mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: refactor pt.4, reduce number of files
This commit is contained in:
parent
adf5b3f0f8
commit
8c37c95cc6
60 changed files with 2185 additions and 2187 deletions
|
|
@ -1,103 +0,0 @@
|
|||
use crate::*;
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum TransportCommand {
|
||||
FocusNext,
|
||||
FocusPrev,
|
||||
Play,
|
||||
Pause,
|
||||
PlayToggle,
|
||||
PlayFromStart,
|
||||
Increment,
|
||||
Decrement,
|
||||
FineIncrement,
|
||||
FineDecrement,
|
||||
SeekUsec(f64),
|
||||
SeekSample(f64),
|
||||
SeekPulse(f64),
|
||||
SetBpm(f64),
|
||||
SetQuant(f64),
|
||||
SetSync(f64),
|
||||
}
|
||||
impl<E: Engine> Command<TransportView<E>> for TransportCommand {
|
||||
fn translate (self, state: &TransportView<E>) -> Self {
|
||||
use TransportCommand::*;
|
||||
use TransportViewFocus::*;
|
||||
match self {
|
||||
Increment => match state.focus {
|
||||
Bpm =>
|
||||
{return SetBpm(state.clock.timebase().bpm.get() + 1.0) },
|
||||
Quant =>
|
||||
{return SetQuant(next_note_length(state.clock.quant.get()as usize)as f64)},
|
||||
Sync =>
|
||||
{return SetSync(next_note_length(state.clock.sync.get()as usize)as f64+1.)},
|
||||
PlayPause =>
|
||||
{/*todo seek*/},
|
||||
Clock =>
|
||||
{/*todo seek*/},
|
||||
},
|
||||
FineIncrement => match state.focus {
|
||||
Bpm =>
|
||||
{return SetBpm(state.clock.timebase().bpm.get() + 0.001)},
|
||||
Quant =>
|
||||
{return Increment},
|
||||
Sync =>
|
||||
{return Increment},
|
||||
PlayPause =>
|
||||
{/*todo seek*/},
|
||||
Clock =>
|
||||
{/*todo seek*/},
|
||||
},
|
||||
Decrement => match state.focus {
|
||||
Bpm =>
|
||||
{return SetBpm(state.clock.timebase().bpm.get() - 1.0)},
|
||||
Quant =>
|
||||
{return SetQuant(prev_note_length(state.clock.quant.get()as usize)as f64)},
|
||||
Sync =>
|
||||
{return SetSync(prev_note_length(state.clock.sync.get()as usize)as f64)},
|
||||
PlayPause =>
|
||||
{/*todo seek*/},
|
||||
Clock =>
|
||||
{/*todo seek*/},
|
||||
},
|
||||
FineDecrement => match state.focus {
|
||||
Bpm =>
|
||||
{return SetBpm(state.clock.timebase().bpm.get() - 0.001)},
|
||||
Quant =>
|
||||
{return Decrement},
|
||||
Sync =>
|
||||
{return Decrement},
|
||||
PlayPause =>
|
||||
{/*todo seek*/},
|
||||
Clock =>
|
||||
{/*todo seek*/},
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
return self
|
||||
}
|
||||
fn execute (self, state: &mut TransportView<E>) -> Perhaps<Self> {
|
||||
use TransportCommand::*;
|
||||
match self.translate(&state) {
|
||||
FocusNext =>
|
||||
{ state.focus.next(); },
|
||||
FocusPrev =>
|
||||
{ state.focus.prev(); },
|
||||
PlayToggle =>
|
||||
{ state.toggle_play()?; },
|
||||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue