Skip to main content

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

https://libcsound.readthedocs.io/en/latest/

Project details


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.13.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libcsound-0.13.0-py3-none-any.whl (180.6 kB view details)

Uploaded Python 3

File details

Details for the file libcsound-0.13.0.tar.gz.

File metadata

  • Download URL: libcsound-0.13.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for libcsound-0.13.0.tar.gz
Algorithm Hash digest
SHA256 a27236c901c87a294c85d0cdd0e6f372858f886d42194d55ff966c5895f7c93d
MD5 4599856c1aa71fd4723e337a7c833e87
BLAKE2b-256 2865fad226fc667babbc1b078b8f0a999413bf0a485cf6e96d2f59c9149393b8

See more details on using hashes here.

File details

Details for the file libcsound-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: libcsound-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 180.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for libcsound-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b459c7c18e57ac709af8147db467880e6f8851dc17124184b161e650811cbcad
MD5 f7bdbfcbccbfa63f2e2ec24e3fe65185
BLAKE2b-256 13e6075f2bb3c9278fff4ceafcbee0af8ab05b91b3dea858d481e398aabbf2aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page