class ctcsound.CsoundPerformanceThread(csp)

Performs a score in a separate thread until the end of score is reached.

The playback (which is paused by default) is stopped by calling stop(), or if an error occurs. The constructor takes a Csound instance pointer as argument; it assumes that Csound.compile_() was called successfully before creating the performance thread. Once the playback is stopped for one of the above mentioned reasons, the performance thread calls Csound.cleanup() and returns.


Returns the Csound instance pointer.


Waits until all pending messages are actually received.

(pause, send score event, etc.)


Sends a score event as a string, similarly to line events (-L).


Returns True if the performance thread is running, False otherwise.


Waits until the performance is finished or fails.

Returns a positive value if the end of score was reached or stop() was called, and a negative value if an error occured. Also releases any resources associated with the performance thread object.


Pauses performance (can be continued by calling play()).


Continues performance if it was paused.


Returns the process callback.

record(filename, samplebits, numbufs)

Starts recording the output from Csound.

The sample rate and number of channels are taken directly from the running Csound instance.

scoreEvent(absp2mode, opcod, pFields)

Sends a score event.

The event has type opcod (e.g. ‘i’ for a note event). pFields is tuple, a list, or an ndarray of MYFLTs with all the pfields for this event, starting with the p1 value specified in pFields[0]. If absp2mode is non-zero, the start time of the event is measured from the beginning of performance, instead of the default of relative to the current time.

setProcessCB(function, data)

Sets the process callback.


Sets the playback time pointer to the specified value (in seconds).


Returns the current status.

Zero if still playing, positive if the end of score was reached or performance was stopped, and negative if an error occured.


Stops performance (cannot be continued).


Stops recording and closes audio file.


Pauses or continues performance, depending on current state.