mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
oh yes more MIDI work
This commit is contained in:
parent
d8328e91a7
commit
08910d37b2
4 changed files with 33 additions and 16 deletions
|
@ -2621,6 +2621,10 @@ bool DivEngine::switchMaster() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::setMidiCallback(std::function<bool(const TAMidiMessage&)> what) {
|
||||||
|
midiCallback=what;
|
||||||
|
}
|
||||||
|
|
||||||
void DivEngine::synchronized(const std::function<void()>& what) {
|
void DivEngine::synchronized(const std::function<void()>& what) {
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
what();
|
what();
|
||||||
|
|
|
@ -244,6 +244,8 @@ class DivEngine {
|
||||||
|
|
||||||
size_t totalProcessed;
|
size_t totalProcessed;
|
||||||
|
|
||||||
|
std::function<bool(const TAMidiMessage&)> midiCallback=[](const TAMidiMessage&) -> bool {return false;};
|
||||||
|
|
||||||
DivSystem systemFromFile(unsigned char val);
|
DivSystem systemFromFile(unsigned char val);
|
||||||
unsigned char systemToFile(DivSystem val);
|
unsigned char systemToFile(DivSystem val);
|
||||||
int dispatchCmd(DivCommand c);
|
int dispatchCmd(DivCommand c);
|
||||||
|
@ -635,6 +637,10 @@ class DivEngine {
|
||||||
// switch master
|
// switch master
|
||||||
bool switchMaster();
|
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);
|
||||||
|
|
||||||
// perform secure/sync operation
|
// perform secure/sync operation
|
||||||
void synchronized(const std::function<void()>& what);
|
void synchronized(const std::function<void()>& what);
|
||||||
|
|
||||||
|
|
|
@ -1541,21 +1541,23 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
// process MIDI events (TODO: everything)
|
// process MIDI events (TODO: everything)
|
||||||
if (output->midiIn) while (!output->midiIn->queue.empty()) {
|
if (output->midiIn) while (!output->midiIn->queue.empty()) {
|
||||||
TAMidiMessage& msg=output->midiIn->queue.front();
|
TAMidiMessage& msg=output->midiIn->queue.front();
|
||||||
int chan=msg.type&15;
|
if (!midiCallback(msg)) {
|
||||||
switch (msg.type&0xf0) {
|
int chan=msg.type&15;
|
||||||
case TA_MIDI_NOTE_OFF: {
|
switch (msg.type&0xf0) {
|
||||||
if (chan<0 || chan>=chans) break;
|
case TA_MIDI_NOTE_OFF: {
|
||||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,-1,-1,false));
|
if (chan<0 || chan>=chans) break;
|
||||||
break;
|
pendingNotes.push(DivNoteEvent(msg.type&15,-1,-1,-1,false));
|
||||||
}
|
break;
|
||||||
case TA_MIDI_NOTE_ON: {
|
}
|
||||||
if (chan<0 || chan>=chans) break;
|
case TA_MIDI_NOTE_ON: {
|
||||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,(int)msg.data[0]-12,msg.data[1],true));
|
if (chan<0 || chan>=chans) break;
|
||||||
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
|
case TA_MIDI_PROGRAM: {
|
||||||
break;
|
// TODO: change instrument event thingy
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logD("%.2x\n",msg.type);
|
logD("%.2x\n",msg.type);
|
||||||
|
|
|
@ -2628,6 +2628,11 @@ bool FurnaceGUI::init() {
|
||||||
|
|
||||||
firstFrame=true;
|
firstFrame=true;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
e->setMidiCallback([this](const TAMidiMessage& msg) -> bool {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue