wip: refactor pt.8, 512 errors lol

This commit is contained in:
🪞👃🪞 2024-11-10 15:40:45 +01:00
parent a1818a8504
commit a784f7a6f2
19 changed files with 238 additions and 183 deletions

View file

@ -10,6 +10,17 @@ pub struct Transport {
pub metronome: bool,
}
impl Debug for Transport {
fn fmt (&self, f: &mut Formatter<'_>) -> std::result::Result<(), Error> {
f.debug_struct("transport")
.field("jack", &self.jack)
.field("transport", &"(JACK transport)")
.field("clock", &self.clock)
.field("metronome", &self.metronome)
.finish()
}
}
impl Audio for Transport {
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
let times = scope.cycle_times().unwrap();
@ -41,3 +52,22 @@ impl Audio for Transport {
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");
let playing = match playing {
TransportState::Stopped => {
self.transport.start()?;
Some(TransportState::Starting)
},
_ => {
self.transport.stop()?;
self.transport.locate(0)?;
Some(TransportState::Stopped)
},
};
*self.clock.playing.write().unwrap() = playing;
Ok(())
}
}