1
0
Fork 0

Replace sine loop

This commit is contained in:
Robbert van der Helm 2022-04-11 18:24:07 +02:00
parent 8219d5f2b8
commit 97b2c9a2b1

View file

@ -147,25 +147,26 @@ impl Plugin for Sine {
// This plugin can be either triggered by MIDI or controleld by a parameter // This plugin can be either triggered by MIDI or controleld by a parameter
let sine = if self.params.use_midi.value { let sine = if self.params.use_midi.value {
// Act on the next MIDI event // Act on the next MIDI event
'midi_events: loop { while let Some(event) = next_event {
match next_event { if event.timing() != sample_id as u32 {
Some(event) if event.timing() == sample_id as u32 => match event { break;
NoteEvent::NoteOn { note, velocity, .. } => { }
self.midi_note_id = note;
self.midi_note_freq = util::midi_note_to_freq(note); match event {
self.midi_note_gain.set_target(self.sample_rate, velocity); NoteEvent::NoteOn { note, velocity, .. } => {
} self.midi_note_id = note;
NoteEvent::NoteOff { note, .. } if note == self.midi_note_id => { self.midi_note_freq = util::midi_note_to_freq(note);
self.midi_note_gain.set_target(self.sample_rate, 0.0); self.midi_note_gain.set_target(self.sample_rate, velocity);
} }
NoteEvent::PolyPressure { note, pressure, .. } NoteEvent::NoteOff { note, .. } if note == self.midi_note_id => {
if note == self.midi_note_id => self.midi_note_gain.set_target(self.sample_rate, 0.0);
{ }
self.midi_note_gain.set_target(self.sample_rate, pressure); NoteEvent::PolyPressure { note, pressure, .. }
} if note == self.midi_note_id =>
_ => (), {
}, self.midi_note_gain.set_target(self.sample_rate, pressure);
_ => break 'midi_events, }
_ => (),
} }
next_event = context.next_event(); next_event = context.next_event();