diff core/Midi.cpp @ 224:97faaf985164 mergingClockSync

Added callback for Midi channel messages
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 08 Mar 2016 15:49:42 +0000
parents b128e3ea84ff
children af1e662400fc
line wrap: on
line diff
--- a/core/Midi.cpp	Mon Feb 22 11:28:21 2016 +0000
+++ b/core/Midi.cpp	Tue Mar 08 15:49:42 2016 +0000
@@ -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());
+				}
 				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){