mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
refactor: reuse horizontal::draw
This commit is contained in:
parent
91832e0072
commit
939ffe3630
6 changed files with 130 additions and 117 deletions
|
|
@ -102,9 +102,18 @@ fn render (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
|||
SequencerView::Vertical => self::vertical::draw(s, buf, Rect {
|
||||
x, y: y + header.height, width, height,
|
||||
})?,
|
||||
SequencerView::Horizontal => self::horizontal::draw(s, buf, Rect {
|
||||
x, y: y + header.height, width, height,
|
||||
})?,
|
||||
SequencerView::Horizontal => self::horizontal::draw(
|
||||
buf,
|
||||
Rect { x, y: y + header.height, width, height, },
|
||||
s.phrase(),
|
||||
s.timebase.ppq() as usize,
|
||||
s.time_cursor,
|
||||
s.time_start,
|
||||
s.time_zoom,
|
||||
s.note_cursor,
|
||||
s.note_start,
|
||||
None
|
||||
)?,
|
||||
};
|
||||
Ok(draw_box(buf, Rect {
|
||||
x, y,
|
||||
|
|
@ -159,37 +168,3 @@ pub fn contains_note_on (sequence: &Phrase, k: u7, start: usize, end: usize) ->
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
#[cfg(test)] mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_sequencer_output () -> Usually<()> {
|
||||
let sequencer = Sequencer::new("test")?;
|
||||
let mut s = sequencer.state.lock().unwrap();
|
||||
s.rate = Hz(48000);
|
||||
s.tempo = Tempo(240_000);
|
||||
println!("F/S = {:.03}", s.rate());
|
||||
println!("B/S = {:.03}", s.beats_per_secon());
|
||||
println!("F/B = {:.03}", s.frames_per_beat());
|
||||
println!("T/B = {:.03}", s.ticks_per_beat());
|
||||
println!("F/T = {:.03}", s.frames_per_tick());
|
||||
println!("F/L = {:.03}", s.frames_per_loop());
|
||||
println!("T/L = {:.03}", s.ticks_per_loop());
|
||||
let fpt = s.fpt();
|
||||
let frames_per_chunk = 240;
|
||||
let chunk = |chunk: usize| s.frames_to_ticks(
|
||||
chunk * frames_per_chunk,
|
||||
(chunk + 1) * frames_per_chunk
|
||||
);
|
||||
//for i in 0..2000 {
|
||||
//println!("{i} {:?}", chunk(i));
|
||||
//}
|
||||
assert_eq!(chunk(0), vec![(0, 0), (125, 1)]);
|
||||
assert_eq!(chunk(1), vec![(10, 2), (135, 3)]);
|
||||
assert_eq!(chunk(12), vec![(120, 24)]);
|
||||
assert_eq!(chunk(412), vec![(120, 24)]);
|
||||
assert_eq!(chunk(413), vec![(5, 25), (130, 26)]);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue