diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 0f90d0ac1..fee7a6fd5 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1825,37 +1825,37 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi 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; - if (midiIsDirect) { - pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false)); - } else { - autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]); - } - if (!playing) { - reset(); - freelance=true; - playing=true; - } - break; - } - case TA_MIDI_NOTE_ON: { - if (chan<0 || chan>=chans) break; - if (msg.data[1]==0) { - if (midiIsDirect) { - pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false)); - } else { - autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]); - } - } else { - if (midiIsDirect) { - pendingNotes.push_back(DivNoteEvent(chan,ins,msg.data[0]-12,msg.data[1],true)); - } else { - autoNoteOn(msg.type&15,ins,msg.data[0]-12,msg.data[1]); - } - } - break; - } + // case TA_MIDI_NOTE_OFF: { + // if (chan<0 || chan>=chans) break; + // if (midiIsDirect) { + // pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false)); + // } else { + // autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]); + // } + // if (!playing) { + // reset(); + // freelance=true; + // playing=true; + // } + // break; + // } + // case TA_MIDI_NOTE_ON: { + // if (chan<0 || chan>=chans) break; + // if (msg.data[1]==0) { + // if (midiIsDirect) { + // pendingNotes.push_back(DivNoteEvent(chan,-1,-1,-1,false)); + // } else { + // autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]); + // } + // } else { + // if (midiIsDirect) { + // pendingNotes.push_back(DivNoteEvent(chan,ins,msg.data[0]-12,msg.data[1],true)); + // } else { + // autoNoteOn(msg.type&15,ins,msg.data[0]-12,msg.data[1]); + // } + // } + // break; + // } case TA_MIDI_PROGRAM: { // TODO: change instrument event thingy break; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ccb307fd6..1b460c90f 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3767,6 +3767,10 @@ bool FurnaceGUI::loop() { learning=-1; } else { int action=midiMap.at(msg); + int chan=msg.type&15; + int ins=-1; + int vol = midiMap.volInput?((int)(pow((double)msg.data[1]/127.0,midiMap.volExp)*127.0)):-1; + int note = msg.data[0]-12; if (action!=0) { doAction(action); } else switch (msg.type&0xf0) { @@ -3774,10 +3778,33 @@ bool FurnaceGUI::loop() { if (midiMap.valueInputStyle==0 || midiMap.valueInputStyle>3 || cursor.xFine==0) { if (midiMap.noteInput && edit && msg.data[1]!=0) { noteInput( - msg.data[0]-12, + note, 0, - midiMap.volInput?((int)(pow((double)msg.data[1]/127.0,midiMap.volExp)*127.0)):-1 + vol ); + // Preview note input with velocity sensitivity + if (midiMap.directChannel) { + e->noteOn( + chan, + ins, + note, + vol + ); + } else { + e->autoNoteOn( + chan, + ins, + note, + vol + ); + } + } else if (msg.data[1]==0) { + // Velocity 0 note offs + if (midiMap.directChannel) { + e->noteOff(chan); + } else { + e->autoNoteOff(chan, note); + } } } else { if (edit && msg.data[1]!=0) { @@ -3802,6 +3829,13 @@ bool FurnaceGUI::loop() { } } break; + case TA_MIDI_NOTE_OFF: + if (midiMap.directChannel) { + e->noteOff(msg.type&15); + } else { + e->autoNoteOff(msg.type&15, msg.data[0]-12); + } + break; case TA_MIDI_PROGRAM: if (midiMap.programChange) { curIns=msg.data[0];