mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: PhraseLength widget
This commit is contained in:
parent
b9b4f5ff3a
commit
83dafe3e81
2 changed files with 74 additions and 0 deletions
|
|
@ -309,3 +309,43 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
self.overdub = !self.overdub;
|
||||
}
|
||||
}
|
||||
pub struct PhraseLength<E: Engine> {
|
||||
_engine: PhantomData<E>,
|
||||
pub ppq: usize,
|
||||
pub bpb: usize,
|
||||
pub pulses: usize,
|
||||
pub focused: bool,
|
||||
pub focus: PhraseLengthFocus
|
||||
}
|
||||
impl<E: Engine> PhraseLength<E> {
|
||||
fn new (pulses: usize) -> Self {
|
||||
Self {
|
||||
_engine: Default::default(),
|
||||
ppq: PPQ,
|
||||
bpb: 4,
|
||||
pulses,
|
||||
focused: false,
|
||||
focus: PhraseLengthFocus::Bar
|
||||
}
|
||||
}
|
||||
pub fn bars (&self) -> usize {
|
||||
self.pulses / (self.bpb * self.ppq)
|
||||
}
|
||||
pub fn beats (&self) -> usize {
|
||||
self.pulses % (self.bpb * self.ppq)
|
||||
}
|
||||
pub fn ticks (&self) -> usize {
|
||||
self.pulses % self.ppq
|
||||
}
|
||||
pub fn bars_string (&self) -> String {
|
||||
format!("{}", self.bars())
|
||||
}
|
||||
pub fn beats_string (&self) -> String {
|
||||
format!("{}", self.beats())
|
||||
}
|
||||
pub fn ticks_string (&self) -> String {
|
||||
format!("{}", self.ticks())
|
||||
}
|
||||
}
|
||||
#[derive(Copy,Clone)]
|
||||
pub enum PhraseLengthFocus { Bar, Beat, Tick }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue