Python bindings for Csound (fork of ctcsound)
These bindings can be used with any version of csound >= 6.18. Csound 7 is explicitely supported and is the recommended version.
Installation
Csound
Csound needs to be installed in the system. See https://github.com/csound/csound/releases
In Linux / macOS:
curl -fsSL https://csound-plugins.github.io/installer/install.sh | bash
This installs the latest version of csound 7.
libcsound
pip install libcsound
Quick Start
Rendering in real-time using a render thread
import libcsound
csound = libcsound.Csound()
csound.setOption('-odac')
csound.compileOrc(r'''
sr = 44100 ; Modify to fit your system
ksmps = 64
nchnls = 2
0dbfs = 1
instr 1
kchan init -1
kchan = (kchan + metro:k(1)) % nchnls
if changed:k(kchan) == 1 then
println "Channel: %d", kchan + 1
endif
asig = pinker() * 0.2
outch kchan + 1, asig
endin
''')
csound.start()
thread = csound.performanceThread()
thread.play()
# Schedule an instance of instr 1 for 10 seconds
thread.scoreEvent(0, "i", [1, 0, 10])
input("Press any key to stop...\n")
thread.stop()
Render offline
import libcsound
csound = libcsound.Csound()
csound.setOption('-ooutfile.wav')
csound.compileOrc(r'''
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1
instr 1
kchan init -1
kchan = (kchan + metro:k(1)) % nchnls
if changed:k(kchan) == 1 then
println "Channel: %d", kchan + 1
endif
asig = pinker() * 0.2
outch kchan + 1, asig
endin
''')
csound.start()
csound.scoreEvent("i", [1, 0, 10])
csound.setEndMarker(10)
# Perform until the end of the score
while not csound.performKsmps():
pass
Documentation
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
libcsound-0.15.1.tar.gz
(1.3 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
libcsound-0.15.1-py3-none-any.whl
(184.0 kB
view details)
File details
Details for the file libcsound-0.15.1.tar.gz.
File metadata
- Download URL: libcsound-0.15.1.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9479741bf332726275c9ab7d6a2c8970247ae555ee6233bb71537b171851d035
|
|
| MD5 |
9d5fdd6ab35c9c2bd1e7bd6de2b4c21e
|
|
| BLAKE2b-256 |
886c43dca3995db4f187eb15aba9fed390c80d09b2e73f8ca737247f344b9d2c
|
File details
Details for the file libcsound-0.15.1-py3-none-any.whl.
File metadata
- Download URL: libcsound-0.15.1-py3-none-any.whl
- Upload date:
- Size: 184.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc511a26a9cbe651e3a622e211426ce018cd8f344b48ef25daef9ceed7faff8e
|
|
| MD5 |
10e17089aa94fb9d80a681ff906465e3
|
|
| BLAKE2b-256 |
11cc5e231ccfd91285ef1dbceed2a7c457dfa34a7d770b01cf4dcef944a88553
|