Skip to main content

A Python API for SuperCollider

Project description

Supriya

Supriya is a Python API for SuperCollider.

Supriya lets you:

Quickstart

1. Get Supriya

Install from PyPI:

pip install supriya

Or from source:

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

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()

4. 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=frequency) * amplitude
...     envelope = EnvGen.kr(envelope=Envelope.adsr(), gate=gate, done_action=2)
...     Out.ar(bus=0, source=[sine * envelope] * 2)
...

Visualize the SynthDef (requires Graphviz):

>>> supriya.graph(simple_sine)

Allocate it on the server:

>>> _ = server.add_synthdefs(simple_sine)

5. Create some nodes

Create and allocate a group:

>>> group = server.add_group()

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(simple_sine, frequency=111 * (i + 1))
...

Query the server's node tree:

>>> print(server.query_tree())
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

6. Release and quit

Release the synths:

>>> for synth in group.children[:]:
...     synth.free()
...

Quit the server:

>>> server.quit()

License

This library is made available under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

supriya-23.3b0.tar.gz (4.5 MB view hashes)

Uploaded Source

Built Distributions

supriya-23.3b0-cp310-cp310-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

supriya-23.3b0-cp310-cp310-win32.whl (1.1 MB view hashes)

Uploaded CPython 3.10 Windows x86

supriya-23.3b0-cp310-cp310-musllinux_1_1_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

supriya-23.3b0-cp310-cp310-musllinux_1_1_i686.whl (2.7 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

supriya-23.3b0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

supriya-23.3b0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

supriya-23.3b0-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

supriya-23.3b0-cp39-cp39-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

supriya-23.3b0-cp39-cp39-win32.whl (1.1 MB view hashes)

Uploaded CPython 3.9 Windows x86

supriya-23.3b0-cp39-cp39-musllinux_1_1_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

supriya-23.3b0-cp39-cp39-musllinux_1_1_i686.whl (2.7 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

supriya-23.3b0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

supriya-23.3b0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

supriya-23.3b0-cp39-cp39-macosx_10_9_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

supriya-23.3b0-cp38-cp38-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

supriya-23.3b0-cp38-cp38-win32.whl (1.1 MB view hashes)

Uploaded CPython 3.8 Windows x86

supriya-23.3b0-cp38-cp38-musllinux_1_1_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

supriya-23.3b0-cp38-cp38-musllinux_1_1_i686.whl (2.7 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

supriya-23.3b0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

supriya-23.3b0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

supriya-23.3b0-cp38-cp38-macosx_10_9_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page