Skip to main content

Python bindings to the Csound API, supporting all versions of csound higher or equal to 6.18

Project description

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

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

ctcsound7-0.8.0.tar.gz (96.2 kB view details)

Uploaded Source

Built Distribution

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

ctcsound7-0.8.0-py3-none-any.whl (75.1 kB view details)

Uploaded Python 3

File details

Details for the file ctcsound7-0.8.0.tar.gz.

File metadata

  • Download URL: ctcsound7-0.8.0.tar.gz
  • Upload date:
  • Size: 96.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.7

File hashes

Hashes for ctcsound7-0.8.0.tar.gz
Algorithm Hash digest
SHA256 b04a1f67e05a943084d169ff3a51581458cbf7fdc8445434c2e3992676e1bc04
MD5 95d2ba6a2b280b3f456f83757e603227
BLAKE2b-256 e2408043a80e40f87ee7a2d65de87c25c67681bfcb9e7a78192a34101a8244a2

See more details on using hashes here.

File details

Details for the file ctcsound7-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: ctcsound7-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 75.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.7

File hashes

Hashes for ctcsound7-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a1300a8a044986d87232fbe06e3dc861f59b143b465e2a1b7445ec577544ad0
MD5 ee9caa60492e27462f94c634c3ca9009
BLAKE2b-256 37a985d6e2549de75e2c984f64d50c82eb869a0c708857d22cb3f7bd84fc6867

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