Skip to content

Commit

Permalink
Add MPE routing for timbre, pressure.
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Oct 18, 2024
1 parent ecc54a6 commit 3575bdd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
22 changes: 22 additions & 0 deletions include/sst/voicemanager/managers/polymanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,28 @@ template <typename Cfg, typename VoiceResponder, typename MonoResponder> struct
{
monoResponder.setMIDIChannelPressure(channel, pat);
}

void routeMIDIMPETimbreToVoice(int16_t port, int16_t channel, int8_t val)
{
for (auto &vi : voiceInfo)
{
if (vi.port == port && vi.channel == channel && vi.gated)
{
responder.setVoiceMIDIMPETimbre(vi.activeVoiceCookie, val);
}
}
}

void routeMIDIMPEChannelPressureToVoice(int16_t port, int16_t channel, int8_t val)
{
for (auto &vi : voiceInfo)
{
if (vi.port == port && vi.channel == channel && vi.gated)
{
responder.setVoiceMIDIMPEChannelPressure(vi.activeVoiceCookie, val);
}
}
}
};
} // namespace sst::voicemanager::managers

Expand Down
33 changes: 31 additions & 2 deletions include/sst/voicemanager/voicemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ template <typename Cfg, typename Responder, typename MonoResponder> struct Voice
} dialect{MIDI1};

int8_t mpeGlobalChannel{0};
int8_t mpeTimbreCC{74};

Responder &responder;
MonoResponder &monoResponder;
Expand Down Expand Up @@ -124,7 +125,21 @@ template <typename Cfg, typename Responder, typename MonoResponder> struct Voice
switch (voiceMode)
{
case POLY:
polyManager.routeMIDI1CC(port, channel, cc, val);
if (dialect == MIDI1)
{
polyManager.routeMIDI1CC(port, channel, cc, val);
}
else if (dialect == MIDI1_MPE)
{
if (channel == mpeGlobalChannel || cc != mpeTimbreCC)
{
polyManager.routeMIDI1CC(port, channel, cc, val);
}
else
{
polyManager.routeMIDIMPETimbreToVoice(port, channel, val);
}
}
}
}

Expand All @@ -142,7 +157,21 @@ template <typename Cfg, typename Responder, typename MonoResponder> struct Voice
switch (voiceMode)
{
case POLY:
polyManager.routeChannelPressure(port, channel, pat);
if (dialect == MIDI1)
{
polyManager.routeChannelPressure(port, channel, pat);
}
else if (dialect == MIDI1_MPE)
{
if (channel == mpeGlobalChannel)
{
polyManager.routeChannelPressure(port, channel, pat);
}
else
{
polyManager.routeMIDIMPEChannelPressureToVoice(port, channel, pat);
}
}
}
}
void routeNoteExpression(int16_t port, int16_t channel, int16_t key, int32_t noteid,
Expand Down

0 comments on commit 3575bdd

Please sign in to comment.