synthdefs

class SuperColliderSynthDef(name, body, rates=None)

Bases: supriya.system.SupriyaObject

property body
compile()
property name
property rates
class SynthDef(ugens, name=None, optimize=True, parameter_names=None, **kwargs)

Bases: object

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()
>>> supriya.graph(synthdef)  
>>> import supriya.realtime
>>> server = supriya.Server().boot()
>>> synthdef.allocate(server=server)
<SynthDef: 9c4eb4778dc0faf39459fa8a5cd45c19>
>>> synthdef in server
True
>>> synthdef.free(server)
>>> synthdef in server
False
>>> server.quit()
<Server: offline>
__graph__()

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_9c4eb4778dc0faf39459fa8a5cd45c19 {
    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.

property actual_name
allocate(server)
property anonymous_name
property audio_channel_count
property audio_input_channel_count

Gets audio input channel count of synthdef.

>>> with supriya.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()
>>> supriya.graph(synthdef)  
>>> synthdef.audio_input_channel_count
1

Returns integer.

property audio_output_channel_count

Gets audio output channel count of synthdef.

>>> with supriya.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()
>>> supriya.graph(synthdef)  
>>> synthdef.audio_output_channel_count
4

Returns integer.

compile(use_anonymous_name=False)
property constants
property control_channel_count
property control_input_channel_count

Gets control input channel count of synthdef.

>>> with supriya.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()
>>> supriya.graph(synthdef)  
>>> synthdef.control_input_channel_count
2

Returns integer.

property control_output_channel_count

Gets control output channel count of synthdef.

>>> with supriya.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()
>>> supriya.graph(synthdef)  
>>> synthdef.control_output_channel_count
0

Returns integer.

property control_ugens
property done_actions
free(server)
property has_gate
property indexed_parameters
property input_ugens
property is_allocated
property name
property output_ugens
property parameter_names
property parameters
to_dict()

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
            }
        }
    }
}
property ugens
class UGenSortBundle(ugen, width_first_antecedents)

Bases: supriya.system.SupriyaObject

clear()