earliest MIDI input! (no note input tho)

This commit is contained in:
tildearrow 2022-03-28 03:46:50 -05:00
parent 13a8873050
commit 5360cd73f4
15 changed files with 525 additions and 27 deletions

View file

@ -1537,7 +1537,32 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
isBusy.lock();
}
got.bufsize=size;
// process MIDI events (TODO: everything)
if (output->midiIn) while (!output->midiIn->queue.empty()) {
TAMidiMessage& msg=output->midiIn->queue.front();
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));
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));
break;
}
case TA_MIDI_PROGRAM: {
// TODO: change instrument event thingy
break;
}
}
logD("%.2x\n",msg.type);
output->midiIn->queue.pop();
}
// process audio
if (out!=NULL && ((sPreview.sample>=0 && sPreview.sample<(int)song.sample.size()) || (sPreview.wave>=0 && sPreview.wave<(int)song.wave.size()))) {
unsigned int samp_bbOff=0;
unsigned int prevAvail=blip_samples_avail(samp_bb);