Skip to content

Commit

Permalink
Add option to use MIDI channels 2 and 3 to play scenes individually (#…
Browse files Browse the repository at this point in the history
…6606)

Closes #4657
  • Loading branch information
mkruselj authored Sep 10, 2022
1 parent 1b4414e commit d0b03d3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,52 +298,67 @@ SurgeSynthesizer::~SurgeSynthesizer()
}
}

// A voice is routed to a particular scene if channelmask & n.
// So, "1" means scene A, "2" means scene B and "3" (= 2 | 1) means both.
int SurgeSynthesizer::calculateChannelMask(int channel, int key)
{
/*
** Just because I always forget
**
** A voice is routed to scene n if channelmask & n. So "1" means scene A, "2" means scene B and
*"3" (= 2 | 1 ) = both.
*/
bool useMIDICh2Ch3 = Surge::Storage::getUserDefaultValue(
&storage, Surge::Storage::UseCh2Ch3ToPlayScenesIndividually, true);

int channelmask = channel;

if ((channel == 0) || (channel > 2) || mpeEnabled ||
storage.getPatch().scenemode.val.i == sm_chsplit || storage.mapChannelToOctave)
if (((channel == 0 || channel > 2) && useMIDICh2Ch3) ||
(channel >= 0 && channel < 16 && !useMIDICh2Ch3) || mpeEnabled ||
storage.mapChannelToOctave || storage.getPatch().scenemode.val.i == sm_chsplit)
{
switch (storage.getPatch().scenemode.val.i)
{
case sm_single:
// case sm_morph:
if (storage.getPatch().scene_active.val.i == 1)
{
channelmask = 2;
}
else
{
channelmask = 1;
}
break;
case sm_dual:
channelmask = 3;
break;
case sm_split:
if (key < storage.getPatch().splitpoint.val.i)
{
channelmask = 1;
}
else
{
channelmask = 2;
}
break;
case sm_chsplit:
if (channel < ((int)(storage.getPatch().splitpoint.val.i / 8) + 1))
{
channelmask = 1;
}
else
{
channelmask = 2;
}

break;
}
}
else if (storage.getPatch().scenemode.val.i == sm_single)
{
if (storage.getPatch().scene_active.val.i == 1)
{
channelmask = 2;
}
else
{
channelmask = 1;
}
}

return channelmask;
Expand All @@ -353,7 +368,9 @@ void SurgeSynthesizer::playNote(char channel, char key, char velocity, char detu
int32_t host_noteid)
{
if (halt_engine)
{
return;
}

if (storage.oddsound_mts_client && storage.oddsound_mts_active)
{
Expand Down Expand Up @@ -402,6 +419,8 @@ void SurgeSynthesizer::playNote(char channel, char key, char velocity, char detu

int channelmask = calculateChannelMask(channel, key);

printf("channelmask %d\n", channelmask);

// TODO: FIX SCENE ASSUMPTION
if (channelmask & 1)
{
Expand Down
3 changes: 3 additions & 0 deletions src/common/UserDefaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ std::string defaultKeyToString(DefaultKey k)
case MPEPitchBendRange:
r = "mpePitchBendRange";
break;
case UseCh2Ch3ToPlayScenesIndividually:
r = "useCh2Ch3ToPlayScenesIndividually";
break;
case RestoreMSEGSnapFromPatch:
r = "restoreMSEGSnapFromPatch";
break;
Expand Down
1 change: 1 addition & 0 deletions src/common/UserDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum DefaultKey

MPEPitchBendRange,
PitchSmoothingMode,
UseCh2Ch3ToPlayScenesIndividually,

SmoothingMode,
MonoPedalMode,
Expand Down
11 changes: 11 additions & 0 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4374,6 +4374,17 @@ juce::PopupMenu SurgeGUIEditor::makeMidiMenu(const juce::Point<int> &where)
auto mmom = makeMonoModeOptionsMenu(where, true);
midiSubMenu.addSubMenu(Surge::GUI::toOSCase("Sustain Pedal In Mono Mode"), mmom);

bool useMIDICh2Ch3 = Surge::Storage::getUserDefaultValue(
&(this->synth->storage), Surge::Storage::UseCh2Ch3ToPlayScenesIndividually, true);

midiSubMenu.addItem(
Surge::GUI::toOSCase("Use MIDI Channels 2 and 3 to Play Scenes Individually"), true,
useMIDICh2Ch3, [this, useMIDICh2Ch3]() {
Surge::Storage::updateUserDefaultValue(
&(this->synth->storage), Surge::Storage::UseCh2Ch3ToPlayScenesIndividually,
!useMIDICh2Ch3);
});

midiSubMenu.addSeparator();

midiSubMenu.addItem(Surge::GUI::toOSCase("Save MIDI Mapping As..."), [this, where]() {
Expand Down

0 comments on commit d0b03d3

Please sign in to comment.