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.1.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.1-py3-none-any.whl (80.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ctcsound7-0.7.1.tar.gz
  • Upload date:
  • Size: 91.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for ctcsound7-0.7.1.tar.gz
Algorithm Hash digest
SHA256 d94f239fa3fe92d0857411ffb2b1a1837aec17c72d23f7e92170fc8c0784f020
MD5 699ab32790b5c80beb68cefeaaebdb1a
BLAKE2b-256 d82f00f6f9d416af4460067656f59d29f925735a6fc8642774f6eee1397af250

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ctcsound7-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 80.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for ctcsound7-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 facbac7556b6938c71351bb0a87bf9fd73465b646a08c8a26b73e4abfafe10cb
MD5 7d474a8dbc8d95ea1733007bb001ec76
BLAKE2b-256 6dffd0123974efb3417473b0ebcc6eff8d3f12ead498acb3d178ce04e346b5d6

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