29 class TextFileMIDIDevice:
public MIDIDevice
37 TextFileMIDIDevice(
const std::string& name,
const std::string& device);
38 ~TextFileMIDIDevice();
40 void ConcreteStart(
void) throw(Err);
41 void ConcreteStop(
void) throw(Err);
43 void Read(
void) throw(Err);
44 void Write(
unsigned char* msg,
int size) throw(Err);
50 TextFileMIDIDevice::TextFileMIDIDevice(
const std::string& name,
const std::string& device):
59 void TextFileMIDIDevice::ConcreteStart(
void) throw(Err)
61 if (mOut) fclose(mOut);
67 if (mInputs.size() && mOutputs.size() && mDevice!=
"-")
69 throw Err(
"TextFileMIDIDevice: Cannot use the same file for reading and writing");
76 mIn = fopen(mDevice.c_str(),
"r");
83 mOut = fopen(mDevice.c_str(),
"w");
87 void TextFileMIDIDevice::ConcreteStop(
void) throw(Err)
89 if (mOut) fclose(mOut);
90 if (mIn) fclose(mOut);
95 void TextFileMIDIDevice::Write(
unsigned char* msg,
int size)
throw(Err)
97 printf(
"TextFileMIDIDevice::Write:");
99 for (
int i=0;i<size;i++)
101 printf(
" 0x%02x",msg[i]);
106 fprintf(mOut,
"%f",mClock);
107 for (
int i=0;i<size;i++)
109 fprintf(mOut,
" 0x%02x",msg[i]);
114 void TextFileMIDIDevice::Read(
void) throw(Err)
118 TextFileMIDIDevice::~TextFileMIDIDevice()
123 class TextFileMIDIDeviceList:
public MIDIDeviceList
125 static TextFileMIDIDeviceList sDevices;
127 TextFileMIDIDeviceList()
136 std::string DefaultDevice(
void)
142 const std::string& name,
const std::string& device)
144 return new TextFileMIDIDevice(name,device);
148 TextFileMIDIDeviceList TextFileMIDIDeviceList::sDevices;