Mercurial > hg > beaglert
diff core/Midi.cpp @ 199:b128e3ea84ff
Fixed midi docs, implentation and example
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 05 Feb 2016 06:49:33 +0000 |
parents | 265a527f8be8 |
children | 97faaf985164 |
line wrap: on
line diff
--- a/core/Midi.cpp Fri Feb 05 06:17:35 2016 +0000 +++ b/core/Midi.cpp Fri Feb 05 06:49:33 2016 +0000 @@ -134,26 +134,10 @@ } 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){ + while((input=_getInput()) >= 0){ midi_byte_t inputByte = (midi_byte_t)(input); -// printf("__0x%x\n", input); inputParser->parse(&inputByte, 1); } -// if(inputBytesReadPointer == inputBytesWritePointer){ - // this should never be the case, it should only happen when ret == 0 -// } else { - -// unsigned int length = (inputBytesWritePointer - inputBytesReadPointer + inputBytes.size()) -// % inputBytes.size(); -// rt_printf("inputBytes: 0x%x 0x%x 0x%x", inputBytes[inputBytesReadPointer], -// inputBytes[inputBytesReadPointer+1], inputBytes[inputBytesReadPointer+2]); -// length = inputParser->parse(&inputBytes[inputBytesReadPointer], length); -// inputBytesReadPointer += length; //if parserEnabled, the readPointer is incremented here, -// //so calls to getInput() should be avoided -// if(inputBytesReadPointer == inputBytes.size()){ -// inputBytesReadPointer = 0; -// } -// } } if(ret < maxBytesToRead){ //no more data to retrieve at the moment usleep(1000); @@ -206,10 +190,7 @@ } } -int Midi::getInput(){ -// if(parserEnabled == true) { -// return -3; -// } +int Midi::_getInput(){ if(inputPort < 0) return -2; if(inputBytesReadPointer == inputBytesWritePointer){ @@ -222,6 +203,13 @@ return inputMessage; } +int Midi::getInput(){ + if(parserEnabled == true) { + return -3; + } + return _getInput(); +} + MidiParser* Midi::getParser(){ if(parserEnabled == false){ return 0;