SuperCollider library for Python

Overview

PyPI Documentation Status PyPI - Python Version

SuperCollider library for Python

This project is a port of core features of SuperCollider's language to Python 3. It is intended to be the same library in a different language and to keep sclang elegance in a pythonic way (if possible).

The main reason for this port is Python's capacity of interaction with other libraries applicable to composition, sonic-art and research. My wish is for this project to be useful for the SuperCollider community.

Note that this project is still under development and there are missing parts, bugs you are welcome to report, and documentation is under construction. The best way to learn about SuperCollider is going to the source.

Example

The idea is that you can write the same in Python as in sclang, with the same logic regarding multichannel expansion, arguments conversion to Control ugens, etc., it should be the same result. For example:

from sc3.all import *

s.boot()

@synthdef
def sine(freq=440, amp=0.1, gate=1):
    sig = SinOsc(freq) * amp
    env = EnvGen(Env.adsr(), gate, done_action=2)
    Out(0, (sig * env).dup())

sine.dump_ugens()

Wait for boot...

n = Synth('sine')
n.set('amp', 0.05)
n.set('freq', 550)
s.dump_tree(True)
n.release()
# s.free_nodes()  # If something went wrong free all nodes.
s.quit()  # Stop server at the end of interactive session or just quit ipython.

Install

From PyPI (usually outdated by now):

pip3 install sc3

From source in develop mode (recommended for the moment):

python3 setup.py develop --user

License

The sc3 library is free software available under Version 3 of the GNU General Public License. See COPYING for details.

NB: The sc3 library is a Python translation of the SuperCollider's library and inherits its same license and community guidelines.

Comments
  • FM7 synth

    FM7 synth

    Hi! Is it possible to add FM7 synth? I am especially interested in its arAlgo function. Thanks.

    Also, I tried writing something like:

    from sc3.synth import ugen as ugn
    
    class FM7(ugn.MultiOutUGen):
        @classmethod
        def ar(cls, ctlMatrix, modMatrix):
            return cls._multi_new("audio", ctlMatrix, modMatrix)
    
        def _init_ugen(self, *inputs):
            self._inputs = inputs
            return self._init_outputs(6, self.rate)
    

    but it will return "ChannelList([ChannelList([ChannelList([..." which I don't know how to convert into sound.

    opened by gexahedron 16
  • Add missing bin_dir() method to DarwinPlatform class.

    Add missing bin_dir() method to DarwinPlatform class.

    I'm not sure if this is the correct way to add this method, but it worked on my Mac.

    I had to add this because when it tried to import everything (Sphinx does this when building docs), it tried to call bin_dir() and raised a NotImplementedError.

    opened by munshkr 3
  • Updates on the fly, for live-coding

    Updates on the fly, for live-coding

    Hi! Say I want something like Pbindef with dynamic updating, for live coding, like here in Eli Fieldsteel video: https://youtu.be/8Is3hJvzjvs?t=1217 How do I do this? How do I use quant (so that new updates/changes will land on a beat, not in the middle of a pattern)? How do I update speed of TempoClock?

    opened by gexahedron 2
  • Scsynth not found.

    Scsynth not found.

    Hello, First this project look really interesting. Something you dream at night when you begin in Python and Supercollider... And you did it! i love the transcription between the two laguage.

    I wanted to test and get this error (with your example script) : ERROR:sc3.synth.server:localhost failed to boot, program scsynth not found

    I'm on mac OS Catalina. Python3.7.4 SuperCollider 3.11.2 My regular SuperCollider app is in /Applications/SuperCollider. I copied this app to this path to : /Users/macbook/Applications/SuperCollider but same result...

    got sc3 from source code in develop mode (everything goes fine).

    For info i can use without problem an other SuperCollider / Pyhton project => supercollider and start SC server within VS-Code. So i'am wondering why it doesn't find my Scsynth program?

    Thank you very much. I hope to test it soon ! Michaël Filler.

    opened by Cricot2 2
  • syntax for patterns, loading buffers etc

    syntax for patterns, loading buffers etc

    Hi,

    I was wondering if you wouldn't mind clarifying what the syntax would be for accessing the patterns functionality, and for loading buffers. Also is JITLib (Ndef, Pdef, Tdef etc) included in this wrapper?

    Thanks,

    Mark

    opened by markhanslip 1
  • Use Sphinx to generate documentation.

    Use Sphinx to generate documentation.

    Includes an index.rst based on README.md, and sets autodoc and other Sphinx extensions for autogenerating module documentation from docstrings.

    Personally, I also recommend configuring readthedocs for free hosting and automatic generation on git pushes :)

    opened by munshkr 1
  • Missing patterns from RandomDistPatterns.sc

    Missing patterns from RandomDistPatterns.sc

    Discussed in https://github.com/smrg-lm/sc3/discussions/14

    Originally posted by d3vp July 31, 2022 So far I have added the following things I found missing in sc3:

    • method: Env.delay
    • class Pgauss(ValuePattern)

    Is there any alternative to delay?

    opened by smrg-lm 0
  • Problem using list of freq in synthdef & Pbind

    Problem using list of freq in synthdef & Pbind

    Hi,

    First of all, thank you for the great library. I am trying to implement this example using sc3.

    from sc3.all import *
    
    @synthdef
    def dtmf(freq=(770, 1633), out=0, amp=0.2, gate=1):
        son = SinOsc.ar(freq, 0).sum() * amp
        env = EnvGen.ar(Env.asr(0.001, 1, 0.001), gate, done_action=2)
        Out.ar(out, Pan2.ar(son * env * amp))
    
    # this works:
    Pbind({'instrument': 'dtmf',
            'dur': Pwhite(0.2, 0.5),
            'sustain': 0.15,
            'amp': 0.3,
            'freq': Prand([697, 1209, 770, 1209], 13)
    }).play();
    
    # but this does not work:
    Pbind({'instrument': 'dtmf',
            'dur': Pwhite(0.2, 0.5),
            'sustain': 0.15,
            'amp': 0.3,
            'freq': Prand([[697, 1209],[770, 1209], [852, 1209], [697, 1336]], 13)
    }).play();
    

    But getting following error:

    ERROR:sc3.base.clock:EventStreamPlayer(EventStreamPlayer._stream_player_func.<locals>.esp_func) scheduled on SystemClock
    Traceback (most recent call last):
      File "/Supercollider/sc3/sc3/base/clock.py", line 237, in _run
        delta = task.__awake__(cls)
      File "/Supercollider/sc3/sc3/base/stream.py", line 608, in __awake__
        return self.next((self, clock))
      File "/Supercollider/sc3/sc3/base/stream.py", line 491, in next
        self._last_value = next(self._iterator)
      File "/Supercollider/sc3/sc3/seq/eventstream.py", line 140, in esp_func
        yield self._play_and_delta(outevent)
      File "/Supercollider/sc3/sc3/seq/eventstream.py", line 148, in _play_and_delta
        outevent.play()
      File "/Supercollider/sc3/sc3/seq/event.py", line 624, in play
        self['freq'] = self._detuned_freq()  # Before _get_msg_params.
      File "/Supercollider/sc3/sc3/seq/event.py", line 221, in _detuned_freq
        return self('freq') * self('harmonic') + self('detune')
    TypeError: can't multiply sequence by non-int of type 'float'
    

    Not sure if I am doing something wrong or it is a bug or missing feature.

    opened by d3vp 4
Owner
Lucas Samaruga
Lucas Samaruga
K2HASH Python library - NoSQL Key Value Store(KVS) library

k2hash_python Overview k2hash_python is an official python driver for k2hash. Install Firstly you must install the k2hash shared library: curl -o- htt

Yahoo! JAPAN 3 Oct 19, 2022
Msgpack serialization/deserialization library for Python, written in Rust using PyO3 and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Aviram Hassan 139 Dec 30, 2022
PyPIContents is an application that generates a Module Index from the Python Package Index (PyPI) and also from various versions of the Python Standard Library.

PyPIContents is an application that generates a Module Index from the Python Package Index (PyPI) and also from various versions of the Python Standar

Collage Labs 10 Nov 19, 2022
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as — and yet conspicuously mis

Mahmoud Hashemi 6k Jan 6, 2023
A Python library to simulate a Zoom H6 recorder remote control

H6 A Python library to emulate a Zoom H6 recorder remote control Introduction This library allows you to control your Zoom H6 recorder from your compu

Matias Godoy 68 Nov 2, 2022
Python library for creating PEG parsers

PyParsing -- A Python Parsing Module Introduction The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the t

Pyparsing 1.7k Jan 3, 2023
Python library to natively send files to Trash (or Recycle bin) on all platforms.

Send2Trash -- Send files to trash on all platforms Send2Trash is a small package that sends files to the Trash (or Recycle Bin) natively and on all pl

Andrew Senetar 224 Jan 4, 2023
Python screenshot library, replacement for the Pillow ImageGrab module on Linux.

tldr: Use Pillow The pyscreenshot module is obsolete in most cases. It was created because PIL ImageGrab module worked on Windows only, but now Linux

null 455 Dec 24, 2022
A functional standard library for Python.

Toolz A set of utility functions for iterators, functions, and dictionaries. See the PyToolz documentation at https://toolz.readthedocs.io LICENSE New

null 4.1k Jan 4, 2023
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as — and yet conspicuously mis

Mahmoud Hashemi 5.4k Feb 20, 2021
Retrying library for Python

Tenacity Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just

Julien Danjou 4.3k Jan 2, 2023
Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything.

Retrying Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just

Ray Holder 1.9k Dec 29, 2022
Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Salma Saidane 64 Sep 28, 2022
Paprika is a python library that reduces boilerplate. Heavily inspired by Project Lombok.

Image courtesy of Anna Quaglia (Photographer) Paprika Paprika is a python library that reduces boilerplate. It is heavily inspired by Project Lombok.

Rayan Hatout 55 Dec 26, 2022
A Python library that helps data scientists to infer causation rather than observing correlation.

A Python library that helps data scientists to infer causation rather than observing correlation.

QuantumBlack Labs 1.7k Jan 4, 2023
Python library and cli util for https://www.zerochan.net/

Zerochan Library for Zerochan.net with pics parsing and downloader included! Features CLI utility for pics downloading from zerochan.net Library for c

kiriharu 10 Oct 11, 2022
An Advanced Wordlist Library Written In Python For Acm114

RBAPG ->RBAPG is the abbreviation of "Rule Based Attack Password Generator". ->This module is a wordlist generator module. ->You can generate randomly

Aziz Kaplan 11 Aug 28, 2022
Datamol is a python library to work with molecules.

Datamol is a python library to work with molecules. It's a layer built on top of RDKit and aims to be as light as possible.

datamol 276 Dec 19, 2022