19 MIDIInput::MIDIInput(MIDIPtr protocol,
TTSymbol& application) :
24 mApplication(application)
29 MIDIInput::~MIDIInput()
39 mPollingThread->wait();
40 delete mPollingThread;
45 const PmDeviceInfo* deviceInfo;
47 PmError err = pmNoError;
49 if (newName != mName) {
52 deviceCount = Pm_CountDevices();
53 for (i = 0; i < deviceCount; i++) {
55 deviceInfo = Pm_GetDeviceInfo(i);
57 if (deviceInfo->input && newName ==
TTSymbol(deviceInfo->name))
73 err = Pm_OpenInput(&mStream, i, NULL, kMidiBufferSize, NULL, NULL);
76 TTLogError(
"MIDIInput::setName : can't open the %s device\n", mName.c_str());
86 if (running != mRunning) {
92 mPollingThread =
new TTThread(TTThreadCallbackType(
MIDIInputPoll),
this);
97 mPollingThread->wait();
98 delete mPollingThread;
110 while (self->mRunning) {
112 if (Pm_Poll(self->mStream)) {
114 result = Pm_Read(self->mStream, buffer, 64);
124 MIDIParserFrom parser;
126 for (
TTInt32 i = 0; i < result; i++) {
129 if (parser.parse(Pm_MessageStatus(buffer[i].message), Pm_MessageData1(buffer[i].message), Pm_MessageData2(buffer[i].message)))
130 self->mProtocol->receivedMessage(self->mApplication, parser.address, parser.value);
135 self->mPollingThread->sleep(1);
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
void TTFOUNDATION_EXPORT TTLogError(TTImmutableCString message,...)
Platform and host independent method for posting errors.
std::int32_t TTInt32
32 bit signed integer
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...