mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
and more MIDI input refinements
This commit is contained in:
parent
052dcb2576
commit
4b436ef1fc
4 changed files with 39 additions and 7 deletions
|
@ -2673,6 +2673,10 @@ void DivEngine::setMidiBaseChan(int chan) {
|
||||||
midiBaseChan=chan;
|
midiBaseChan=chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::setMidiDirect(bool value) {
|
||||||
|
midiIsDirect=value;
|
||||||
|
}
|
||||||
|
|
||||||
void DivEngine::setMidiCallback(std::function<int(const TAMidiMessage&)> what) {
|
void DivEngine::setMidiCallback(std::function<int(const TAMidiMessage&)> what) {
|
||||||
midiCallback=what;
|
midiCallback=what;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,7 @@ class DivEngine {
|
||||||
bool softLocked;
|
bool softLocked;
|
||||||
bool firstTick;
|
bool firstTick;
|
||||||
bool skipping;
|
bool skipping;
|
||||||
|
bool midiIsDirect;
|
||||||
int softLockCount;
|
int softLockCount;
|
||||||
int ticks, curRow, curOrder, remainingLoops, nextSpeed;
|
int ticks, curRow, curOrder, remainingLoops, nextSpeed;
|
||||||
double divider;
|
double divider;
|
||||||
|
@ -650,6 +651,9 @@ class DivEngine {
|
||||||
// set MIDI base channel
|
// set MIDI base channel
|
||||||
void setMidiBaseChan(int chan);
|
void setMidiBaseChan(int chan);
|
||||||
|
|
||||||
|
// set MIDI direct channel map
|
||||||
|
void setMidiDirect(bool value);
|
||||||
|
|
||||||
// set MIDI input callback
|
// set MIDI input callback
|
||||||
// if the specified function returns -2, note feedback will be inhibited.
|
// if the specified function returns -2, note feedback will be inhibited.
|
||||||
void setMidiCallback(std::function<int(const TAMidiMessage&)> what);
|
void setMidiCallback(std::function<int(const TAMidiMessage&)> what);
|
||||||
|
@ -715,6 +719,7 @@ class DivEngine {
|
||||||
softLocked(false),
|
softLocked(false),
|
||||||
firstTick(false),
|
firstTick(false),
|
||||||
skipping(false),
|
skipping(false),
|
||||||
|
midiIsDirect(false),
|
||||||
softLockCount(0),
|
softLockCount(0),
|
||||||
ticks(0),
|
ticks(0),
|
||||||
curRow(0),
|
curRow(0),
|
||||||
|
|
|
@ -1597,7 +1597,11 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
switch (msg.type&0xf0) {
|
switch (msg.type&0xf0) {
|
||||||
case TA_MIDI_NOTE_OFF: {
|
case TA_MIDI_NOTE_OFF: {
|
||||||
if (chan<0 || chan>=chans) break;
|
if (chan<0 || chan>=chans) break;
|
||||||
autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]);
|
if (midiIsDirect) {
|
||||||
|
pendingNotes.push(DivNoteEvent(chan,-1,-1,-1,false));
|
||||||
|
} else {
|
||||||
|
autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]);
|
||||||
|
}
|
||||||
if (!playing) {
|
if (!playing) {
|
||||||
reset();
|
reset();
|
||||||
freelance=true;
|
freelance=true;
|
||||||
|
@ -1608,9 +1612,17 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
case TA_MIDI_NOTE_ON: {
|
case TA_MIDI_NOTE_ON: {
|
||||||
if (chan<0 || chan>=chans) break;
|
if (chan<0 || chan>=chans) break;
|
||||||
if (msg.data[1]==0) {
|
if (msg.data[1]==0) {
|
||||||
autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]);
|
if (midiIsDirect) {
|
||||||
|
pendingNotes.push(DivNoteEvent(chan,-1,-1,-1,false));
|
||||||
|
} else {
|
||||||
|
autoNoteOff(msg.type&15,msg.data[0]-12,msg.data[1]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
autoNoteOn(msg.type&15,ins,msg.data[0]-12,msg.data[1]);
|
if (midiIsDirect) {
|
||||||
|
pendingNotes.push(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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,18 +363,26 @@ void FurnaceGUI::drawSettings() {
|
||||||
ImGui::Text("MIDI input");
|
ImGui::Text("MIDI input");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
String midiInName=settings.midiInDevice.empty()?"<disabled>":settings.midiInDevice;
|
String midiInName=settings.midiInDevice.empty()?"<disabled>":settings.midiInDevice;
|
||||||
|
bool hasToReloadMidi=false;
|
||||||
if (ImGui::BeginCombo("##MidiInDevice",midiInName.c_str())) {
|
if (ImGui::BeginCombo("##MidiInDevice",midiInName.c_str())) {
|
||||||
if (ImGui::Selectable("<disabled>",settings.midiInDevice.empty())) {
|
if (ImGui::Selectable("<disabled>",settings.midiInDevice.empty())) {
|
||||||
settings.midiInDevice="";
|
settings.midiInDevice="";
|
||||||
|
hasToReloadMidi=true;
|
||||||
}
|
}
|
||||||
for (String& i: e->getMidiIns()) {
|
for (String& i: e->getMidiIns()) {
|
||||||
if (ImGui::Selectable(i.c_str(),i==settings.midiInDevice)) {
|
if (ImGui::Selectable(i.c_str(),i==settings.midiInDevice)) {
|
||||||
settings.midiInDevice=i;
|
settings.midiInDevice=i;
|
||||||
|
hasToReloadMidi=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasToReloadMidi) {
|
||||||
|
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
||||||
|
midiMap.compile();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Text("MIDI output");
|
ImGui::Text("MIDI output");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
String midiOutName=settings.midiOutDevice.empty()?"<disabled>":settings.midiOutDevice;
|
String midiOutName=settings.midiOutDevice.empty()?"<disabled>":settings.midiOutDevice;
|
||||||
|
@ -393,12 +401,13 @@ void FurnaceGUI::drawSettings() {
|
||||||
if (ImGui::TreeNode("MIDI input settings")) {
|
if (ImGui::TreeNode("MIDI input settings")) {
|
||||||
ImGui::Checkbox("Note input",&midiMap.noteInput);
|
ImGui::Checkbox("Note input",&midiMap.noteInput);
|
||||||
ImGui::Checkbox("Velocity input",&midiMap.volInput);
|
ImGui::Checkbox("Velocity input",&midiMap.volInput);
|
||||||
ImGui::Checkbox("Use raw velocity value (don't map from linear to log)",&midiMap.rawVolume);
|
// TODO
|
||||||
ImGui::Checkbox("Polyphonic/chord input",&midiMap.polyInput);
|
//ImGui::Checkbox("Use raw velocity value (don't map from linear to log)",&midiMap.rawVolume);
|
||||||
|
//ImGui::Checkbox("Polyphonic/chord input",&midiMap.polyInput);
|
||||||
ImGui::Checkbox("Map MIDI channels to direct channels",&midiMap.directChannel);
|
ImGui::Checkbox("Map MIDI channels to direct channels",&midiMap.directChannel);
|
||||||
ImGui::Checkbox("Program change is instrument selection",&midiMap.programChange);
|
ImGui::Checkbox("Program change is instrument selection",&midiMap.programChange);
|
||||||
ImGui::Checkbox("Listen to MIDI clock",&midiMap.midiClock);
|
//ImGui::Checkbox("Listen to MIDI clock",&midiMap.midiClock);
|
||||||
ImGui::Checkbox("Listen to MIDI time code",&midiMap.midiTimeCode);
|
//ImGui::Checkbox("Listen to MIDI time code",&midiMap.midiTimeCode);
|
||||||
ImGui::Combo("Value input style",&midiMap.valueInputStyle,valueInputStyles,7);
|
ImGui::Combo("Value input style",&midiMap.valueInputStyle,valueInputStyles,7);
|
||||||
if (midiMap.valueInputStyle>3) {
|
if (midiMap.valueInputStyle>3) {
|
||||||
if (midiMap.valueInputStyle==6) {
|
if (midiMap.valueInputStyle==6) {
|
||||||
|
@ -1570,6 +1579,8 @@ void FurnaceGUI::syncSettings() {
|
||||||
|
|
||||||
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
||||||
midiMap.compile();
|
midiMap.compile();
|
||||||
|
|
||||||
|
e->setMidiDirect(midiMap.directChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PUT_UI_COLOR(source) e->setConf(#source,(int)ImGui::GetColorU32(uiColors[source]));
|
#define PUT_UI_COLOR(source) e->setConf(#source,(int)ImGui::GetColorU32(uiColors[source]));
|
||||||
|
|
Loading…
Reference in a new issue