mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-08-28 21:06:56 +02:00
This commit is contained in:
parent
ae496987c8
commit
7fcab73b04
12 changed files with 811 additions and 559 deletions
|
|
@ -20,6 +20,32 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
def_command!(ClockCommand: |clock: Clock| {
|
||||
SeekUsec { usec: f64 } => {
|
||||
clock.playhead.update_from_usec(*usec); Ok(None) },
|
||||
SeekSample { sample: f64 } => {
|
||||
clock.playhead.update_from_sample(*sample); Ok(None) },
|
||||
SeekPulse { pulse: f64 } => {
|
||||
clock.playhead.update_from_pulse(*pulse); Ok(None) },
|
||||
SetBpm { bpm: f64 } => Ok(Some(
|
||||
Self::SetBpm { bpm: clock.timebase().bpm.set(*bpm) })),
|
||||
SetQuant { quant: f64 } => Ok(Some(
|
||||
Self::SetQuant { quant: clock.quant.set(*quant) })),
|
||||
SetSync { sync: f64 } => Ok(Some(
|
||||
Self::SetSync { sync: clock.sync.set(*sync) })),
|
||||
|
||||
Play { position: Option<u32> } => {
|
||||
clock.play_from(*position)?; Ok(None) /* TODO Some(Pause(previousPosition)) */ },
|
||||
Pause { position: Option<u32> } => {
|
||||
clock.pause_at(*position)?; Ok(None) },
|
||||
|
||||
TogglePlayback { position: u32 } => Ok(if clock.is_rolling() {
|
||||
clock.pause_at(Some(*position))?; None
|
||||
} else {
|
||||
clock.play_from(Some(*position))?; None
|
||||
}),
|
||||
});
|
||||
|
||||
impl <T: AsRef<Clock>+AsMut<Clock>> HasClock for T {}
|
||||
pub trait HasClock: AsRef<Clock> + AsMut<Clock> {
|
||||
fn clock (&self) -> &Clock { self.as_ref() }
|
||||
|
|
@ -118,32 +144,6 @@ pub const NOTE_NAMES: [&str; 128] = [
|
|||
"C10", "C#10", "D10", "D#10", "E10", "F10", "F#10", "G10",
|
||||
];
|
||||
|
||||
def_command!(ClockCommand: |clock: Clock| {
|
||||
SeekUsec { usec: f64 } => {
|
||||
clock.playhead.update_from_usec(*usec); Ok(None) },
|
||||
SeekSample { sample: f64 } => {
|
||||
clock.playhead.update_from_sample(*sample); Ok(None) },
|
||||
SeekPulse { pulse: f64 } => {
|
||||
clock.playhead.update_from_pulse(*pulse); Ok(None) },
|
||||
SetBpm { bpm: f64 } => Ok(Some(
|
||||
Self::SetBpm { bpm: clock.timebase().bpm.set(*bpm) })),
|
||||
SetQuant { quant: f64 } => Ok(Some(
|
||||
Self::SetQuant { quant: clock.quant.set(*quant) })),
|
||||
SetSync { sync: f64 } => Ok(Some(
|
||||
Self::SetSync { sync: clock.sync.set(*sync) })),
|
||||
|
||||
Play { position: Option<u32> } => {
|
||||
clock.play_from(*position)?; Ok(None) /* TODO Some(Pause(previousPosition)) */ },
|
||||
Pause { position: Option<u32> } => {
|
||||
clock.pause_at(*position)?; Ok(None) },
|
||||
|
||||
TogglePlayback { position: u32 } => Ok(if clock.is_rolling() {
|
||||
clock.pause_at(Some(*position))?; None
|
||||
} else {
|
||||
clock.play_from(Some(*position))?; None
|
||||
}),
|
||||
});
|
||||
|
||||
impl LaunchSync {
|
||||
pub fn next (&self) -> f64 {
|
||||
note_duration_next(self.get() as usize) as f64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue