Skip to main content

Python bindings for Csound

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 ctcsound7

Quick Start

Rendering in real-time using a render thread

import ctcsound7 as ct
csound = ct.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 ctcsound7 as ct
csound = ct.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

Release files for ctcsound7 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctcsound7 0.8.0
File Size Uploaded
ctcsound7-0.8.0.tar.gz 96.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ctcsound7 0.8.0
File Interpreter ABI Platform
ctcsound7-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 171.4 kB

Release files / ctcsound7-0.8.0.tar.gz

Download URL ctcsound7-0.8.0.tar.gz
Size 96.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b04a1f67e05a943084d169ff3a51581458cbf7fdc8445434c2e3992676e1bc04
BLAKE2b-256 checksum
How to use checksums
e2408043a80e40f87ee7a2d65de87c25c67681bfcb9e7a78192a34101a8244a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.7

Release files / ctcsound7-0.8.0-py3-none-any.whl

Download URL ctcsound7-0.8.0-py3-none-any.whl
Size 75.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a1300a8a044986d87232fbe06e3dc861f59b143b465e2a1b7445ec577544ad0
BLAKE2b-256 checksum
How to use checksums
37a985d6e2549de75e2c984f64d50c82eb869a0c708857d22cb3f7bd84fc6867
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.7

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

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