Skip to content

Commit

Permalink
Consolidate synthdefs into ugens
Browse files Browse the repository at this point in the history
  • Loading branch information
josiah-wolf-oberholtzer committed Mar 25, 2024
1 parent 4da10f2 commit b68337f
Show file tree
Hide file tree
Showing 86 changed files with 3,361 additions and 28,480 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Supriya lets you:
in realtime.

- Compile SuperCollider
[SynthDefs](http://josiahwolfoberholtzer.com/supriya/api/supriya/synthdefs/index.html)
[SynthDefs](http://josiahwolfoberholtzer.com/supriya/api/supriya/ugens/index.html)
natively in Python code

- Explore
Expand Down Expand Up @@ -69,8 +69,8 @@ Boot the SuperCollider server:

Import some classes:

>>> from supriya import Envelope, synthdef
>>> from supriya.ugens import EnvGen, Out, SinOsc
>>> from supriya.synthdefs import Envelope, synthdef

Make a synthesizer definition:

Expand Down
25,031 changes: 0 additions & 25,031 deletions docs/notebooks/introduction.ipynb

This file was deleted.

11 changes: 0 additions & 11 deletions docs/notebooks/rise.css

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Supriya lets you:
:py:class:`context <supriya.contexts.core.Context>` interface.

- Compile SuperCollider :py:class:`SynthDefs
<supriya.synthdefs.synthdefs.SynthDef>` natively in Python code.
<supriya.ugens.bases.SynthDef>` natively in Python code.

- Schedule :py:mod:`~supriya.patterns` and callbacks with tempo- and
meter-aware :py:mod:`~supriya.clocks`.
Expand Down Expand Up @@ -76,8 +76,8 @@ Boot the SuperCollider server::

Import some classes::

>>> from supriya import Envelope, synthdef
>>> from supriya.ugens import EnvGen, Out, SinOsc
>>> from supriya.synthdefs import Envelope, synthdef

Make a synthesizer definition::

Expand Down
9 changes: 6 additions & 3 deletions supriya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@
CalculationRate,
DoneAction,
HeaderFormat,
ParameterRate,
SampleFormat,
)
from .io import graph, play, plot, render
from .osc import OscBundle, OscCallback, OscMessage
from .patterns import Pattern
from .synthdefs import (
from .ugens import (
Envelope,
UGen,
UGenVector,
UGenOperable,
SynthDef,
SynthDefBuilder,
synthdef,
)
from .ugens import UGen, UGenArray, UGenOperable
from .assets.synthdefs import default
from .scsynth import Options

Expand Down Expand Up @@ -92,7 +95,7 @@
"SynthDefBuilder",
"TimeUnit",
"UGen",
"UGenArray",
"UGenVector",
"UGenOperable",
"__version__",
"__version_info__",
Expand Down
12 changes: 10 additions & 2 deletions supriya/assets/synthdefs/clap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from ...synthdefs import Envelope, SynthDef, SynthDefBuilder
from ...ugens import BPF, HPF, EnvGen, Out, WhiteNoise
from ...ugens import (
BPF,
HPF,
EnvGen,
Envelope,
Out,
SynthDef,
SynthDefBuilder,
WhiteNoise,
)


def _build_clap_synthdef() -> SynthDef:
Expand Down
15 changes: 13 additions & 2 deletions supriya/assets/synthdefs/default.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from ...enums import DoneAction, ParameterRate
from ...synthdefs import Parameter, SynthDef, SynthDefBuilder
from ...ugens import LPF, Linen, Mix, OffsetOut, Pan2, Rand, VarSaw, XLine
from ...ugens import (
LPF,
Linen,
Mix,
OffsetOut,
Pan2,
Parameter,
Rand,
SynthDef,
SynthDefBuilder,
VarSaw,
XLine,
)


def _build_default_synthdef() -> SynthDef:
Expand Down
15 changes: 13 additions & 2 deletions supriya/assets/synthdefs/kick.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from supriya.synthdefs import Envelope, SynthDef, SynthDefBuilder
from supriya.ugens import BPF, RLPF, EnvGen, Impulse, LinLin, Out, PinkNoise, SinOsc
from supriya.ugens import (
BPF,
RLPF,
EnvGen,
Envelope,
Impulse,
LinLin,
Out,
PinkNoise,
SinOsc,
SynthDef,
SynthDefBuilder,
)


def _build_kick_synthdef() -> SynthDef:
Expand Down
13 changes: 11 additions & 2 deletions supriya/assets/synthdefs/multiband_compressor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from ...synthdefs import SynthDef, SynthDefBuilder
from ...ugens import HPF, LPF, CompanderD, In, Limiter, ReplaceOut, Sum4
from ...ugens import (
HPF,
LPF,
CompanderD,
In,
Limiter,
ReplaceOut,
Sum4,
SynthDef,
SynthDefBuilder,
)


def _make_synthdef(channel_count: int = 2) -> SynthDef:
Expand Down
3 changes: 1 addition & 2 deletions supriya/assets/synthdefs/simple_sine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...synthdefs import SynthDef, SynthDefBuilder
from ...ugens import Out, SinOsc
from ...ugens import Out, SinOsc, SynthDef, SynthDefBuilder


def _build_synthdef() -> SynthDef:
Expand Down
3 changes: 1 addition & 2 deletions supriya/assets/synthdefs/sweep_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ...synthdefs import SynthDef, SynthDefBuilder
from ...ugens import HPF, LPF, In, Lag, ReplaceOut
from ...ugens import HPF, LPF, In, Lag, ReplaceOut, SynthDef, SynthDefBuilder


def _build_synthdef() -> SynthDef:
Expand Down
5 changes: 1 addition & 4 deletions supriya/assets/synthdefs/system_synthdefs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from ...enums import EnvelopeShape
from ...synthdefs import Envelope, SynthDef, SynthDefBuilder
from ...ugens import EnvGen, In, InFeedback, Out

__all__ = []
from ...ugens import EnvGen, Envelope, In, InFeedback, Out, SynthDef, SynthDefBuilder


def _build_link_audio_synthdef(channel_count: int) -> SynthDef:
Expand Down
3 changes: 1 addition & 2 deletions supriya/assets/synthdefs/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ...enums import ParameterRate
from ...synthdefs import Parameter, SynthDef, SynthDefBuilder
from ...ugens import Out, SinOsc
from ...ugens import Out, Parameter, SinOsc, SynthDef, SynthDefBuilder


def _build_test_synthdef() -> SynthDef:
Expand Down
2 changes: 1 addition & 1 deletion supriya/contexts/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

from ..enums import AddAction, CalculationRate, ParameterRate
from ..scsynth import Options
from ..synthdefs import SynthDef
from ..typing import (
AddActionLike,
CalculationRateLike,
HeaderFormatLike,
SampleFormatLike,
SupportsOsc,
)
from ..ugens import SynthDef
from .allocators import BlockAllocator, NodeIdAllocator
from .entities import (
Buffer,
Expand Down
2 changes: 1 addition & 1 deletion supriya/contexts/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from ..assets.synthdefs.default import default
from ..enums import AddAction, CalculationRate
from ..io import PlayMemo
from ..synthdefs import SynthDef
from ..typing import AddActionLike, HeaderFormatLike, SampleFormatLike, SupportsRender
from ..ugens import SynthDef
from .errors import InvalidCalculationRate, InvalidMoment
from .responses import BufferInfo, NodeInfo

Expand Down
2 changes: 1 addition & 1 deletion supriya/contexts/nonrealtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from ..enums import CalculationRate, HeaderFormat, SampleFormat
from ..osc import OscBundle
from ..scsynth import AsyncNonrealtimeProcessProtocol, Options
from ..synthdefs import SynthDef
from ..typing import HeaderFormatLike, SampleFormatLike, SupportsOsc
from ..ugens import SynthDef
from .core import Context, ContextError, ContextObject, Node
from .requests import DoNothing, RequestBundle, Requestable

Expand Down
2 changes: 1 addition & 1 deletion supriya/contexts/realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
ProcessProtocol,
SyncProcessProtocol,
)
from ..synthdefs import SynthDef
from ..typing import SupportsOsc
from ..ugens import SynthDef
from .core import (
Buffer,
Bus,
Expand Down
4 changes: 2 additions & 2 deletions supriya/contexts/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

from ..enums import AddAction, HeaderFormat, RequestName, SampleFormat
from ..osc import OscBundle, OscMessage
from ..synthdefs import SynthDef, SynthDefCompiler
from ..typing import AddActionLike, HeaderFormatLike, SampleFormatLike, SupportsOsc
from ..ugens import SynthDef, compile_synthdefs
from .responses import Response

if TYPE_CHECKING:
Expand Down Expand Up @@ -1649,7 +1649,7 @@ class ReceiveSynthDefs(Request):
on_completion: Optional[Requestable] = None

def to_osc(self) -> OscMessage:
contents = [SynthDefCompiler.compile_synthdefs(self.synthdefs)]
contents = [compile_synthdefs(self.synthdefs)]
if self.on_completion:
contents.append(self.on_completion.to_osc())
return OscMessage(RequestName.SYNTHDEF_RECEIVE, *contents)
Expand Down
38 changes: 13 additions & 25 deletions supriya/contexts/shm.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 4 additions & 18 deletions supriya/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def from_expr(cls, expr) -> "CalculationRate":
::
>>> import supriya.synthdefs
>>> import supriya.ugens
::
Expand Down Expand Up @@ -125,13 +124,12 @@ def from_expr(cls, expr) -> "CalculationRate":
Return calculation-rate.
"""
from .synthdefs import Parameter
from .ugens import OutputProxy, UGen
from .ugens import Parameter

if isinstance(expr, (int, float)) and not isinstance(expr, cls):
return cast(CalculationRate, CalculationRate.SCALAR)
elif isinstance(expr, (OutputProxy, UGen)):
if hasattr(expr, "calculation_rate"):
return expr.calculation_rate
elif isinstance(expr, (int, float)) and not isinstance(expr, cls):
return cast(CalculationRate, CalculationRate.SCALAR)
elif isinstance(expr, Parameter):
name = expr.parameter_rate.name
if name == "TRIGGER":
Expand All @@ -141,8 +139,6 @@ def from_expr(cls, expr) -> "CalculationRate":
return super().from_expr(expr)
elif isinstance(expr, Sequence):
return max(CalculationRate.from_expr(item) for item in expr)
elif hasattr(expr, "calculation_rate"):
return cls.from_expr(expr.calculation_rate)
return super().from_expr(expr)

@property
Expand Down Expand Up @@ -475,13 +471,3 @@ class UnaryOperator(IntEnumeration):
THRU = 47
TRIANGLE_WINDOW = 51
WELCH_WINDOW = 50


class Unit(IntEnumeration):
UNDEFINED = 0
DECIBELS = 1
AMPLITUDE = 2
SECONDS = 3
MILLISECONDS = 4
HERTZ = 5
SEMITONES = 6
Loading

0 comments on commit b68337f

Please sign in to comment.