| 627 | } |
| 628 | } |
| 629 | |
| 630 | fn process_controls(&mut self) { |
| 631 | while let Ok(cmd) = self.rx.try_recv() { |
| 632 | match cmd { |
| 633 | MidiMixerControl::Note(note) => self.push_voice(note), |
| 634 | MidiMixerControl::Release { id } => { |
| 635 | if let Some(index) = self.voice_index.get(&id).copied() |
| 636 | && let Some(voice) = self.voices.get_mut(index) |
| 637 | { |
| 638 | voice.release(); |
| 639 | } |
| 640 | } |
| 641 | MidiMixerControl::Stop => self.stopped = true, |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | fn push_voice(&mut self, note: MidiMixerNote) { |
| 647 | if self.voices.len() >= BUILT_IN_MIXER_MAX_VOICES { |
| 648 | self.remove_voice_at(0); |