Python bindings to the Csound API, supporting all versions of csound higher or equal to 6.18, including csound 7
Project description
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
Project details
Release history Release notifications | RSS feed
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.12.0.tar.gz
(1.3 MB
view details)
File details
Details for the file libcsound-0.12.0.tar.gz.
File metadata
- Download URL: libcsound-0.12.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8b4ebcbe469117bcb14f0488f6aac17634dfa7f8a5456971a2926df2866899
|
|
| MD5 |
99447f5e19f8c56f582ee65d0ccbb2c9
|
|
| BLAKE2b-256 |
58457ed8cc87a66040e205c878760dd4b85a1b02ceabeea1a17f51fe34abfba9
|