wip: refactor pt.42 (84e) lotta todo!

This commit is contained in:
🪞👃🪞 2024-11-15 22:06:52 +01:00
parent bf0e14c252
commit 638298ad32
11 changed files with 536 additions and 335 deletions

View file

@ -19,16 +19,13 @@ impl<T: ClockApi> Command<T> for ClockCommand {
}
pub trait ClockApi: Send + Sync {
/// Current moment in time
fn current (&self) -> &Instant;
/// Temporal resolution in all units
fn timebase (&self) -> &Arc<Timebase>;
/// Note quantization factor
fn quant (&self) -> &Quantize;
fn quant (&self) -> &Quantize;
/// Launch quantization factor
fn sync (&self) -> &LaunchSync;
fn sync (&self) -> &LaunchSync;
fn timebase (&self) -> &Arc<Timebase> {
&self.current().timebase
}
fn sr (&self) -> &SampleRate {
&self.timebase().sr
}

View file

@ -5,7 +5,7 @@ pub trait HasPhrases {
fn phrases_mut (&mut self) -> &mut Vec<Arc<RwLock<Phrase>>>;
}
#[derive(Clone, PartialEq)]
#[derive(Clone, Debug)]
pub enum PhrasePoolCommand {
Add(usize),
Delete(usize),

View file

@ -27,7 +27,7 @@ pub trait HasMidiBuffer {
}
}
pub trait HasPhrase: ClockApi + PlayheadApi + HasMidiBuffer {
pub trait HasPhrase: PlayheadApi + HasMidiBuffer {
fn phrase (&self)
-> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)>;
fn phrase_mut (&self)

View file

@ -34,12 +34,24 @@ impl<T: PlayheadApi> Command<T> for PlayheadCommand {
}
pub trait PlayheadApi: ClockApi {
/// Current moment in time
fn current (&self) -> &Instant;
/// Handle to JACK transport
fn transport (&self) -> &jack::Transport;
/// Playback state
fn playing (&self) -> &RwLock<Option<TransportState>>;
/// Global sample and usec at which playback started
fn started (&self) -> &RwLock<Option<(usize, usize)>>;
fn is_stopped (&self) -> bool {
*self.playing().read().unwrap() == Some(TransportState::Stopped)
}
fn is_rolling (&self) -> bool {
*self.playing().read().unwrap() == Some(TransportState::Rolling)
}
/// Current pulse
fn pulse (&self) -> f64 {
self.current().pulse.get()
}
@ -67,13 +79,6 @@ pub trait PlayheadApi: ClockApi {
Ok(())
}
fn is_stopped (&self) -> bool {
*self.playing().read().unwrap() == Some(TransportState::Stopped)
}
fn is_rolling (&self) -> bool {
*self.playing().read().unwrap() == Some(TransportState::Rolling)
}
}
/// Hosts the JACK callback for updating the temporal pointer and playback status.