wip: refactor pt.12, separate tek_snd

This commit is contained in:
🪞👃🪞 2024-11-10 22:24:58 +01:00
parent 47c9cd2fe8
commit 2be7aee002
28 changed files with 955 additions and 766 deletions

View file

@ -21,38 +21,6 @@ impl Debug for Transport {
}
}
impl Audio for Transport {
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
let times = scope.cycle_times().unwrap();
let CycleTimes { current_frames, current_usecs, next_usecs: _, period_usecs: _ } = times;
let _chunk_size = scope.n_frames() as usize;
let transport = self.transport.query().unwrap();
self.clock.current.sample.set(transport.pos.frame() as f64);
let mut playing = self.clock.playing.write().unwrap();
let mut started = self.clock.started.write().unwrap();
if *playing != Some(transport.state) {
match transport.state {
TransportState::Rolling => {
*started = Some((current_frames as usize, current_usecs as usize))
},
TransportState::Stopped => {
*started = None
},
_ => {}
}
};
*playing = Some(transport.state);
if *playing == Some(TransportState::Stopped) {
*started = None;
}
self.clock.current.update_from_usec(match *started {
Some((_, usecs)) => current_usecs as f64 - usecs as f64,
None => 0.
});
Control::Continue
}
}
impl Transport {
pub fn toggle_play (&mut self) -> Usually<()> {
let playing = self.clock.playing.read().unwrap().expect("1st sample has not been processed yet");