Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MPE routing for timbre, pressure. #10

Merged
merged 2 commits into from
Oct 18, 2024
Merged
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
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.activeVoiceCookie && 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.activeVoiceCookie && 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
Loading