diff --git a/csoundengine/synth.py b/csoundengine/synth.py index 9e51bb7..faeec39 100644 --- a/csoundengine/synth.py +++ b/csoundengine/synth.py @@ -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: @@ -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: @@ -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: @@ -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) diff --git a/pyproject.toml b/pyproject.toml index dc7d0c1..b045cdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/setup.py~ b/setup.py~ deleted file mode 100755 index 5ebd005..0000000 --- a/setup.py~ +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from setuptools import setup -import os - -version = (2, 10, 5) - -from os import path -this_directory = path.abspath(path.dirname(__file__)) -with open(path.join(this_directory, 'README.rst'), encoding='utf-8') as f: - long_description = f.read() - - -def package_files(directory): - paths = [] - for (path, directories, filenames) in os.walk(directory): - for filename in filenames: - paths.append(os.path.join('..', path, filename)) - return paths - - -datafiles = package_files('csoundengine/data') - - -setup( - name='csoundengine', - python_requires=">=3.9", - version=".".join(map(str, version)), - description='A synthesis framework using csound', - long_description=long_description, - author='Eduardo Moguillansky', - author_email='eduardo.moguillansky@gmail.com', - url='https://github.com/gesellkammer/csoundengine', - packages=[ - 'csoundengine', - ], - install_requires=[ - "numpy", - "scipy", - "matplotlib", - "cachetools", - "JACK-client", - "appdirs", - "pygments", - "sf2utils", - "ipywidgets", - "progressbar2", - "xxhash", - "docstring_parser", - "typing_extensions", - - "ctcsound7>=0.4.6", - "sndfileio>=1.9.4", - "emlib>=1.15.0", - "configdict>=2.10.0", - "bpf4>=1.10.1", - "numpyx>=1.3.3", - "pitchtools>=1.14.0", - "risset>=2.9.1", - "sounddevice" - ], - license="BSD", - classifiers=[ - 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)' - ], - package_data={'csoundengine': datafiles}, - include_package_data=True, - zip_safe=False -)