CLAM-Development
1.4.0
|
This processing object is mainly an aggregate of input control data It works by asynchronously receiving messages, keeping them enqueued and synchronously converting them to a Processing Data, at Do() time. More...
#include <Control2Data.hxx>
Public Types | |
typedef Control2DataConfig | Config |
![]() | |
enum | ExecState { Unconfigured = 0, Ready, Running } |
Processing Object possible execution states. More... |
Public Member Functions | |
Control2Data (const Config &c=Config()) | |
virtual | ~Control2Data () |
bool | Do () |
Already implemented Do operation. | |
const ProcessingConfig & | GetConfig () const |
Returns internal configuration method. | |
![]() | |
bool | Configure (const ProcessingConfig &config) |
Configuration change method. | |
void | Start (void) |
Method to turn the object into running state. | |
void | Stop (void) |
Method to put the object out of running state When in execution mode, this method must be called before any further call to Configure() methods. | |
Processing () | |
virtual | ~Processing () |
virtual bool | CanProcessInplace () |
Override this method if your processing cannot process inplace. | |
bool | CanConsumeAndProduce () |
Check that Supervised Do() can be safely called. | |
void | ConsumeAndProduce () |
Acknoledges data tokens in published ports as read/writen by calling Produce() for all registered OutPorts and Consume() to all registered InPorts. | |
std::string | GetExecStateString () const |
bool | IsConfigured () const |
bool | IsRunning () const |
void | RegisterOutPort (OutPortBase *out) |
void | RegisterInPort (InPortBase *in) |
void | RegisterOutControl (OutControlBase *out) |
void | RegisterInControl (InControlBase *in) |
void | SetParent (Processing *p) |
void | SetNetworkBackLink (Network *network) |
virtual bool | ModifiesPortsAndControlsAtConfiguration () |
This method is used to determine if a given processing can change its interface of ports/controls after its construction (i.e. | |
bool | HasInPort (const std::string &name) |
bool | HasOutPort (const std::string &name) |
bool | HasInControl (const std::string &name) |
bool | HasOutControl (const std::string &name) |
InPortBase & | GetInPort (const std::string &name) |
OutPortBase & | GetOutPort (const std::string &name) |
InControlBase & | GetInControl (const std::string &name) |
OutControlBase & | GetOutControl (const std::string &name) |
InPortBase & | GetInPort (unsigned index) |
OutPortBase & | GetOutPort (unsigned index) |
InControlBase & | GetInControl (unsigned index) |
OutControlBase & | GetOutControl (unsigned index) |
unsigned | GetNInPorts () const |
unsigned | GetNOutPorts () const |
unsigned | GetNInControls () const |
unsigned | GetNOutControls () const |
const std::string & | GetConfigErrorMessage () const |
Returns a string describing configuration errors if any. | |
virtual bool | IsSyncSource () const |
Wether the processing is a sync source such as audio i/o device, or an audio callback hook (i.e. | |
virtual bool | SupportsVariableAudioSize () const |
This method reports whether the processing supports dynamic buffer-size host. |
Protected Types | |
typedef std::queue< TControlData > | TQueue |
typedef used for convenience | |
typedef std::list< int > | IdxList |
typedef used for convenience |
Protected Member Functions | |
virtual bool | GenerateOutputData (int id, TControlData val)=0 |
This pure virtual operation should be implemented in the derived classes. | |
void | BufferQueueInit (int ncontrols) |
Initialization for queues of control events. | |
void | EnqueueControl (unsigned id, TControlData data) |
Add new control event to internal queue. | |
TControlData | PopControl (unsigned id) |
Read and remove last control event for a given control id. | |
bool | Empty (unsigned id) |
Whether the queue for a particular event is empty or not. | |
IdxList | GetQueues () |
Returns list of controls that are being enqueued. | |
void | ControlCallbackId (int id, TControlData val) |
Callback that will be called when a particular control receives an event and that will be in charge of enqueing the event. | |
virtual bool | ConcreteConfigure (const ProcessingConfig &) |
Concrete configuration for particular Processing. | |
const char * | GetClassName () const |
Compulsory method for Processing derived classes. | |
![]() | |
virtual bool | ConcreteStart () |
Processing objects have to redefine this method when starting them implies some internal changes. | |
virtual bool | ConcreteStop () |
Processing objects have to redefine this method when stoping them implies some internal changes. | |
unsigned | BackendBufferSize () |
Given by the NetworkPlayer (backend) if exists. | |
unsigned | BackendSampleRate () |
Given by the NetworkPlayer (backend) if exists. | |
InControlRegistry & | GetInControls () |
Accessor to published Controls manager. | |
OutControlRegistry & | GetOutControls () |
Accessor to published Controls manager. | |
InPortRegistry & | GetInPorts () |
Accessor to published Ports manager. | |
OutPortRegistry & | GetOutPorts () |
Accessor to published Portss manager. | |
bool | AddConfigErrorMessage (const std::string &msg) |
Use this method to append a configuration errors to the processing when implementing ConcreteConfigure. | |
bool | AbleToExecute (void) const |
In debug-mode checks that the processing is configured and started. | |
template<typename ConcreteConfig > | |
void | CopyAsConcreteConfig (ConcreteConfig &concrete, const ProcessingConfig &abstract) const |
Helper template to convert a reference to a ProcessingConfig to the concrete ProcessingConfig specified on the first parameter. | |
void | SetExecState (ExecState state) |
Protected Attributes | |
InControlArray | mInArray |
Array of input control arrays that is initialized in the ConcreteConfigure method. | |
FloatInControl | mStop |
Special input control to be able to stop the process in response to an external control event. | |
Config | mConfig |
Internal configuration. | |
std::vector< TQueue > | mDataQueues |
Vector of queues containing events for each control. | |
Mutex | mDataMutex |
Mutex object for ensuring multithread capabilities. | |
Mutex | mControl2DataDoMutex |
Mutex object for ensuring multithread capabilities. | |
![]() | |
ProcessingComposite * | mpParent |
Pointer to the parent (composite) processing object, or 0. | |
Network * | _network |
The parent network if any. |
This processing object is mainly an aggregate of input control data It works by asynchronously receiving messages, keeping them enqueued and synchronously converting them to a Processing Data, at Do() time.
It is an abstract class because the responsability for the concrete processing of controls and conversion to a particular processing data is deferred to subclasses.
Note that if mulithreading is enabled, the EnqueueControl calls can be done from different threads than the execution method. A lock for the mDataQueue structure ensures it.
Definition at line 65 of file Control2Data.hxx.
Reimplemented from CLAM::Processing.
Definition at line 68 of file Control2Data.hxx.
|
protected |
typedef used for convenience
Definition at line 85 of file Control2Data.hxx.
|
protected |
typedef used for convenience
Definition at line 83 of file Control2Data.hxx.
Definition at line 33 of file Control2Data.cxx.
References CLAM::Processing::Configure().
|
inlinevirtual |
Definition at line 70 of file Control2Data.hxx.
|
protected |
Initialization for queues of control events.
ncontrols | is the number of controls that the converter has. |
Definition at line 73 of file Control2Data.cxx.
References mDataMutex, and mDataQueues.
Referenced by ConcreteConfigure().
|
protectedvirtual |
Concrete configuration for particular Processing.
Reimplemented from CLAM::Processing.
Reimplemented in CLAM::MIDI2Melody.
Definition at line 39 of file Control2Data.cxx.
References BufferQueueInit(), CLAM::Processing::CopyAsConcreteConfig(), CLAM::InControl< ControlDataType >::DoControl(), EnqueueControl(), mConfig, mInArray, mStop, and CLAM::ControlArray< ControlT >::Resize().
|
protected |
Callback that will be called when a particular control receives an event and that will be in charge of enqueing the event.
id | is the identifier of the control |
val | is the value of the control event |
Definition at line 145 of file Control2Data.cxx.
References EnqueueControl().
|
virtual |
Already implemented Do operation.
This operation is in charge of reading the enqueued events and producing the processing data output. But for doing so it relies on the particular implementation of the GenerateOutputData operation.
Implements CLAM::Processing.
Definition at line 56 of file Control2Data.cxx.
References GenerateOutputData(), CLAM::InControl< ControlDataType >::GetLastValue(), GetQueues(), mControl2DataDoMutex, mStop, and PopControl().
|
protected |
Whether the queue for a particular event is empty or not.
Definition at line 121 of file Control2Data.cxx.
References mDataMutex, and mDataQueues.
|
protected |
Add new control event to internal queue.
id | is the identifier of the control to which the event is sent |
data | is teh value of the event |
Definition at line 92 of file Control2Data.cxx.
References mDataMutex, and mDataQueues.
Referenced by ConcreteConfigure(), and ControlCallbackId().
|
protectedpure virtual |
This pure virtual operation should be implemented in the derived classes.
It is responsible for implementing the concrete behaviour of how to covert the controls into a particular processing data
Implemented in CLAM::MIDI2Melody.
Referenced by Do().
|
inlineprotectedvirtual |
Compulsory method for Processing derived classes.
Implements CLAM::Processing.
Definition at line 121 of file Control2Data.hxx.
|
virtual |
Returns internal configuration method.
Reimplemented from CLAM::Processing.
Definition at line 86 of file Control2Data.cxx.
References mConfig.
|
protected |
Returns list of controls that are being enqueued.
Definition at line 104 of file Control2Data.cxx.
References mDataQueues.
Referenced by Do().
|
protected |
Read and remove last control event for a given control id.
Definition at line 133 of file Control2Data.cxx.
References mDataMutex, and mDataQueues.
Referenced by Do().
|
protected |
Internal configuration.
Definition at line 137 of file Control2Data.hxx.
Referenced by ConcreteConfigure(), and GetConfig().
|
protected |
Mutex object for ensuring multithread capabilities.
Definition at line 145 of file Control2Data.hxx.
Referenced by Do().
|
protected |
Mutex object for ensuring multithread capabilities.
Definition at line 143 of file Control2Data.hxx.
Referenced by BufferQueueInit(), Empty(), EnqueueControl(), and PopControl().
|
protected |
Vector of queues containing events for each control.
Definition at line 140 of file Control2Data.hxx.
Referenced by BufferQueueInit(), Empty(), EnqueueControl(), GetQueues(), and PopControl().
|
protected |
Array of input control arrays that is initialized in the ConcreteConfigure method.
Number of controls is indicated in the configuration
Definition at line 129 of file Control2Data.hxx.
Referenced by ConcreteConfigure().
|
protected |
Special input control to be able to stop the process in response to an external control event.
Definition at line 134 of file Control2Data.hxx.
Referenced by ConcreteConfigure(), and Do().