Csound API
6.18
|
This class provides a multi-threaded C++ interface to the "C" Csound API. More...
#include <csound_threaded.hpp>
Public Member Functions | |
CsoundThreaded () | |
CsoundThreaded (CSOUND *csound_) | |
CsoundThreaded (void *host_data) | |
virtual | ~CsoundThreaded () |
virtual void | SetKperiodCallback (void(*kperiod_callback_)(CSOUND *, void *), void *kperiod_callback_user_data_) |
virtual int | PerformRoutine () |
virtual int | PerformAndResetRoutine () |
virtual int | Perform () |
Overrides Csound::Perform to run in a separate thread of execution. More... | |
virtual int | PerformAndReset () |
Like Perform, but calls Cleanup() and Reset() at the conclusion of the performance, so that this is done in the performance thread. More... | |
virtual int | ScoreEvent (char opcode, const MYFLT *pfields, long pfield_count) |
Enqueues a low-level score event with raw pfields for dispatch from the performance thread routine. More... | |
virtual void | InputMessage (const char *message) |
Enqueues a textual score event or events for dispatch from the performance thread routine. More... | |
virtual int | ReadScore (const char *score) |
Enqueues a textual score event, score fragment, or entire score for dispatch from the performance thread routine. More... | |
virtual void | Stop () |
Signals the performance thread routine to stop and return. More... | |
virtual void | Join () |
Causes the calling thread to wait for the end of the performance thread routine. More... | |
virtual bool | IsPlaying () const |
Returns whether or not the performance thread routine is running. More... | |
Protected Member Functions | |
void | ClearQueue () |
Protected Attributes | |
std::thread | performance_thread |
std::atomic< bool > | keep_running |
void(* | kperiod_callback )(CSOUND *, void *) |
void * | kperiod_callback_user_data |
concurrent_queue< CsoundEvent * > | input_queue |
This class provides a multi-threaded C++ interface to the "C" Csound API.
The interface is identical to the C++ interface of the Csound class in csound.hpp; however, the ::Perform() function runs in a separate thread of execution that is fed by a thread-safe FIFO of messages from ::ScoreEvent, ::InputMessage, and ::ReadScore.
This is a header-file-only facility. The multi-threaded features of this class are minimalistic, but seem sufficient for most purposes. There are no external dependences apart from Csound and the standard C++ library.
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
|
inlineprotected |
References concurrent_queue< Data >::try_pop().
|
inlinevirtual |
Enqueues a textual score event or events for dispatch from the performance thread routine.
References concurrent_queue< Data >::push().
|
inlinevirtual |
Returns whether or not the performance thread routine is running.
|
inlinevirtual |
Causes the calling thread to wait for the end of the performance thread routine.
|
inlinevirtual |
Overrides Csound::Perform to run in a separate thread of execution.
The granularity of time is one kperiod. If a kperiod callback has been set, it is called with the CSOUND object and any user data on every kperiod.
References PerformRoutine().
|
inlinevirtual |
Like Perform, but calls Cleanup() and Reset() at the conclusion of the performance, so that this is done in the performance thread.
References PerformAndResetRoutine().
|
inlinevirtual |
References concurrent_queue< Data >::try_pop().
Referenced by PerformAndReset().
|
inlinevirtual |
References concurrent_queue< Data >::try_pop().
Referenced by Perform().
|
inlinevirtual |
Enqueues a textual score event, score fragment, or entire score for dispatch from the performance thread routine.
References concurrent_queue< Data >::push().
|
inlinevirtual |
Enqueues a low-level score event with raw pfields for dispatch from the performance thread routine.
References concurrent_queue< Data >::push().
|
inlinevirtual |
|
inlinevirtual |
Signals the performance thread routine to stop and return.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |