csoundengine
============
|sh-month|
.. |sh-month| image:: https://static.pepy.tech/badge/csoundengine/month
This package implements an intuitive interface to run and control a csound process
Documentation
-------------
https://csoundengine.readthedocs.io/en/latest/index.html
-----
Introduction
------------
The core of this package is the ``Engine`` class, which wraps a csound
process and allows transparent control over all parameters, while providing
sane defaults. It uses the csound API to communicate with a running csound
instance. All audio processing is run in a separate performance thread.
.. code-block:: python
from csoundengine import *
# create an Engine with default options for the platform.
engine = Engine()
# Define an instrument
engine.compile(r'''
instr synth
; pfields of the instrument
kmidinote = p4
kamp = p5
kcutoff = p6
kdetune = p7
kfreq = mtof:k(kmidinote)
; A filtered sawtooth
asig = vco2:a(kamp*0.7, kfreq)
asig += vco2:a(kamp*0.7, kfreq + kdetune)
asig = moogladder2(asig, kcutoff, 0.9)
; Attack / Release
aenv = linsegr:a(0, 0.01, 1, 0.2, 0)
asig *= aenv
outs asig, asig
endin
''')
# Start a synth with indefinite duration. This returns the eventid (p1)
# of the running instrument, which can be used to further control it
event = engine.sched("synth", args=[48, 0.2, 3000, 4])
# Change midinote. setp means: set p-field. This sets kmidinote (p4) to 50
engine.setp(event, 4, 50)
# Modify cutoff
engine.setp(event, 6, 1000, delay=4)
# Create a graphic interface to interact with this event. If running within a jupyter notebook
# a html gui is generated, otherwise a native gui is used:
engine.eventUI(event, p4=(0, 127), p5=(0, 1), kcutoff=(100, 5000))
.. figure:: https://raw.githubusercontent.com/gesellkammer/csoundengine/master/docs/assets/eventui2.png
Session - high level interface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Each engine can have an associated ``Session``. A Session provides a
higher level interface, allowing to:
* Define instrument templates (an ``Instr``), which can be instantiated at any order of evaluation, allowing to implement processing chains of any complexity
* An ``Instr`` can have named parameters which can be used to control the event.
* A ``Session`` provides a series of built-in ``Instr``'s to perform some common tasks, like playing samples from memory or from disk, perform audio analysis, etc.
.. figure:: https://raw.githubusercontent.com/gesellkammer/csoundengine/master/docs/assets/synthui.png
.. code-block:: python
from csoundengine import *
# Create an Engine and a corresponding Session using default options
session = Engine().session()
# create a master audio bus
masterbus = session.assignBus()
# define instruments
session.defInstr("synth", r'''
|ibus, kmidi=60, kamp=0.1, ktransp=0, ifade=0.5|
; a simple sawtooth
asig vco2 kamp, mtof:k(kmidi+ktransp)
asig *= linsegr:a(0, ifade, 1, ifade, 0)
; output is routed to a bus
busout(ibus, asig)
''')
session.defInstr("filter", r'''
|ibus, imasterbus, kcutoff=1000, kresonance=0.9|
asig = busin(ibus)
asig = moogladder2(asig, kcutoff, kresonance)
busmix(imasterbus, asig)
''')
session.defInstr("master", r'''
imasterbus = p4
asig = busin(imasterbus)
asig compress2 asig, asig, -120, -40, -12, 3, 0.1, 0.01, 0.05
outch 1, asig
''')
# Start a master instance at the end of the evaluation chain
master = session.sched("master", imasterbus=masterbus, priority=10)
# Launch some notes
for i, midinote in enumerate(range(60, 72, 2)):
# for each synth, we create a bus to plug it to an effect, in this case a filter
# The bus will be collected once all clients are finished
bus = session.assignBus()
# start time for synth and effect
start = i * 1
# Schedule a synth
synth = session.sched("synth", delay=start, dur=5, kmidi=midinote, ibus=bus)
# Automate pitch transposition so that it descends 2 semitones over the
# duration of the event
synth.automatep('ktransp', [0, 0, dur, -2], delay=start)
# Schedule the filter for this synth, with a priority higher than the
# synth, so that it is evaluated later in the chain
filt = session.sched("filter",
delay=start,
dur=synth.dur,
priority=synth.priority+1,
kcutoff=2000,
kresonance=0.92,
ibus=bus,
imasterbus=masterbus)
# Automate the cutoff freq. of the filter
filt.automatep('kcutoff', [0, 2000, dur*0.8, 500, dur, 6000], delay=start)
-----
Installation
------------
https://csoundengine.readthedocs.io/en/latest/Installation.html
Dependencies
~~~~~~~~~~~~
* python >= 3.9
* csound 6 >= 6.16 (https://github.com/csound/csound/releases).
.. code-block:: bash
pip install csoundengine
**csoundengine** also needs many csound plugins (https://github.com/csound-plugins/csound-plugins/releases),
but these are installed automatically if needed.
Documentation
-------------
https://csoundengine.readthedocs.io
----------------
Usage in other projects
-----------------------
* **csoundengine** is used as the audio engine in `maelzel <https://github.com/gesellkammer/maelzel>`_
Raw data
{
"_id": null,
"home_page": "https://github.com/gesellkammer/csoundengine",
"name": "csoundengine",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Eduardo Moguillansky",
"author_email": "eduardo.moguillansky@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/78/b5/43f9a2c473d06a3ce42ec8a0940b782b2184814fb25a21de5cca584ccd38/csoundengine-2.8.5.tar.gz",
"platform": null,
"description": "csoundengine\n============\n\n|sh-month|\n\n.. |sh-month| image:: https://static.pepy.tech/badge/csoundengine/month\n\n\nThis package implements an intuitive interface to run and control a csound process\n\n\nDocumentation\n-------------\n\nhttps://csoundengine.readthedocs.io/en/latest/index.html\n\n\n-----\n\n\nIntroduction \n------------\n\nThe core of this package is the ``Engine`` class, which wraps a csound\nprocess and allows transparent control over all parameters, while providing \nsane defaults. It uses the csound API to communicate with a running csound\ninstance. All audio processing is run in a separate performance thread.\n\n\n.. code-block:: python\n\n from csoundengine import *\n # create an Engine with default options for the platform.\n engine = Engine()\n \n # Define an instrument\n engine.compile(r'''\n instr synth\n ; pfields of the instrument\n kmidinote = p4\n kamp = p5\n kcutoff = p6\n kdetune = p7\n\n kfreq = mtof:k(kmidinote)\n ; A filtered sawtooth\n asig = vco2:a(kamp*0.7, kfreq)\n asig += vco2:a(kamp*0.7, kfreq + kdetune)\n asig = moogladder2(asig, kcutoff, 0.9)\n ; Attack / Release\n aenv = linsegr:a(0, 0.01, 1, 0.2, 0)\n asig *= aenv\n outs asig, asig\n endin\n ''')\n\n # Start a synth with indefinite duration. This returns the eventid (p1)\n # of the running instrument, which can be used to further control it\n event = engine.sched(\"synth\", args=[48, 0.2, 3000, 4])\n\n # Change midinote. setp means: set p-field. This sets kmidinote (p4) to 50\n engine.setp(event, 4, 50)\n\n # Modify cutoff\n engine.setp(event, 6, 1000, delay=4)\n\n # Create a graphic interface to interact with this event. If running within a jupyter notebook\n # a html gui is generated, otherwise a native gui is used:\n engine.eventUI(event, p4=(0, 127), p5=(0, 1), kcutoff=(100, 5000))\n\n\n.. figure:: https://raw.githubusercontent.com/gesellkammer/csoundengine/master/docs/assets/eventui2.png\n\n\n\nSession - high level interface\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nEach engine can have an associated ``Session``. A Session provides a\nhigher level interface, allowing to:\n\n* Define instrument templates (an ``Instr``), which can be instantiated at any order of evaluation, allowing to implement processing chains of any complexity\n\n* An ``Instr`` can have named parameters which can be used to control the event.\n\n* A ``Session`` provides a series of built-in ``Instr``'s to perform some common tasks, like playing samples from memory or from disk, perform audio analysis, etc.\n\n\n.. figure:: https://raw.githubusercontent.com/gesellkammer/csoundengine/master/docs/assets/synthui.png\n\n\n.. code-block:: python\n \n from csoundengine import *\n\n # Create an Engine and a corresponding Session using default options\n session = Engine().session()\n\n # create a master audio bus\n masterbus = session.assignBus()\n\n # define instruments\n session.defInstr(\"synth\", r'''\n |ibus, kmidi=60, kamp=0.1, ktransp=0, ifade=0.5|\n ; a simple sawtooth\n asig vco2 kamp, mtof:k(kmidi+ktransp)\n asig *= linsegr:a(0, ifade, 1, ifade, 0)\n ; output is routed to a bus\n busout(ibus, asig)\n ''')\n\n session.defInstr(\"filter\", r'''\n |ibus, imasterbus, kcutoff=1000, kresonance=0.9|\n asig = busin(ibus)\n asig = moogladder2(asig, kcutoff, kresonance)\n busmix(imasterbus, asig)\n ''')\n\n session.defInstr(\"master\", r'''\n imasterbus = p4\n asig = busin(imasterbus)\n asig compress2 asig, asig, -120, -40, -12, 3, 0.1, 0.01, 0.05\n outch 1, asig\n ''')\n\n # Start a master instance at the end of the evaluation chain\n master = session.sched(\"master\", imasterbus=masterbus, priority=10)\n\n # Launch some notes\n for i, midinote in enumerate(range(60, 72, 2)):\n # for each synth, we create a bus to plug it to an effect, in this case a filter\n # The bus will be collected once all clients are finished\n bus = session.assignBus()\n \n # start time for synth and effect\n start = i * 1\n \n # Schedule a synth\n synth = session.sched(\"synth\", delay=start, dur=5, kmidi=midinote, ibus=bus)\n \n # Automate pitch transposition so that it descends 2 semitones over the\n # duration of the event\n synth.automatep('ktransp', [0, 0, dur, -2], delay=start)\n \n # Schedule the filter for this synth, with a priority higher than the\n # synth, so that it is evaluated later in the chain\n filt = session.sched(\"filter\", \n delay=start, \n dur=synth.dur, \n priority=synth.priority+1,\n kcutoff=2000, \n kresonance=0.92, \n ibus=bus, \n imasterbus=masterbus)\n \n # Automate the cutoff freq. of the filter\n filt.automatep('kcutoff', [0, 2000, dur*0.8, 500, dur, 6000], delay=start) \n\n\n-----\n\nInstallation\n------------\n\nhttps://csoundengine.readthedocs.io/en/latest/Installation.html\n\nDependencies\n~~~~~~~~~~~~\n\n* python >= 3.9\n* csound 6 >= 6.16 (https://github.com/csound/csound/releases). \n\n.. code-block:: bash\n\n pip install csoundengine\n\n**csoundengine** also needs many csound plugins (https://github.com/csound-plugins/csound-plugins/releases),\nbut these are installed automatically if needed.\n\n\nDocumentation\n-------------\n\nhttps://csoundengine.readthedocs.io\n\n----------------\n\n\nUsage in other projects\n-----------------------\n\n* **csoundengine** is used as the audio engine in `maelzel <https://github.com/gesellkammer/maelzel>`_\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "A synthesis framework using csound",
"version": "2.8.5",
"project_urls": {
"Homepage": "https://github.com/gesellkammer/csoundengine"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0e1b3ee61db4e4399ad1509c13559d8f239fe1c0bfb69adcca87590e805e2c11",
"md5": "b470e2dfdbb6480903c29fa4fcd15049",
"sha256": "5851d78961845f867996639191c311264b2ef3b2ec5314a0c5fcd3a828db00f6"
},
"downloads": -1,
"filename": "csoundengine-2.8.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b470e2dfdbb6480903c29fa4fcd15049",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 1631737,
"upload_time": "2024-05-01T16:05:49",
"upload_time_iso_8601": "2024-05-01T16:05:49.710065Z",
"url": "https://files.pythonhosted.org/packages/0e/1b/3ee61db4e4399ad1509c13559d8f239fe1c0bfb69adcca87590e805e2c11/csoundengine-2.8.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "78b543f9a2c473d06a3ce42ec8a0940b782b2184814fb25a21de5cca584ccd38",
"md5": "306c6af63580d108e8f65a26a98a7c06",
"sha256": "0d3932e70bfdbfa41c2e7c4ad07f7dc2d5eaac1a9a16a64731ef0227fd3d437e"
},
"downloads": -1,
"filename": "csoundengine-2.8.5.tar.gz",
"has_sig": false,
"md5_digest": "306c6af63580d108e8f65a26a98a7c06",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 1592469,
"upload_time": "2024-05-01T16:07:17",
"upload_time_iso_8601": "2024-05-01T16:07:17.169457Z",
"url": "https://files.pythonhosted.org/packages/78/b5/43f9a2c473d06a3ce42ec8a0940b782b2184814fb25a21de5cca584ccd38/csoundengine-2.8.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-01 16:07:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gesellkammer",
"github_project": "csoundengine",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "csoundengine"
}