Skip to content

Commit

Permalink
* fix: allow SynthGroups with no synths, instead of relying in a dumm…
Browse files Browse the repository at this point in the history
…y synth

* update dependencies
  • Loading branch information
gesellkammer committed Oct 10, 2024
1 parent 268b09b commit e9c48b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 79 deletions.
23 changes: 16 additions & 7 deletions csoundengine/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def ui(self, **specs: tuple[float, float]) -> None:
return ui(self, specs=specs)


def ui(specs: dict[str, tuple[float, float]]):
def ui(event, specs: dict[str, tuple[float, float]]):
from . import interact
dynparams = event.dynamicParamNames(aliases=True, aliased=False)
if not dynparams:
Expand Down Expand Up @@ -617,9 +617,14 @@ class SynthGroup(BaseSchedEvent):
__slots__ = ('synths', 'session', 'autostop', '__weakref__')

def __init__(self, synths: list[Synth], autostop=False) -> None:
start = min(synth.start for synth in synths)
end = max(synth.end for synth in synths)
dur = end - start
if not synths:
start = 0.
end = 0.
dur = 0.
else:
start = min(synth.start for synth in synths)
end = max(synth.end for synth in synths)
dur = end - start
BaseSchedEvent.__init__(self, start=start, dur=dur)
flatsynths: list[Synth] = []
for synth in synths:
Expand All @@ -629,7 +634,7 @@ def __init__(self, synths: list[Synth], autostop=False) -> None:
flatsynths.append(synth)
self.synths: list[Synth] = flatsynths
self.autostop = autostop
self.session = self.synths[0].session
self.session = self.synths[0].session if synths else None

def __del__(self):
if self.autostop:
Expand Down Expand Up @@ -821,10 +826,14 @@ def ui(self, **specs: tuple[float, float]) -> None:

def _repr_html_(self) -> str:
assert jupytertools.inside_jupyter()
bold = lambda txt: span(txt, bold=True)
span = jupytertools.htmlSpan

if not self.synths:
return f'{bold("SynthGroup")}(synths=[])'

if config['jupyter_synth_repr_stopbutton']:
jupytertools.displayButton("Stop", self.stop)
span = jupytertools.htmlSpan
bold = lambda txt: span(txt, bold=True)
now = self[0].session.engine.elapsedTime()
start = min(max(0., s.start - now) for s in self)
end = max(s.dur + s.start - now for s in self)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [

"ctcsound7>=0.4.6",
"sndfileio>=1.9.4",
"emlib>=1.15.0",
"emlib>=1.16",
"configdict>=2.10.0",
"bpf4>=1.10.1",
"numpyx>=1.3.3",
Expand Down
71 changes: 0 additions & 71 deletions setup.py~

This file was deleted.

0 comments on commit e9c48b1

Please sign in to comment.