Skip to main content

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

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

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.3.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.15.3-py3-none-any.whl (184.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: libcsound-0.15.3.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

Hashes for libcsound-0.15.3.tar.gz
Algorithm Hash digest
SHA256 e92f772c3280d78d9dd91d4697e5d2c87e7b3dac7c3a2b09f4e795636f27fdf9
MD5 4083d40c069a03067d59d9aa3526657f
BLAKE2b-256 7b49de915fc507f6957efc6737ce8b7211dd2276e88ae2cdb96ba3a0b446026a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libcsound-0.15.3-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

Hashes for libcsound-0.15.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b48ed932cc4d665b0b09e98b6928e65c6a26bb4cf2365d505cf28a240176d5e9
MD5 af231096d21d2a8ccc767a583bd74a99
BLAKE2b-256 e7e11357e4081bd6c15e25c2f139cd8d843f3f7f57011cfa21094cc695600982

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.15.3 This release

2 files

0.15.2

2 files

0.15.1

2 files

0.15.0

2 files

0.14.3

2 files

0.14.1

2 files

0.14.0

2 files

0.13.1

2 files

0.13.0

2 files

0.12.0

1 file

0.11.3

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.8

2 files

0.10.7

2 files

0.10.6

2 files

0.10.5

1 file

0.10.4

1 file

0.10.2

1 file

0.10.1

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page