wrap note end and post-add advance

This commit is contained in:
🪞👃🪞 2024-10-23 20:50:26 +03:00
parent 35599c6cde
commit ecbbef22b5
2 changed files with 5 additions and 2 deletions

View file

@ -127,7 +127,8 @@ impl Handle<Tui> for PhraseEditor<Tui> {
}, },
key!(KeyCode::Char('a')) => if self.entered { key!(KeyCode::Char('a')) => if self.entered {
self.put(); self.put();
self.time_axis.point = self.time_axis.point.map(|time|{time + self.note_len}); self.time_axis.point = self.time_axis.point.map(|time|(time + self.note_len)
% self.phrase.as_ref().map(|p|p.read().unwrap().length).unwrap_or(1));
}, },
key!(KeyCode::Char('s')) => if self.entered { key!(KeyCode::Char('s')) => if self.entered {
self.put(); self.put();

View file

@ -165,8 +165,10 @@ impl<E: Engine> PhraseEditor<E> {
let mut phrase = phrase.write().unwrap(); let mut phrase = phrase.write().unwrap();
let key: u7 = u7::from((127 - note) as u8); let key: u7 = u7::from((127 - note) as u8);
let vel: u7 = 100.into(); let vel: u7 = 100.into();
let start = time;
let end = (start + self.note_len) % phrase.length;
phrase.notes[time].push(MidiMessage::NoteOn { key, vel }); phrase.notes[time].push(MidiMessage::NoteOn { key, vel });
phrase.notes[time + self.note_len].push(MidiMessage::NoteOff { key, vel }); phrase.notes[end].push(MidiMessage::NoteOff { key, vel });
self.buffer = Self::redraw(&phrase); self.buffer = Self::redraw(&phrase);
} }
} }