full block piano roll, pt.3

This commit is contained in:
🪞👃🪞 2024-12-04 01:00:05 +01:00
parent 35c0470d15
commit 501e47cd85

View file

@ -307,29 +307,24 @@ impl PhraseViewMode {
} }
/// Draw the piano roll using full blocks on note on and half blocks on legato: █▄ █▄ █▄ /// Draw the piano roll using full blocks on note on and half blocks on legato: █▄ █▄ █▄
fn draw_piano_horizontal ( 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]; let mut notes_on = [false;128];
for col in 0..buffer.width { for (x, time_start) in (0..phrase.length).step_by(time_zoom).enumerate() {
let time_start = time_zoom * col; let time_end = time_start + time_zoom;
let time_end = time_zoom * (col + 1);
for time in time_start..time_end { for time in time_start..time_end {
for row in 0..buffer.height { for (y, note) in (127..0).enumerate() {
let cell = buffer.get_mut(row, col).unwrap(); let cell = target.get_mut(x, y).unwrap();
if notes_on[row] {
cell.set_char('▄');
} else {
cell.set_char(' ');
}
cell.set_fg(Color::Rgb(255, 255, 255)); cell.set_fg(Color::Rgb(255, 255, 255));
cell.set_bg(Color::Rgb(28, 35, 25)); cell.set_bg(Color::Rgb(28, 35, 25));
cell.set_char(if notes_on[note] { '▄' } else { '?' });
} }
for event in phrase.notes[time].iter() { for event in phrase.notes[time].iter() {
match event { match event {
MidiMessage::NoteOn { key, .. } => { MidiMessage::NoteOn { key, .. } => {
let row = key.as_int() as usize; let note = key.as_int() as usize;
buffer.get_mut(row, col).unwrap().set_char('█'); target.get_mut(x, 127 - note).unwrap().set_char('█');
notes_on[row] = true notes_on[note] = true
}, },
MidiMessage::NoteOff { key, .. } => { MidiMessage::NoteOff { key, .. } => {
notes_on[key.as_int() as usize] = false notes_on[key.as_int() as usize] = false