Mercurial > hg > beaglert
diff core/Midi.cpp @ 235:3d41a6fa1830
Merge
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 10 Apr 2016 04:08:06 +0200 |
parents | a0a7f00cf98d |
children | e4392164b458 |
line wrap: on
line diff
--- a/core/Midi.cpp Sat Feb 13 01:51:01 2016 +0000 +++ b/core/Midi.cpp Sun Apr 10 04:08:06 2016 +0200 @@ -58,6 +58,11 @@ messages[writePointer].setDataByte(elapsedDataBytes, input[n]); elapsedDataBytes++; if(elapsedDataBytes == messages[writePointer].getNumDataBytes()){ + // done with the current message + // call the callback if available + if(isCallbackEnabled() == true){ + messageReadyCallback(getNextChannelMessage(), callbackArg); + } waitingForStatus = true; writePointer++; if(writePointer == messages.size()){ @@ -66,6 +71,7 @@ } } } + return consumedBytes; }; @@ -104,14 +110,12 @@ } void Midi::midiInputLoop(){ - printf("Midi input loop %d\n", objAddrs[kMidiInput].size()); for(unsigned int n = 0; n < objAddrs[kMidiInput].size(); n++){ objAddrs[kMidiInput][n] -> readInputLoop(); } } void Midi::midiOutputLoop(){ - printf("Midi output loop %d\n", objAddrs[kMidiOutput].size()); for(unsigned int n = 0; n < objAddrs[kMidiOutput].size(); n++){ objAddrs[kMidiOutput][n] -> writeOutputLoop(); } @@ -132,6 +136,7 @@ if(inputBytesWritePointer == inputBytes.size()){ //wrap pointer around inputBytesWritePointer = 0; } + if(parserEnabled == true && ret > 0){ // if the parser is enabled and there is new data, send the data to it int input; while((input=_getInput()) >= 0){ @@ -168,10 +173,9 @@ objAddrs[kMidiInput].push_back(this); inputPort = open("/dev/midi1", O_RDONLY | O_NONBLOCK | O_NOCTTY); if(inputPort < 0){ - printf("Error occurred while opening midi input port %d: %d", port, inputPort); return -1; } else { - printf("Reading from port %d\n", port); + printf("Reading from Midi port %d\n", port); BeagleRT_scheduleAuxiliaryTask(midiInputTask); return 1; } @@ -181,7 +185,6 @@ objAddrs[kMidiOutput].push_back(this); outputPort = open("/dev/midi1", O_WRONLY, 0); if(outputPort < 0){ - printf("Error occurred while opening midi output port %d: %d", port, outputPort); return -1; } else { printf("Writing to Midi port %d\n", port);