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.0.tar.gz (91.8 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.0-py3-none-any.whl (80.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ctcsound7-0.7.0.tar.gz
  • Upload date:
  • Size: 91.8 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.0.tar.gz
Algorithm Hash digest
SHA256 755511b23eac0da8da2c2b2dee09f3b5c35973eca4276330265524815b981e45
MD5 a37cc5af070795ed25bf7ea8e08d9885
BLAKE2b-256 d3fe630b364a53e22360071791196f23c5dc6e8f099a5a55633778494be6b382

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ctcsound7-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 80.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 336200e79f4a0ccfbefb0ac7d7d982097abda20bbadfe5ac575ffdd81ed0f95a
MD5 18447f34c8dbe9b62a36490c3b466a92
BLAKE2b-256 9830d358244b898016521f2e4edab46d1875b889936924a6d41ba1857cddeb33

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