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.7.2.tar.gz (91.7 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.7.2-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ctcsound7-0.7.2.tar.gz
Algorithm Hash digest
SHA256 a90afeb1389632af77d3ec7f37b070e6f6c62307f6fc192a81b70db2fe0c4913
MD5 4388f66e73d39bd4dde1cafcc43c07c1
BLAKE2b-256 c2b228179a2c6d2c4b251a6e9c9d54c9e38dcddfdef3c35eb847be7bfdecac69

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ctcsound7-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a3ac6e4fb4b41bc3dc1096472133d1e6280cc9a12b1fa020380ba5ea4e567ec
MD5 03dabfcecfe50087a7a8f0eb936a630a
BLAKE2b-256 ee120ab443845413dade0b6f41d78c65ba83ff9e2968f8593ef0cd9afa5edf7a

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