00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "Dispatcher.hxx"
00023
00024 using namespace CLAM;
00025
00026 bool Dispatcher::ConcreteConfigure( const ProcessingConfig& c )
00027 {
00028 CopyAsConcreteConfig(mConfig, c);
00029 int i,j,k;
00030
00031 mInstruments = mConfig.GetInstruments();
00032 mNInValues = mConfig.GetNInValues();
00033 mMInstruments = mInstruments.Size();
00034
00035 for( i = 0; i < mMInstruments; i++ )
00036 {
00037 mInstruments[ i ]->SetId(i);
00038 mInstruments[ i ]->LinkStateOutWithInControl( this, 0 ) ;
00039
00040 InstrStatus status = {-1,-1,i};
00041 mInstrStatusList.push_back(status);
00042 }
00043
00044 k = 0;
00045
00046 for ( i = 0; i < mMInstruments; i++ )
00047 {
00048 for ( j = 0; j < mNInValues;j++)
00049 {
00050 mValuesOut.AddElem( new OutControl("",this ) );
00051 GetOutControls().GetByNumber(k).AddLink(mInstruments[i]->GetInControls().GetByNumber(j+1));
00052
00053 k++;
00054 }
00055 }
00056
00057 return true;
00058 }
00059
00060 int Dispatcher::UpdateState( TControlData availableInstr )
00061 {
00062 std::list<InstrStatus>::iterator it;
00063 for (it=mInstrStatusList.begin();it!=mInstrStatusList.end();it++)
00064 {
00065 if ((*it).mId == availableInstr)
00066 {
00067 mInstrStatusList.erase(it);
00068 InstrStatus status = { -1,-1, int(availableInstr) };
00069 mInstrStatusList.push_front(status);
00070 return 0;
00071 }
00072 }
00073 return 0;
00074 }
00075
00076 void Dispatcher::Dispatch(void)
00077 {
00078 if( mVelocity == 0.0 )
00079 {
00080 std::list<InstrStatus>::iterator it;
00081
00082 for (it=mInstrStatusList.begin();it!=mInstrStatusList.end();it++)
00083 {
00084 if ( ( (*it).mNote == mNote ) && ( (*it).mVelocity ) )
00085 {
00086 InstrStatus status = (*it);
00087 (*it).mVelocity = 0;
00088 mValuesOut[ (*it).mId * mNInValues + 1]->SendControl( mVelocity );
00089 return;
00090 }
00091 }
00092 }
00093 else
00094 {
00095 InstrStatus status = mInstrStatusList.front();
00096 mInstrStatusList.pop_front();
00097 status.mNote = int(mNote);
00098 status.mVelocity = int(mVelocity);
00099 mInstrStatusList.push_back(status);
00100
00101 mValuesOut[ status.mId * mNInValues + 1 ]->SendControl( mVelocity );
00102 mValuesOut[ status.mId * mNInValues ]->SendControl( mNote );
00103 }
00104 }
00105
00106