Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions firmware/MIDIClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions firmware/MIDIClass.ino
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ int ReadMIDIeeprom(void)
SetPpqnClock(lGS.PpqnCLOCK);
SetClockMode(lGS.ClockMode);
SetSTSPMode(lGS.StSpMode);
SetRoundRobin(lGS.RoundRobin);
return (GS.NumVoices);
}

Expand Down Expand Up @@ -662,3 +663,7 @@ void SetVoiceMode(int mode)
Serial.println(mode);
#endif
}

void SetRoundRobin(bool roundRobin) {
GS.RoundRobin = roundRobin;
}
26 changes: 26 additions & 0 deletions firmware/MIDILearn.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -410,6 +434,8 @@ byte checkMenuMode( byte channel )
return CHANGEMODE;
} else if (channel == 2) {
return CHANGEOPTIONS;
} else if (channel == 3) {
return CHANGEOPTIONS_EX;
}
}

Expand Down
2 changes: 2 additions & 0 deletions firmware/firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define CALMODE 1
#define CHANGEMODE 2
#define CHANGEOPTIONS 3
#define CHANGEOPTIONS_EX 4

//Percussion midi channel
#define PERCCHANNEL 10
Expand Down Expand Up @@ -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
};


Expand Down
1 change: 1 addition & 0 deletions firmware/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void setup()
SetClockMode(NORMAL_CLOCK);
SetSTSPMode(NORMAL_STSP);
SetPpqnClock(24);
SetRoundRobin(false);
WriteMIDIeeprom();
}

Expand Down