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/supriya-project/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 import Envelope, synthdef
>>> from supriya.ugens import EnvGen, Out, SinOsc

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)

... and then sync the server before proceeding to ensure the SynthDef has been fully parsed by scsynth:

>>> _ = server.sync()

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


Release history Release notifications | RSS feed

Download files

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

Source Distribution

supriya-26.3b0.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

supriya-26.3b0-py3-none-any.whl (957.7 kB view details)

Uploaded Python 3

File details

Details for the file supriya-26.3b0.tar.gz.

File metadata

  • Download URL: supriya-26.3b0.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for supriya-26.3b0.tar.gz
Algorithm Hash digest
SHA256 c6318acd0da3d3e8c3b0abc39ef01fcda1d96b6e752ff4cd67428c8660de0a4e
MD5 fc2b04859b52be14b957640fefcd2405
BLAKE2b-256 43df7744e55c554b8b0ac40acfd8d984ec0bec056631bd79df448b66de0ad7a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for supriya-26.3b0.tar.gz:

Publisher: publish.yml on supriya-project/supriya

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file supriya-26.3b0-py3-none-any.whl.

File metadata

  • Download URL: supriya-26.3b0-py3-none-any.whl
  • Upload date:
  • Size: 957.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for supriya-26.3b0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0c374191fd855528bc087917b358937521ef675aa24ca1f9ad43378e7cfd428
MD5 5c1498bb795f5ed8184138b5bb6d781c
BLAKE2b-256 024f455601b4a190f585ac725f17de10ae45c0dcee6984697a461cf5e037e023

See more details on using hashes here.

Provenance

The following attestation bundles were made for supriya-26.3b0-py3-none-any.whl:

Publisher: publish.yml on supriya-project/supriya

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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