1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include "MIDIManager.hxx"
#include "MIDIInControl.hxx"
#include "MIDIOutControl.hxx"
#include "MIDIClocker.hxx"
#include <vector>
using namespace CLAM;
main()
{
char* indevice = "file:zefile.mid";
char* outdevice = "textfile:test.txt";
MIDIManager manager;
MIDIInConfig inNoteCfg;
MIDIOutConfig outNoteCfg;
MIDIClockerConfig inpClockerCfg;
MIDIClockerConfig outClockerCfg;
inpClockerCfg.SetDevice(indevice);
outClockerCfg.SetDevice(outdevice);
MIDIClocker inpClocker(inpClockerCfg);
MIDIClocker outClocker(outClockerCfg);
inNoteCfg.SetDevice(indevice);
inNoteCfg.SetMessage(MIDI::eNoteOnOff);
outNoteCfg.SetDevice(outdevice);
outNoteCfg.SetMessage(MIDI::eNoteOnOff);
MIDIInControl inNote(inNoteCfg);
MIDIOutControl outNote(outNoteCfg);
//control for stoping at eof
MIDIInConfig inStopCfg;
inStopCfg.SetDevice(indevice);
inStopCfg.SetChannel(CLAM::MIDI::eStop); //it is a sys message that uses channel byte for actual data
inStopCfg.SetMessage(CLAM::MIDI::eSystem);
MIDIInControl inStop(inStopCfg);
FloatInControl stopReceiver("stop-receiver");
inStop.GetOutControl(0).AddLink( &stopReceiver);
inNote.GetOutControl(0).AddLink( &outNote.GetInControl(0));
inNote.GetOutControl(1).AddLink( &outNote.GetInControl(1));
inNote.GetOutControl(2).AddLink( &outNote.GetInControl(2));
manager.Start();
TTime curTime = 0;
while (stopReceiver.GetLastValue()==0)
{
//we send a timing control to the MIDI clocker
SendFloatToInControl(inpClocker,0,curTime);
SendFloatToInControl(outClocker,0,curTime);
//we check for new events in the MIDI manager
manager.Check();
//we increment the time counter
curTime ++;
}
}
|