Skip to content

Commit

Permalink
fix lilytools
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellkammer committed May 21, 2024
1 parent 03a13a0 commit 25c6466
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
23 changes: 12 additions & 11 deletions maelzel/core/mobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from maelzel.common import asmidi, F, asF, F0, F1
from maelzel.textstyle import TextStyle

from ._common import logger
from maelzel.core._common import logger
from ._typedefs import *
from .config import CoreConfig
from .workspace import Workspace
Expand All @@ -68,6 +68,7 @@
from typing_extensions import Self
import matplotlib.pyplot as plt
from maelzel.core import chain
from maelzel.scoring.renderoptions import RenderOptions


__all__ = (
Expand Down Expand Up @@ -610,7 +611,7 @@ def quantizePitch(self, step=0.) -> Self:
""" Returns a new object, with pitch rounded to step """
raise NotImplementedError()

def transposeByRatio(self, ratio: float) -> _MObjT:
def transposeByRatio(self, ratio: float) -> Self:
"""
Transpose this by a given frequency ratio, if applicable
Expand Down Expand Up @@ -658,7 +659,7 @@ def show(self,
resolution: dpi resolution when rendering to an image, overrides the
:ref:`config key 'show.pngResolution' <config_show_pngresolution>`
"""
cfg = config or Workspace.active.config
cfg = config or Workspace.getConfig()
if resolution:
cfg = cfg.clone({'show.pngResolution': resolution})

Expand Down Expand Up @@ -732,7 +733,7 @@ def quantizedScore(self,
list of QuantizedMeasures. To access the recursive notation structure of each measure
call its :meth:`~maelzel.scoring.QuantizedMeasure.asTree` method
"""
w = Workspace.active
w = Workspace.getActive()
if config is None:
config = w.config

Expand Down Expand Up @@ -847,7 +848,7 @@ def _renderImage(self,
.. seealso:: :meth:`~maelzel.core.mobj.MObj.render`
"""
w = Workspace.active
w = Workspace.getActive()
if not config:
config = w.config
if not backend:
Expand Down Expand Up @@ -924,7 +925,7 @@ def scoringParts(self,
package to represent notated events. It represents a list of non-simultaneous Notations,
unquantized and independent of any score structure
"""
notations = self.scoringEvents(config=config or Workspace.active.config)
notations = self.scoringEvents(config=config or Workspace.getConfig())
if not notations:
return []
scoring.resolveOffsets(notations)
Expand Down Expand Up @@ -1050,7 +1051,7 @@ def write(self,
return
outfile = selected
ext = os.path.splitext(outfile)[1]
cfg = Workspace.active.config
cfg = Workspace.getConfig()
if ext == '.ly' or ext == '.mid' or ext == '.midi':
backend = 'lilypond'
elif ext == '.xml' or ext == '.musicxml':
Expand Down Expand Up @@ -1078,7 +1079,7 @@ def _htmlImage(self) -> str:
imgpath = self._renderImage()
if not imgpath:
return ''
scaleFactor = Workspace.active.config.get('show.scaleFactor', 1.0)
scaleFactor = Workspace.getConfig().get('show.scaleFactor', 1.0)
width, height = emlib.img.imgSize(imgpath)
img = emlib.img.htmlImgBase64(imgpath,
width=f'{int(width * scaleFactor)}px')
Expand Down Expand Up @@ -1211,7 +1212,7 @@ def events(self,
args = kwargs

if workspace is None:
workspace = Workspace.active
workspace = Workspace.getActive()

if (struct := self.scorestruct()) is not None:
workspace = workspace.clone(scorestruct=struct, config=workspace.config)
Expand Down Expand Up @@ -1355,9 +1356,9 @@ def play(self,
... Chord("4E 4G", 3).play(instr='piano')
"""
if config is not None:
workspace = Workspace.active.clone(config=config)
workspace = Workspace.getActive().clone(config=config)
elif workspace is None:
workspace = Workspace.active
workspace = Workspace.getActive()

events = self.events(delay=delay,
chan=chan,
Expand Down
2 changes: 1 addition & 1 deletion maelzel/core/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def definedInstrs(self) -> dict[str, csoundengine.instr.Instr]:
return instrs

def playSample(self,
source: int | str | TableProxy | tuple[np.ndarray, int] | audiosample.Sample,
source: int | str | tuple[np.ndarray, int] | audiosample.Sample,
delay=0.,
dur=0,
chan=1,
Expand Down
2 changes: 1 addition & 1 deletion maelzel/music/lilytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def installLilypond(usehomebrew=True) -> str:
"'brew install lilypond'. For more information see "
"https://formulae.brew.sh/formula/lilypond#default")

lilybin = lilyponddist.lilypondbin(autoinstall=True)
lilybin = lilyponddist.lilypondbin()
if not lilybin or not lilybin.exists():
raise RuntimeError(f"Could not install lilypond")
lilypath = lilybin.as_posix()
Expand Down
7 changes: 5 additions & 2 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"ignore": ["**/node_modules", "**/__pycache__"],
"include": ["csoundengine"],
"pythonPlatform": "Linux",
"pythonVersion": "3.10",
"reportMissingImports": true,
Expand All @@ -9,5 +8,9 @@
"typeCheckingMode": "basic",
"venvPath": "/home/em/.virtualenvs",
"venv": "maelzel",
"strictParameterNoneValue": false
"strictParameterNoneValue": false,
"executionEnvironments": [
{"root": "."}
],
"include": ["maelzel/core", "maelzel/scoring", "scorestruct"]
}

0 comments on commit 25c6466

Please sign in to comment.