Change single branch match to if let
This commit is contained in:
parent
1fbcd583a4
commit
3ffc2f0604
|
@ -249,58 +249,53 @@ impl Plugin for PolyModSynth {
|
||||||
normalized_offset,
|
normalized_offset,
|
||||||
} => {
|
} => {
|
||||||
// Polyphonic modulation events are matched to voices using the
|
// Polyphonic modulation events are matched to voices using the
|
||||||
// voice ID, and to parameters using the poly modulation ID
|
// voice ID, and to parameters using the poly modulation ID. The
|
||||||
match self.get_voice_idx(voice_id) {
|
// host will probably send a modulation event every N samples. This
|
||||||
Some(voice_idx) => {
|
// will happen before the voice is active, and of course also after
|
||||||
let voice = self.voices[voice_idx].as_mut().unwrap();
|
// it has been terminated (because the host doesn't know that it
|
||||||
|
// will be). Because of that, we won't print any assertion failures
|
||||||
|
// when we can't find the voice index here.
|
||||||
|
if let Some(voice_idx) = self.get_voice_idx(voice_id) {
|
||||||
|
let voice = self.voices[voice_idx].as_mut().unwrap();
|
||||||
|
|
||||||
match poly_modulation_id {
|
match poly_modulation_id {
|
||||||
GAIN_POLY_MOD_ID => {
|
GAIN_POLY_MOD_ID => {
|
||||||
// This should either create a smoother for this
|
// This should either create a smoother for this
|
||||||
// modulated parameter or update the existing one.
|
// modulated parameter or update the existing one.
|
||||||
// Notice how this uses the parameter's unmodulated
|
// Notice how this uses the parameter's unmodulated
|
||||||
// normalized value in combination with the normalized
|
// normalized value in combination with the normalized
|
||||||
// offset to create the target plain value
|
// offset to create the target plain value
|
||||||
let target_plain_value = self
|
let target_plain_value = self
|
||||||
.params
|
.params
|
||||||
.gain
|
.gain
|
||||||
.preview_modulated(normalized_offset);
|
.preview_modulated(normalized_offset);
|
||||||
let (_, smoother) =
|
let (_, smoother) =
|
||||||
voice.voice_gain.get_or_insert_with(|| {
|
voice.voice_gain.get_or_insert_with(|| {
|
||||||
(
|
(
|
||||||
normalized_offset,
|
normalized_offset,
|
||||||
self.params.gain.smoothed.clone(),
|
self.params.gain.smoothed.clone(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
// If this `PolyModulation` events happens on the
|
// If this `PolyModulation` events happens on the
|
||||||
// same sample as a voice's `NoteOn` event, then it
|
// same sample as a voice's `NoteOn` event, then it
|
||||||
// should immediately use the modulated value
|
// should immediately use the modulated value
|
||||||
// instead of slowly fading in
|
// instead of slowly fading in
|
||||||
if voice.internal_voice_id
|
if voice.internal_voice_id
|
||||||
>= this_sample_internal_voice_id_start
|
>= this_sample_internal_voice_id_start
|
||||||
{
|
{
|
||||||
smoother.reset(target_plain_value);
|
smoother.reset(target_plain_value);
|
||||||
} else {
|
} else {
|
||||||
smoother.set_target(
|
smoother
|
||||||
sample_rate,
|
.set_target(sample_rate, target_plain_value);
|
||||||
target_plain_value,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
n => nih_debug_assert_failure!(
|
|
||||||
"Polyphonic modulation sent for unknown poly \
|
|
||||||
modulation ID {}",
|
|
||||||
n
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
n => nih_debug_assert_failure!(
|
||||||
|
"Polyphonic modulation sent for unknown poly \
|
||||||
|
modulation ID {}",
|
||||||
|
n
|
||||||
|
),
|
||||||
}
|
}
|
||||||
// The host will probably send a modulation event every N
|
|
||||||
// samples. This will happen before the voice is active, and of
|
|
||||||
// course also after it has been terminated (because the host
|
|
||||||
// doesn't know that it will be). Because of that, we won't
|
|
||||||
// print any assertion failures here.
|
|
||||||
None => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NoteEvent::MonoAutomation {
|
NoteEvent::MonoAutomation {
|
||||||
|
|
Loading…
Reference in a new issue