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.

csound()

Returns the Csound instance pointer.

flushMessageQueue()

Waits until all pending messages are actually received.

(pause, send score event, etc.)

inputMessage(s)

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

isRunning()

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

join()

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.

pause()

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

play()

Continues performance if it was paused.

processCB()

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.

setScoreOffsetSeconds(timeVal)

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

status()

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.

stop()

Stops performance (cannot be continued).

stopRecord()

Stops recording and closes audio file.

togglePause()

Pauses or continues performance, depending on current state.