Python bindings for Csound (fork of ctcsound)
These bindings can be used with any version of csound >= 6.18. Csound 7 is explicitely supported.
Installation
Csound needs to be installed in the system.
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.14.0.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.14.0-py3-none-any.whl
(181.4 kB
view details)
File details
Details for the file libcsound-0.14.0.tar.gz.
File metadata
- Download URL: libcsound-0.14.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f44366e4d5f08ab8e0acd0cdc5be7638e28fa85f4feed0565020ca913e66800a
|
|
| MD5 |
024d46073adf12be556b1af284b7b8c7
|
|
| BLAKE2b-256 |
e0c9030b5b7ec4d530c7eb6ec5c38645483979da3f4bc791b3aacc82b4fd3dcd
|
File details
Details for the file libcsound-0.14.0-py3-none-any.whl.
File metadata
- Download URL: libcsound-0.14.0-py3-none-any.whl
- Upload date:
- Size: 181.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4761e7476c5c604b70b16115f43531b054707fd98bf75fcda50d1545d7a32560
|
|
| MD5 |
a9793174100485db26aed6ea2b33ea93
|
|
| BLAKE2b-256 |
73d3ea3025f87826b519cbada3607f30405203735276b4e84f123a06f6f2f714
|