support multiple midi ins in PhrasePlayer::process

This commit is contained in:
🪞👃🪞 2024-10-31 23:50:16 +02:00
parent 325492ec42
commit 02f691c494
3 changed files with 51 additions and 66 deletions

View file

@ -423,7 +423,7 @@ impl<E: Engine> PhrasePlayer<E> {
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }
pub fn toggle_record (&mut self) { self.recording = !self.recording; }
pub fn toggle_overdub (&mut self) { self.overdub = !self.overdub; }
pub fn enqueue_next (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
pub fn enqueue_next (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
let start = self.clock.next_launch_pulse();
self.next_phrase = Some((start.into(), phrase.map(|p|p.clone())));
self.reset = true;
@ -433,6 +433,21 @@ impl<E: Engine> PhrasePlayer<E> {
.map(|(started,_)|started.load(Ordering::Relaxed))
.map(|started|started - self.clock.sample())
}
pub fn playing_phrase (&self) -> Option<(usize, Arc<RwLock<Phrase>>)> {
if let (
Some(TransportState::Rolling),
Some((start_frame, _)),
Some((_started, Some(ref phrase)))
) = (
*self.clock.playing.read().unwrap(),
self.started,
&self.phrase
) {
Some((start_frame, phrase.clone()))
} else {
None
}
}
}
/// Displays and edits phrase length
pub struct PhraseLength<E: Engine> {