more work
This commit is contained in:
parent
81319e34bc
commit
4825fe7adb
5 changed files with 57 additions and 10 deletions
|
|
@ -2621,7 +2621,7 @@ bool DivEngine::switchMaster() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void DivEngine::setMidiCallback(std::function<bool(const TAMidiMessage&)> what) {
|
||||
void DivEngine::setMidiCallback(std::function<int(const TAMidiMessage&)> what) {
|
||||
midiCallback=what;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -244,7 +244,8 @@ class DivEngine {
|
|||
|
||||
size_t totalProcessed;
|
||||
|
||||
std::function<bool(const TAMidiMessage&)> midiCallback=[](const TAMidiMessage&) -> bool {return false;};
|
||||
// MIDI stuff
|
||||
std::function<int(const TAMidiMessage&)> midiCallback=[](const TAMidiMessage&) -> int {return -1;};
|
||||
|
||||
DivSystem systemFromFile(unsigned char val);
|
||||
unsigned char systemToFile(DivSystem val);
|
||||
|
|
@ -638,8 +639,8 @@ class DivEngine {
|
|||
bool switchMaster();
|
||||
|
||||
// set MIDI input callback
|
||||
// if the specified function returns true, note feedback will be inhibited.
|
||||
void setMidiCallback(std::function<bool(const TAMidiMessage&)> what);
|
||||
// if the specified function returns -2, note feedback will be inhibited.
|
||||
void setMidiCallback(std::function<int(const TAMidiMessage&)> what);
|
||||
|
||||
// perform secure/sync operation
|
||||
void synchronized(const std::function<void()>& what);
|
||||
|
|
|
|||
|
|
@ -1541,17 +1541,32 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
// process MIDI events (TODO: everything)
|
||||
if (output->midiIn) while (!output->midiIn->queue.empty()) {
|
||||
TAMidiMessage& msg=output->midiIn->queue.front();
|
||||
if (!midiCallback(msg)) {
|
||||
int ins=-1;
|
||||
if ((ins=midiCallback(msg))!=-2) {
|
||||
int chan=msg.type&15;
|
||||
switch (msg.type&0xf0) {
|
||||
case TA_MIDI_NOTE_OFF: {
|
||||
if (chan<0 || chan>=chans) break;
|
||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,-1,-1,false));
|
||||
if (!playing) {
|
||||
reset();
|
||||
freelance=true;
|
||||
playing=true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TA_MIDI_NOTE_ON: {
|
||||
if (chan<0 || chan>=chans) break;
|
||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,(int)msg.data[0]-12,msg.data[1],true));
|
||||
if (msg.data[1]==0) {
|
||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,-1,-1,false));
|
||||
} else {
|
||||
pendingNotes.push(DivNoteEvent(msg.type&15,ins,(int)msg.data[0]-12,msg.data[1],true));
|
||||
}
|
||||
if (!playing) {
|
||||
reset();
|
||||
freelance=true;
|
||||
playing=true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TA_MIDI_PROGRAM: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue