SynthDef

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph cluster_builtins { graph [label=builtins]; node [color=1]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_supriya.realtime" { graph [label="supriya.realtime"]; node [color=2]; "supriya.realtime.ServerObjectProxy.ServerObjectProxy" [URL="../api/supriya/synthdefs/../realtime/ServerObjectProxy.html#supriya.realtime.ServerObjectProxy.ServerObjectProxy", label="Server\nObject\nProxy", shape=oval, style=bold, target=_top]; } subgraph "cluster_supriya.synthdefs" { graph [label="supriya.synthdefs"]; node [color=3]; "supriya.synthdefs.SynthDef.SynthDef" [URL="../api/supriya/synthdefs/SynthDef.html#supriya.synthdefs.SynthDef.SynthDef", color=black, fontcolor=white, label="Synth\nDef", target=_top]; } subgraph "cluster_supriya.system" { graph [label="supriya.system"]; node [color=4]; "supriya.system.SupriyaObject.SupriyaObject" [URL="../api/supriya/synthdefs/../system/SupriyaObject.html#supriya.system.SupriyaObject.SupriyaObject", label="Supriya\nObject", target=_top]; } "builtins.object" -> "supriya.system.SupriyaObject.SupriyaObject"; "supriya.realtime.ServerObjectProxy.ServerObjectProxy" -> "supriya.synthdefs.SynthDef.SynthDef"; "supriya.system.SupriyaObject.SupriyaObject" -> "supriya.realtime.ServerObjectProxy.ServerObjectProxy"; }

class supriya.synthdefs.SynthDef.SynthDef(ugens, name=None, optimize=True, parameter_names=None, **kwargs)[source]

A synth definition.

>>> import supriya.synthdefs
>>> import supriya.ugens
>>> with supriya.synthdefs.SynthDefBuilder(frequency=440) as builder:
...     sin_osc = supriya.ugens.SinOsc.ar(frequency=builder['frequency'])
...     out = supriya.ugens.Out.ar(bus=0, source=sin_osc)
...
>>> synthdef = builder.build()
>>> graph(synthdef)  
>>> import supriya.realtime
>>> server = supriya.realtime.Server().boot()
>>> synthdef.allocate(server=server)
<SynthDef: 9c4eb4778dc0faf39459fa8a5cd45c19>
>>> synthdef in server
True
>>> synthdef.free()
>>> synthdef in server
False
>>> server.quit()
<Server: offline>

Attributes Summary

__eq__ Return self==value.
__graph__ Graphs SynthDef.
__hash__ Return hash(self).
__repr__ Return repr(self).
__str__ Gets string representation of synth definition.
actual_name
allocate
anonymous_name
audio_channel_count
audio_input_channel_count Gets audio input channel count of synthdef.
audio_output_channel_count Gets audio output channel count of synthdef.
compile
constants
control_channel_count
control_input_channel_count Gets control input channel count of synthdef.
control_output_channel_count Gets control output channel count of synthdef.
control_ugens
done_actions
free
has_gate
indexed_parameters
input_ugens
is_allocated
name
output_ugens
parameter_names
parameters
play Plays the synthdef on the server.
to_dict Convert SynthDef to JSON-serializable dictionay.
ugens

Special methods

__eq__(expr)[source]

Return self==value.

__graph__()[source]

Graphs SynthDef.

>>> with supriya.synthdefs.SynthDefBuilder(frequency=440) as builder:
...     sin_osc = supriya.ugens.SinOsc.ar(frequency=builder['frequency'])
...     out = supriya.ugens.Out.ar(bus=0, source=sin_osc)
...
>>> synthdef = builder.build()
>>> print(format(synthdef.__graph__(), 'graphviz'))
digraph synthdef_... {
    graph [bgcolor=transparent,
        color=lightslategrey,
        dpi=72,
        fontname=Arial,
        outputorder=edgesfirst,
        overlap=prism,
        penwidth=2,
        rankdir=LR,
        ranksep=1,
        splines=spline,
        style="dotted, rounded"];
    node [fontname=Arial,
        fontsize=12,
        penwidth=2,
        shape=Mrecord,
        style="filled, rounded"];
    edge [penwidth=2];
    ugen_0 [fillcolor=lightgoldenrod2,
        label="<f_0> Control\n(control) | { { <f_1_0_0> frequency:\n440.0 } }"];
    ugen_1 [fillcolor=lightsteelblue2,
        label="<f_0> SinOsc\n(audio) | { { <f_1_0_0> frequency | <f_1_0_1> phase:\n0.0 } | { <f_1_1_0> 0 } }"];
    ugen_2 [fillcolor=lightsteelblue2,
        label="<f_0> Out\n(audio) | { { <f_1_0_0> bus:\n0.0 | <f_1_0_1> source } }"];
    ugen_0:f_1_0_0:e -> ugen_1:f_1_0_0:w [color=goldenrod];
    ugen_1:f_1_1_0:e -> ugen_2:f_1_0_1:w [color=steelblue];
}

Returns Graphviz graph.

__hash__()[source]

Return hash(self).

__repr__()[source]

Return repr(self).

__str__()[source]

Gets string representation of synth definition.

>>> import supriya.synthdefs
>>> import supriya.ugens
>>> with supriya.synthdefs.SynthDefBuilder() as builder:
...     sin_one = supriya.ugens.SinOsc.ar()
...     sin_two = supriya.ugens.SinOsc.ar(frequency=443)
...     source = sin_one + sin_two
...     out = supriya.ugens.Out.ar(bus=0, source=source)
...
>>> synthdef = builder.build(name='test')
>>> graph(synthdef)  
>>> print(synthdef)
synthdef:
    name: test
    ugens:
    -   SinOsc.ar/0:
            frequency: 440.0
            phase: 0.0
    -   SinOsc.ar/1:
            frequency: 443.0
            phase: 0.0
    -   BinaryOpUGen(ADDITION).ar:
            left: SinOsc.ar/0[0]
            right: SinOsc.ar/1[0]
    -   Out.ar:
            bus: 0.0
            source[0]: BinaryOpUGen(ADDITION).ar[0]

Returns string.


Methods

allocate(server=None)[source]
compile(use_anonymous_name=False)[source]
free()[source]
play(add_action=None, target_node=None, **kwargs)[source]

Plays the synthdef on the server.

>>> server = Server().boot()
>>> synthdef = supriya.assets.synthdefs.default
>>> synth = synthdef.play()
>>> server = server.quit()
to_dict()[source]

Convert SynthDef to JSON-serializable dictionay.

>>> import json
>>> result = supriya.assets.synthdefs.default.to_dict()
>>> result = json.dumps(
...     result,
...     indent=4,
...     separators=(',', ': '),
...     sort_keys=True,
...     )
>>> print(result)
{
    "synthdef": {
        "hash": "da0982184cc8fa54cf9d288a0fe1f6ca",
        "name": "default",
        "parameters": {
            "amplitude": {
                "range": [
                    0,
                    1
                ],
                "rate": "control",
                "unit": null,
                "value": 0.1
            },
            "frequency": {
                "range": [
                    0,
                    1
                ],
                "rate": "control",
                "unit": null,
                "value": 440.0
            },
            "gate": {
                "range": [
                    0,
                    1
                ],
                "rate": "control",
                "unit": null,
                "value": 1.0
            },
            "out": {
                "range": [
                    0,
                    1
                ],
                "rate": "scalar",
                "unit": null,
                "value": 0.0
            },
            "pan": {
                "range": [
                    0,
                    1
                ],
                "rate": "control",
                "unit": null,
                "value": 0.5
            }
        }
    }
}

Read-only properties

actual_name
anonymous_name
audio_channel_count
audio_input_channel_count

Gets audio input channel count of synthdef.

>>> with SynthDefBuilder() as builder:
...     audio_in = supriya.ugens.In.ar(channel_count=1)
...     control_in = supriya.ugens.In.kr(channel_count=2)
...     sin = supriya.ugens.SinOsc.ar(
...          frequency=audio_in,
...          )
...     source = audio_in * control_in[1]
...     audio_out = supriya.ugens.Out.ar(source=[source] * 4)
...
>>> synthdef = builder.build()
>>> graph(synthdef)  
>>> synthdef.audio_input_channel_count
1

Returns integer.

audio_output_channel_count

Gets audio output channel count of synthdef.

>>> with SynthDefBuilder() as builder:
...     audio_in = supriya.ugens.In.ar(channel_count=1)
...     control_in = supriya.ugens.In.kr(channel_count=2)
...     sin = supriya.ugens.SinOsc.ar(
...          frequency=audio_in,
...          )
...     source = audio_in * control_in[1]
...     audio_out = supriya.ugens.Out.ar(source=[source] * 4)
...
>>> synthdef = builder.build()
>>> graph(synthdef)  
>>> synthdef.audio_output_channel_count
4

Returns integer.

constants
control_channel_count
control_input_channel_count

Gets control input channel count of synthdef.

>>> with SynthDefBuilder() as builder:
...     audio_in = supriya.ugens.In.ar(channel_count=1)
...     control_in = supriya.ugens.In.kr(channel_count=2)
...     sin = supriya.ugens.SinOsc.ar(
...          frequency=audio_in,
...          )
...     source = audio_in * control_in[1]
...     audio_out = supriya.ugens.Out.ar(source=[source] * 4)
...
>>> synthdef = builder.build()
>>> graph(synthdef)  
>>> synthdef.control_input_channel_count
2

Returns integer.

control_output_channel_count

Gets control output channel count of synthdef.

>>> with SynthDefBuilder() as builder:
...     audio_in = supriya.ugens.In.ar(channel_count=1)
...     control_in = supriya.ugens.In.kr(channel_count=2)
...     sin = supriya.ugens.SinOsc.ar(
...          frequency=audio_in,
...          )
...     source = audio_in * control_in[1]
...     audio_out = supriya.ugens.Out.ar(source=[source] * 4)
...
>>> synthdef = builder.build()
>>> graph(synthdef)  
>>> synthdef.control_output_channel_count
0

Returns integer.

control_ugens
done_actions
has_gate
indexed_parameters
input_ugens
is_allocated
name
output_ugens
parameter_names
parameters
ugens