mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
full block piano roll, pt.3
This commit is contained in:
parent
35c0470d15
commit
501e47cd85
1 changed files with 9 additions and 14 deletions
|
|
@ -307,29 +307,24 @@ impl PhraseViewMode {
|
|||
}
|
||||
/// Draw the piano roll using full blocks on note on and half blocks on legato: █▄ █▄ █▄
|
||||
fn draw_piano_horizontal (
|
||||
buffer: &mut BigBuffer, phrase: &Phrase, time_zoom: usize, _: usize
|
||||
target: &mut BigBuffer, phrase: &Phrase, time_zoom: usize, _: usize
|
||||
) {
|
||||
let mut notes_on = [false;128];
|
||||
for col in 0..buffer.width {
|
||||
let time_start = time_zoom * col;
|
||||
let time_end = time_zoom * (col + 1);
|
||||
for (x, time_start) in (0..phrase.length).step_by(time_zoom).enumerate() {
|
||||
let time_end = time_start + time_zoom;
|
||||
for time in time_start..time_end {
|
||||
for row in 0..buffer.height {
|
||||
let cell = buffer.get_mut(row, col).unwrap();
|
||||
if notes_on[row] {
|
||||
cell.set_char('▄');
|
||||
} else {
|
||||
cell.set_char(' ');
|
||||
}
|
||||
for (y, note) in (127..0).enumerate() {
|
||||
let cell = target.get_mut(x, y).unwrap();
|
||||
cell.set_fg(Color::Rgb(255, 255, 255));
|
||||
cell.set_bg(Color::Rgb(28, 35, 25));
|
||||
cell.set_char(if notes_on[note] { '▄' } else { '?' });
|
||||
}
|
||||
for event in phrase.notes[time].iter() {
|
||||
match event {
|
||||
MidiMessage::NoteOn { key, .. } => {
|
||||
let row = key.as_int() as usize;
|
||||
buffer.get_mut(row, col).unwrap().set_char('█');
|
||||
notes_on[row] = true
|
||||
let note = key.as_int() as usize;
|
||||
target.get_mut(x, 127 - note).unwrap().set_char('█');
|
||||
notes_on[note] = true
|
||||
},
|
||||
MidiMessage::NoteOff { key, .. } => {
|
||||
notes_on[key.as_int() as usize] = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue