Supriya (22.2b0)

Attention

Documentation is under construction. Stand by.

Supriya is a Python API for SuperCollider.

Supriya lets you:

Quickstart

1. Get Supriya

pip install supriya
git clone https://github.com/josiah-wolf-oberholtzer/supriya.git
cd supriya
pip install -e .

Note

Consult our installation instructions for detailed help on getting Supriya, setting it up, and installing any additional dependencies like Graphviz.

2. Get SuperCollider

Get SuperCollider from http://supercollider.github.io/.

3. Boot the server

Start your Python interpreter and import Supriya:

>>> import supriya

Boot the SuperCollider server:

>>> server = supriya.Server().boot()

3. Build a SynthDef

Import some classes:

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

Make a synthesizer definition:

>>> @synthdef()
... def simple_sine(frequency=440, amplitude=0.1, gate=1):
...     sine = SinOsc.ar(frequency) * amplitude
...     envelope = EnvGen.kr(envelope=Envelope.adsr(), gate=gate, done_action=2)
...     Out.ar(0, [sine * envelope] * 2)
... 

Visualize the SynthDef (requires Graphviz):

>>> supriya.graph(simple_sine)

Allocate it on the server:

>>> _ = server.add_synthdef(simple_sine)

4. Create some nodes

Create and allocate a group:

>>> group = server.add_group()

Synchronize with the server:

>>> server.sync()
<Server: udp://127.0.0.1:57110, 8i8o>

Create some synthesizers with the previously defined synthesizer definition, and allocate them on the server as a child of the previously created group:

>>> for i in range(3):
...     _ = group.add_synth(synthdef=simple_sine, frequency=111 * (i + 1))
... 

Query the server’s node tree:

>>> print(server.query())
NODE TREE 0 group
    1 group
        1000 group
            1003 simple_sine
                amplitude: 0.1, frequency: 333.0, gate: 1.0
            1002 simple_sine
                amplitude: 0.1, frequency: 222.0, gate: 1.0
            1001 simple_sine
                amplitude: 0.1, frequency: 111.0, gate: 1.0

Visualize the server’s node tree:

>>> supriya.graph(server)

5. Release and quit

Release the synths:

>>> for synth in group[:]:
...     synth.release()
... 
<+ Synth: 1003 simple_sine>
<+ Synth: 1002 simple_sine>
<+ Synth: 1001 simple_sine>

Quit the server:

>>> server.quit()
<Server: offline>