diff --git a/firmware/MIDIClass.h b/firmware/MIDIClass.h index 9ee4ab8..96a63ca 100644 --- a/firmware/MIDIClass.h +++ b/firmware/MIDIClass.h @@ -482,6 +482,7 @@ class VoiceSelector { return -1; // something went wrong } + int nextChannel = 0; // stores which channel is next for round-robin allocation int getPolyTargetChannel(byte channel, byte pitch, byte velocity) { //look for a mininmum pitch @@ -502,10 +503,27 @@ class VoiceSelector { } // then look for an empty channel - for (int i = 0; i < GS.NumVoices; i++) { - if (Voice[i].midiChannel == channel && !Voice[i].notes.getCount()) { - return i; + if (GS.RoundRobin) { + for (int i = nextChannel; i < GS.NumVoices; i++) { + if (Voice[i].midiChannel == channel && !Voice[i].notes.getCount()) { + nextChannel = i + 1; + if (nextChannel >= GS.NumVoices) nextChannel = 0; + return i; + } } + for (int i = 0; i < nextChannel; i++) { + if (Voice[i].midiChannel == channel && !Voice[i].notes.getCount()) { + nextChannel = i + 1; + if (nextChannel >= GS.NumVoices) nextChannel = 0; + return i; + } + } + } else { + for (int i = 0; i < GS.NumVoices; i++) { + if (Voice[i].midiChannel == channel && !Voice[i].notes.getCount()) { + return i; + } + } } if (!velocity) { diff --git a/firmware/MIDIClass.ino b/firmware/MIDIClass.ino index e413e03..740fed1 100644 --- a/firmware/MIDIClass.ino +++ b/firmware/MIDIClass.ino @@ -481,6 +481,7 @@ int ReadMIDIeeprom(void) SetPpqnClock(lGS.PpqnCLOCK); SetClockMode(lGS.ClockMode); SetSTSPMode(lGS.StSpMode); + SetRoundRobin(lGS.RoundRobin); return (GS.NumVoices); } @@ -662,3 +663,7 @@ void SetVoiceMode(int mode) Serial.println(mode); #endif } + +void SetRoundRobin(bool roundRobin) { + GS.RoundRobin = roundRobin; +} diff --git a/firmware/MIDILearn.ino b/firmware/MIDILearn.ino index 27c444a..ddccf55 100644 --- a/firmware/MIDILearn.ino +++ b/firmware/MIDILearn.ino @@ -151,6 +151,12 @@ byte MenuModeHandle(byte channel, byte pitch, byte velocity) ResetToCurrentVoiceMode(); } break; + case CHANGEOPTIONS_EX: + lv_return = selectOptions2(pitch); + if (!calProcEnabled && lv_return == 1) { + ResetToCurrentVoiceMode(); + } + break; default: lv_return = 0; break; @@ -239,6 +245,24 @@ byte selectOptions(byte pitch) break; } } +byte selectOptions2(byte pitch) +{ + byte lv_pitch = pitch; + lv_pitch = getElementalPitch(pitch); + switch (lv_pitch) { + case 0: // C + SetRoundRobin(false); + return 1; + break; + case 2: // D + SetRoundRobin(true); + return 1; + break; + default: + return 0; + break; + } +} ///////////////////////////////////////////////////////////////////////////////////////////// //Voice mode selection ///////////////////////////////////////////////////////////////////////////////////////////// @@ -410,6 +434,8 @@ byte checkMenuMode( byte channel ) return CHANGEMODE; } else if (channel == 2) { return CHANGEOPTIONS; + } else if (channel == 3) { + return CHANGEOPTIONS_EX; } } diff --git a/firmware/firmware.h b/firmware/firmware.h index 8820e72..c98e485 100644 --- a/firmware/firmware.h +++ b/firmware/firmware.h @@ -39,6 +39,7 @@ #define CALMODE 1 #define CHANGEMODE 2 #define CHANGEOPTIONS 3 +#define CHANGEOPTIONS_EX 4 //Percussion midi channel #define PERCCHANNEL 10 @@ -82,6 +83,7 @@ struct GENERALSETTINGS { int ClockMode = NORMAL_CLOCK; //Clock mode int PpqnCLOCK = 24; //Clock resolution int StSpMode = NORMAL_STSP; //Start/stop mode + bool RoundRobin = false; //RoundRobin mode }; diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 420b129..901fff7 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -164,6 +164,7 @@ void setup() SetClockMode(NORMAL_CLOCK); SetSTSPMode(NORMAL_STSP); SetPpqnClock(24); + SetRoundRobin(false); WriteMIDIeeprom(); }