mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
wip: f64 timebase (sloooo)
This commit is contained in:
parent
c4d8692b71
commit
4055662bbd
12 changed files with 206 additions and 142 deletions
|
|
@ -66,7 +66,7 @@ impl Sequencer {
|
|||
timebase: timebase.clone(),
|
||||
sequence: Some(0),
|
||||
phrases: phrases.unwrap_or_else(||vec![
|
||||
Phrase::new("Phrase0", 4*timebase.ppq() as u32, None)
|
||||
Phrase::new("Phrase0", 4 * timebase.ppq() as usize, None)
|
||||
]),
|
||||
|
||||
transport,
|
||||
|
|
@ -95,18 +95,13 @@ impl PortList for Sequencer {
|
|||
}
|
||||
fn render (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, width, height } = area;
|
||||
let pos = s.transport.query().unwrap().pos;
|
||||
let frame = pos.frame();
|
||||
let usecs = s.timebase.frame_to_usec(frame as usize);
|
||||
let ustep = s.timebase.usec_per_step(s.time_zoom as usize);
|
||||
let steps = usecs / ustep;
|
||||
let header = draw_header(s, buf, area, steps)?;
|
||||
let header = draw_header(s, buf, area)?;
|
||||
let piano = match s.view {
|
||||
SequencerView::Tiny => Rect { x, y, width, height: 0 },
|
||||
SequencerView::Compact => Rect { x, y, width, height: 0 },
|
||||
SequencerView::Vertical => self::vertical::draw(s, buf, Rect {
|
||||
x, y: y + header.height, width, height,
|
||||
}, steps)?,
|
||||
})?,
|
||||
SequencerView::Horizontal => self::horizontal::draw(s, buf, Rect {
|
||||
x, y: y + header.height, width, height,
|
||||
})?,
|
||||
|
|
@ -117,7 +112,7 @@ fn render (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
|||
height: header.height + piano.height
|
||||
}))
|
||||
}
|
||||
pub fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect, _: usize) -> Usually<Rect> {
|
||||
pub fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, width, .. } = area;
|
||||
let style = Style::default().gray();
|
||||
crate::device::transport::draw_play_stop(buf, x + 2, y + 1, &s.playing);
|
||||
|
|
@ -149,7 +144,7 @@ pub fn draw_clips (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect>
|
|||
}
|
||||
Ok(Rect { x, y, width: 14, height: 14 })
|
||||
}
|
||||
pub fn contains_note_on (sequence: &Phrase, k: u7, start: u32, end: u32) -> bool {
|
||||
pub fn contains_note_on (sequence: &Phrase, k: u7, start: usize, end: usize) -> bool {
|
||||
for (_, (_, events)) in sequence.notes.range(start..end).enumerate() {
|
||||
for event in events.iter() {
|
||||
match event {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue