Available bindings
Csound offers official bindings for multiple languages:- C API - The core C API that all other bindings wrap
- C++ - Object-oriented C++ interface with RAII semantics
- Python - ctcsound Python bindings using ctypes
- JavaScript - WebAssembly bindings for browser and Node.js
- Java - JNI-based Java bindings
Architecture
All language bindings wrap the core C API defined incsound.h. The typical architecture is:
Common operations
All bindings support these core operations:Instantiation
Creating and destroying Csound instances:- C
- C++
- Python
- JavaScript
Compilation and performance
Compiling Csound code and running performance:- C
- C++
- Python
- JavaScript
Channel communication
Sending and receiving values via software channels:- C
- C++
- Python
- JavaScript
Return values and error handling
Most Csound API functions return status codes:CSOUND_SUCCESS(0) - Operation completed successfullyCSOUND_ERROR(-1) - Unspecified failureCSOUND_INITIALIZATION(-2) - Failed during initializationCSOUND_PERFORMANCE(-3) - Failed during performanceCSOUND_MEMORY(-4) - Failed to allocate requested memoryCSOUND_SIGNAL(-5) - Termination requested by signal
Thread safety
The Csound API is generally not thread-safe except for specific functions documented as thread-safe. When using Csound in multi-threaded applications:- Use separate Csound instances for different threads
- Use the circular buffer API for thread-safe audio data exchange
- Consider using
CsoundPerformanceThread(C++) for threaded performance
Performance considerations
Buffer sizes
Set appropriate buffer sizes for your use case:Sample rate and ksmps
Configure audio settings before compilation:Next steps
C API
Explore the core C API reference
C++ bindings
Learn about the C++ object-oriented interface
Python bindings
Use Csound from Python with ctcsound
JavaScript bindings
Run Csound in the browser or Node.js