CLAM-Development  1.4.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
CLAM::MIDI2Melody Class Reference

This processing is a particular control-to-data converter that takes in MIDI control events and converts them into a MIDIMelody processing data. More...

#include <MIDI2Melody.hxx>

List of all members.

Public Member Functions

 MIDI2Melody ()
virtual ~MIDI2Melody ()
- Public Member Functions inherited from CLAM::Control2Data
 Control2Data (const Config &c=Config())
virtual ~Control2Data ()
bool Do ()
 Already implemented Do operation.
const ProcessingConfigGetConfig () const
 Returns internal configuration method.
- Public Member Functions inherited from CLAM::Processing
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)
InPortBaseGetInPort (const std::string &name)
OutPortBaseGetOutPort (const std::string &name)
InControlBaseGetInControl (const std::string &name)
OutControlBaseGetOutControl (const std::string &name)
InPortBaseGetInPort (unsigned index)
OutPortBaseGetOutPort (unsigned index)
InControlBaseGetInControl (unsigned index)
OutControlBaseGetOutControl (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.

Public Attributes

OutPort< MIDIMelodymOutput
 Concrete output port of type MIDIMelody.
FloatInControl mTime
 Special input control for keeping trace of the time.

Protected Member Functions

bool GenerateOutputData (int id, TControlData val)
 Particular implementation of this operation to generate data from enqueued controls.
bool ConcreteConfigure (const ProcessingConfig &c)
 Concrete configuration, we hardcode the number of controls to use and pass it to the configuration of the base Control2Data configuration method.
int FindNote (int key)
 Finds the given note (according to key number) in internal container.
void AddNote (int key, int velocity, int time)
 Adds a note to internal container.
void DeleteNote (int key)
 Deletes note from internal container using MIDI key.
void DeleteNoteFromIndex (int index)
 Deletes note in given position in internal container.
void ModifyVelocity (int key, int newVelocity)
 Modifies midi velocity for given midi note.
- Protected Member Functions inherited from CLAM::Control2Data
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.
const char * GetClassName () const
 Compulsory method for Processing derived classes.
- Protected Member Functions inherited from CLAM::Processing
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.
InControlRegistryGetInControls ()
 Accessor to published Controls manager.
OutControlRegistryGetOutControls ()
 Accessor to published Controls manager.
InPortRegistryGetInPorts ()
 Accessor to published Ports manager.
OutPortRegistryGetOutPorts ()
 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

Array< intmKeys
 Contains an array of midi keys active at a given moment.
Array< intmVelocities
 Array of Midi velocities corresponding to the active midi notes.
Array< intmBeginTimes
 Array of begin times in milliseconds corresponding to the active midi notes.
int mLastKey
 Last key added to internal container.
- Protected Attributes inherited from CLAM::Control2Data
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< TQueuemDataQueues
 Vector of queues containing events for each control.
Mutex mDataMutex
 Mutex object for ensuring multithread capabilities.
Mutex mControl2DataDoMutex
 Mutex object for ensuring multithread capabilities.
- Protected Attributes inherited from CLAM::Processing
ProcessingCompositempParent
 Pointer to the parent (composite) processing object, or 0.
Network_network
 The parent network if any.

Additional Inherited Members

- Public Types inherited from CLAM::Control2Data
typedef Control2DataConfig Config
- Public Types inherited from CLAM::Processing
enum  ExecState { Unconfigured = 0, Ready, Running }
 Processing Object possible execution states. More...
- Protected Types inherited from CLAM::Control2Data
typedef std::queue< TControlDataTQueue
 typedef used for convenience
typedef std::list< intIdxList
 typedef used for convenience

Detailed Description

This processing is a particular control-to-data converter that takes in MIDI control events and converts them into a MIDIMelody processing data.

See also:
: Control2Data

Definition at line 37 of file MIDI2Melody.hxx.


Constructor & Destructor Documentation

CLAM::MIDI2Melody::MIDI2Melody ( )

Definition at line 26 of file MIDI2Melody.cxx.

References ConcreteConfigure().

virtual CLAM::MIDI2Melody::~MIDI2Melody ( )
inlinevirtual

Definition at line 41 of file MIDI2Melody.hxx.


Member Function Documentation

void CLAM::MIDI2Melody::AddNote ( int  key,
int  velocity,
int  time 
)
protected

Adds a note to internal container.

Parameters:
keynote (MIDI key)
velocityis MIDI velocity
timeis time in milliseconds

Definition at line 114 of file MIDI2Melody.cxx.

References CLAM::Array< T >::AddElem(), mBeginTimes, mKeys, and mVelocities.

Referenced by GenerateOutputData().

bool CLAM::MIDI2Melody::ConcreteConfigure ( const ProcessingConfig c)
protectedvirtual

Concrete configuration, we hardcode the number of controls to use and pass it to the configuration of the base Control2Data configuration method.

See also:
Control2Data::ConcreteConfigure

Reimplemented from CLAM::Control2Data.

Definition at line 90 of file MIDI2Melody.cxx.

Referenced by MIDI2Melody().

void CLAM::MIDI2Melody::DeleteNote ( int  key)
protected

Deletes note from internal container using MIDI key.

Definition at line 121 of file MIDI2Melody.cxx.

References DeleteNoteFromIndex(), and FindNote().

void CLAM::MIDI2Melody::DeleteNoteFromIndex ( int  index)
protected

Deletes note in given position in internal container.

Definition at line 126 of file MIDI2Melody.cxx.

References CLAM::Array< T >::DeleteElem(), mBeginTimes, mKeys, and mVelocities.

Referenced by DeleteNote(), and GenerateOutputData().

int CLAM::MIDI2Melody::FindNote ( int  key)
protected

Finds the given note (according to key number) in internal container.

Returns:
the index of the given note in internal container

Definition at line 100 of file MIDI2Melody.cxx.

References mKeys, and CLAM::Array< T >::Size().

Referenced by DeleteNote(), GenerateOutputData(), and ModifyVelocity().

bool CLAM::MIDI2Melody::GenerateOutputData ( int  id,
TControlData  val 
)
protectedvirtual
void CLAM::MIDI2Melody::ModifyVelocity ( int  key,
int  newVelocity 
)
protected

Modifies midi velocity for given midi note.

Definition at line 133 of file MIDI2Melody.cxx.

References FindNote(), and mVelocities.

Referenced by GenerateOutputData().


Member Data Documentation

Array<int> CLAM::MIDI2Melody::mBeginTimes
protected

Array of begin times in milliseconds corresponding to the active midi notes.

Definition at line 80 of file MIDI2Melody.hxx.

Referenced by AddNote(), DeleteNoteFromIndex(), and GenerateOutputData().

Array<int> CLAM::MIDI2Melody::mKeys
protected

Contains an array of midi keys active at a given moment.

Definition at line 76 of file MIDI2Melody.hxx.

Referenced by AddNote(), DeleteNoteFromIndex(), and FindNote().

int CLAM::MIDI2Melody::mLastKey
protected

Last key added to internal container.

Definition at line 82 of file MIDI2Melody.hxx.

Referenced by GenerateOutputData().

OutPort<MIDIMelody> CLAM::MIDI2Melody::mOutput

Concrete output port of type MIDIMelody.

Definition at line 41 of file MIDI2Melody.hxx.

Referenced by GenerateOutputData().

FloatInControl CLAM::MIDI2Melody::mTime

Special input control for keeping trace of the time.

Definition at line 46 of file MIDI2Melody.hxx.

Referenced by GenerateOutputData().

Array<int> CLAM::MIDI2Melody::mVelocities
protected

Array of Midi velocities corresponding to the active midi notes.

Definition at line 78 of file MIDI2Melody.hxx.

Referenced by AddNote(), DeleteNoteFromIndex(), GenerateOutputData(), and ModifyVelocity().


The documentation for this class was generated from the following files: