wip: refactor pt.30: 74 errors

This commit is contained in:
🪞👃🪞 2024-11-14 22:34:44 +01:00
parent ab85a86b6b
commit 28e15d3f56
12 changed files with 631 additions and 622 deletions

View file

@ -65,3 +65,33 @@ impl TransportModel {
Ok(())
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum TransportCommand {
Play(Option<usize>),
Pause(Option<usize>),
SeekUsec(f64),
SeekSample(f64),
SeekPulse(f64),
SetBpm(f64),
SetQuant(f64),
SetSync(f64),
}
impl<T: TransportModelApi> Command<T> for TransportCommand {
fn execute (self, state: &mut T) -> Perhaps<Self> {
use TransportCommand::*;
match self {
Play(start) => {todo!()},
Pause(start) => {todo!()},
SeekUsec(usec) => {state.clock().current.update_from_usec(usec);},
SeekSample(sample) => {state.clock().current.update_from_sample(sample);},
SeekPulse(pulse) => {state.clock().current.update_from_pulse(pulse);},
SetBpm(bpm) => {return Ok(Some(Self::SetBpm(state.clock().timebase().bpm.set(bpm))))},
SetQuant(quant) => {return Ok(Some(Self::SetQuant(state.clock().quant.set(quant))))},
SetSync(sync) => {return Ok(Some(Self::SetSync(state.clock().sync.set(sync))))},
_ => { unreachable!() }
}
Ok(None)
}
}