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
Metadata
Release files for libcsound 0.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| libcsound-0.16.0.tar.gz | 1.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| libcsound-0.16.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.5 MB
Release files / libcsound-0.16.0.tar.gz
| Download URL | libcsound-0.16.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e6362419d57bcc81a76d20209715347ba2f9ecbf2184bc380fa61ec9d2265db
|
|
BLAKE2b-256 checksum How to use checksums |
8c1fae2b955271029c34b7eee7d3cdea01b4ceeaaf6c1b308dddc7569771658a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / libcsound-0.16.0-py3-none-any.whl
| Download URL | libcsound-0.16.0-py3-none-any.whl |
|---|---|
| Size | 186.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a5405687384f0348ef38d3af5b3d66d008390cf0817bd3b90be899be1eca17d
|
|
BLAKE2b-256 checksum How to use checksums |
01cd95f211764bc6d086605b70be56e3474d35341242f805d13bf66a45c50d68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|