mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
control transport values
This commit is contained in:
parent
33e5f47526
commit
45021bc77a
10 changed files with 168 additions and 86 deletions
|
|
@ -1,16 +1,43 @@
|
|||
use crate::core::*;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum TransportFocus {
|
||||
BPM,
|
||||
Quant,
|
||||
Sync,
|
||||
}
|
||||
|
||||
impl TransportFocus {
|
||||
pub fn prev (&mut self) {
|
||||
*self = match self {
|
||||
Self::BPM => Self::Sync,
|
||||
Self::Quant => Self::BPM,
|
||||
Self::Sync => Self::Quant,
|
||||
}
|
||||
}
|
||||
pub fn next (&mut self) {
|
||||
*self = match self {
|
||||
Self::BPM => Self::Quant,
|
||||
Self::Quant => Self::Sync,
|
||||
Self::Sync => Self::BPM,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TransportToolbar {
|
||||
pub metronome: bool,
|
||||
pub mode: bool,
|
||||
pub focused: bool,
|
||||
pub entered: bool,
|
||||
pub selected: TransportFocus,
|
||||
/// Current sample rate, tempo, and PPQ.
|
||||
pub timebase: Arc<Timebase>,
|
||||
/// JACK transport handle.
|
||||
transport: Option<Transport>,
|
||||
/// Quantization factor
|
||||
pub quant: usize,
|
||||
/// Global sync quant
|
||||
pub sync: usize,
|
||||
/// Current transport state
|
||||
pub playing: Option<TransportState>,
|
||||
/// Current position according to transport
|
||||
|
|
@ -21,17 +48,20 @@ pub struct TransportToolbar {
|
|||
|
||||
impl TransportToolbar {
|
||||
pub fn new (transport: Option<Transport>) -> Self {
|
||||
let timebase = Arc::new(Timebase::default());
|
||||
Self {
|
||||
transport,
|
||||
selected: TransportFocus::BPM,
|
||||
metronome: false,
|
||||
mode: false,
|
||||
focused: false,
|
||||
entered: false,
|
||||
timebase: Arc::new(Timebase::default()),
|
||||
playhead: 0,
|
||||
playing: Some(TransportState::Stopped),
|
||||
started: None,
|
||||
quant: 24,
|
||||
sync: timebase.ppq() as usize * 4,
|
||||
transport,
|
||||
timebase,
|
||||
}
|
||||
}
|
||||
pub fn toggle_play (&mut self) -> Usually<()> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue