Fund2MIDI.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "Fund2MIDI.hxx"
00021 #include "ProcessingFactory.hxx"
00022
00023 namespace CLAM
00024 {
00025 namespace Hidden
00026 {
00027 static const char * metadata[] = {
00028 "key", "Fund2MIDI",
00029 "category", "MIDI",
00030 "description", "Fund2MIDI",
00031 0
00032 };
00033 static FactoryRegistrator<ProcessingFactory, Fund2MIDI> reg = metadata;
00034 }
00035
00036 bool Fund2MIDI::Do( const Fundamental& inFund )
00037 {
00038 TControlData fund_note = Round( 69. + log(inFund.GetFreq(0)/440.)*17.31234 );
00039
00040
00041 if (fund_note > 127 || fund_note < 0 )
00042 {
00043 std::cout << "value clipped! - old fund_note: " << fund_note ;
00044 fund_note = CLAM_min( CLAM_max(fund_note,(TControlData)0), (TControlData)127 );
00045 std::cout << " - new fund_note: " << fund_note << std::endl;
00046 }
00047 CLAM_DEBUG_ASSERT( fund_note>=0 & fund_note<128, "Fundamental MIDI note should be betweeen 0..127");
00048
00049 mFreqControlOut.SendControl( fund_note );
00050
00051 if (fund_note!=_previousNote)
00052 {
00053 MIDI::Message tmpMessage1(128, _previousNote, 90, 0);
00054 mOutputMIDIMessage.SendControl(tmpMessage1);
00055
00056 MIDI::Message tmpMessage2(144, fund_note, 90, 0);
00057 mOutputMIDIMessage.SendControl(tmpMessage2);
00058 _previousNote = fund_note;
00059 }
00060
00061 return true;
00062 }
00063
00064
00065 }
00066