zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit a603795f02403c0d1900ae765052e123ce7a5909
parent 7592cde773d62a74985c7d5e929504627ca0b731
Author: fundamental <[email protected]>
Date:   Fri,  3 Jun 2011 12:43:30 -0400

Applying OSS Midi Patch

Patch from mailing list Hans Petter Selasky
Incorperated midi escape sequences

Diffstat:
MAUTHORS.txt | 1+
Msrc/Nio/OssEngine.cpp | 40+++++++++++++++++++++++++++++-----------
2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/AUTHORS.txt b/AUTHORS.txt @@ -18,4 +18,5 @@ Contributors: Alan Calvert (Portions of New IO) Stephen Parry (DSSI rebuild) Ryan Billing (APhaser) + Hans Petter Selasky (OSS Midi) diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -239,18 +239,36 @@ void *OssEngine::thread() //Collect up to 30 midi events for (int k = 0; k < 30 && getMidiEn(); ++k) { - getMidi(tmp); - unsigned char type = tmp[0]; - unsigned char header = tmp[1]; - if(header!=0xfe&&type==SEQ_MIDIPUTC&&header>=0x80) - { - getMidi(tmp); - unsigned char num = tmp[1]; - getMidi(tmp); - unsigned char value = tmp[1]; + static char escaped; + + memset(tmp, 0, 4); - midiProcess(header, num, value); + if (escaped) { + tmp[0] = escaped; + escaped = 0; + } else { + getMidi(tmp); + if (!(tmp[0] & 0x80)) + continue; + } + getMidi(tmp + 1); + if (tmp[1] & 0x80) { + escaped = tmp[1]; + tmp[1] = 0; + } else { + getMidi(tmp + 2); + if (tmp[2] & 0x80) { + escaped = tmp[2]; + tmp[2] = 0; + } else { + getMidi(tmp + 3); + if (tmp[3] & 0x80) { + escaped = tmp[3]; + tmp[3] = 0; + } + } } + midiProcess(tmp[0], tmp[1], tmp[2]); } } pthread_exit(NULL); @@ -259,6 +277,6 @@ void *OssEngine::thread() void OssEngine::getMidi(unsigned char *midiPtr) { - read(midi.handle, midiPtr, 4); + read(midi.handle, midiPtr, 1); }