Skip to content

Commit

Permalink
Hook up legato mode from the voice manager (#1450)
Browse files Browse the repository at this point in the history
This implements legato mode from the voice manager with the
restart and restart-retrigger modes intact. Critically voice
glide is not in place so its a bit odd but does what you want.
  • Loading branch information
baconpaul authored Nov 19, 2024
1 parent 873d869 commit ba17b04
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src-ui/app/edit-screen/components/GroupSettingsCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ void GroupSettingsCard::rebuildFromInfo()
if (info.vmPlayModeInt == (int32_t)engine::Engine::voiceManager_t::PlayMode::MONO_NOTES)
{
polyMenu->setEnabled(false);
polyModeMenu->setLabel("MONO");
if (info.vmPlayModeFeaturesInt &
(int32_t)engine::Engine::voiceManager_t::MonoPlayModeFeatures::MONO_LEGATO)
{
polyModeMenu->setLabel("LEG");
}
else
{
polyModeMenu->setLabel("MONO");
}
repaint();
}
else
Expand Down Expand Up @@ -232,9 +240,15 @@ void GroupSettingsCard::showPolyModeMenu()
w->rebuildFromInfo();
w->sendToSerialization(messaging::client::UpdateGroupOutputInfoPolyphony{w->info});
});
p.addItem("Legato", false, false, [w = juce::Component::SafePointer(this)]() {
p.addItem("Legato", true, false, [w = juce::Component::SafePointer(this)]() {
if (!w)
return;
w->info.vmPlayModeInt = (uint32_t)engine::Engine::voiceManager_t::PlayMode::MONO_NOTES;
w->info.vmPlayModeFeaturesInt =
(uint64_t)engine::Engine::voiceManager_t::MonoPlayModeFeatures::NATURAL_LEGATO;

w->rebuildFromInfo();
w->sendToSerialization(messaging::client::UpdateGroupOutputInfoPolyphony{w->info});
});
p.addSeparator();
p.addSectionHeader("Mono Release Priority");
Expand Down
6 changes: 5 additions & 1 deletion src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,12 @@ struct Engine : MoveableOnly<Engine>, SampleRateSupport
void terminateVoice(voice::Voice *v);
void retriggerVoiceWithNewNoteID(voice::Voice *v, int32_t noteid, float velocity)
{
SCLOG("Retrigger Voice Unimplemented")
SCLOG("Retrigger Voice Unimplemented");
assert(false);
}
void moveVoice(typename VMConfig::voice_t *, uint16_t, uint16_t, uint16_t, float);
void moveAndRetriggerVoice(typename VMConfig::voice_t *, uint16_t, uint16_t, uint16_t,
float);

void setVoiceMIDIMPEChannelPitchBend(voice::Voice *v, uint16_t pb14bit);
void setVoiceMIDIMPEChannelPressure(voice::Voice *v, int8_t val);
Expand Down
28 changes: 28 additions & 0 deletions src/engine/engine_voice_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,34 @@ void Engine::VoiceManagerResponder::setVoiceMIDIMPETimbre(voice::Voice *v, int8_
v->mpeTimbre = val / 127.0;
}

void Engine::VoiceManagerResponder::moveVoice(VMConfig::voice_t *v, uint16_t port, uint16_t channel,
uint16_t key, float vel)
{
auto dkey = v->key - v->originalMidiKey;
v->key = key;
v->originalMidiKey = key - dkey;
v->calculateVoicePitch();
}

void Engine::VoiceManagerResponder::moveAndRetriggerVoice(VMConfig::voice_t *v, uint16_t port,
uint16_t channel, uint16_t key, float vel)
{
auto dkey = v->key - v->originalMidiKey;
v->key = key;
v->originalMidiKey = key - dkey;
v->calculateVoicePitch();
v->isGated = true;
for (auto &eg : v->eg)
{
eg.attackFrom(eg.outBlock0);
}
for (auto &eg : v->egOS)
{
eg.attackFrom(eg.outBlock0);
}
SCLOG("TODO - Gate voice and Retrigger AEG and EG2");
}

void Engine::MonoVoiceManagerResponder::setMIDIPitchBend(int16_t channel, int16_t pb14bit)
{
auto fv = (pb14bit - 8192) / 8192.f;
Expand Down

0 comments on commit ba17b04

Please sign in to comment.