editor: add note and advance; preparations

This commit is contained in:
🪞👃🪞 2025-05-11 04:01:23 +03:00
parent e00d870d70
commit 85a144798b
4 changed files with 47 additions and 45 deletions

View file

@ -4,12 +4,6 @@ use crate::*;
fn _todo_opt_clip_stub (&self) -> Option<Arc<RwLock<MidiClip>>> {
todo!()
}
fn time_lock (&self) -> bool {
self.get_time_lock()
}
fn time_lock_toggled (&self) -> bool {
!self.get_time_lock()
}
fn note_length (&self) -> usize {
self.get_note_len()
@ -55,10 +49,10 @@ use crate::*;
self.get_time_pos()
}
fn time_pos_next (&self) -> usize {
self.get_time_pos() + self.time_zoom()
self.get_time_pos() + self.get_note_len()
}
fn time_pos_prev (&self) -> usize {
self.get_time_pos().saturating_sub(self.time_zoom())
self.get_time_pos().saturating_sub(self.get_note_len())
}
fn time_zoom (&self) -> usize {
@ -67,29 +61,37 @@ use crate::*;
fn time_zoom_next (&self) -> usize {
self.get_time_zoom() + 1
}
fn time_zoom_next_fine (&self) -> usize {
self.get_time_zoom() + 1
}
fn time_zoom_prev (&self) -> usize {
self.get_time_zoom().saturating_sub(1).max(1)
}
fn time_zoom_prev_fine (&self) -> usize {
self.get_time_zoom().saturating_sub(1).max(1)
}
fn time_lock (&self) -> bool {
self.get_time_lock()
}
fn time_lock_toggled (&self) -> bool {
!self.get_time_lock()
}
}
#[tengri_proc::command(MidiEditor)] impl MidiEditCommand {
// TODO: 1-9 seek markers that by default start every 8th of the clip
fn note_append (editor: &mut MidiEditor) -> Perhaps<Self> {
editor.put_note(true);
fn append_note (editor: &mut MidiEditor, advance: bool) -> Perhaps<Self> {
editor.put_note(advance);
Ok(None)
}
fn note_put (editor: &mut MidiEditor) -> Perhaps<Self> {
editor.put_note(false);
Ok(None)
}
fn note_del (_editor: &mut MidiEditor) -> Perhaps<Self> {
fn delete_note (_editor: &mut MidiEditor) -> Perhaps<Self> {
todo!()
}
fn note_pos (editor: &mut MidiEditor, pos: usize) -> Perhaps<Self> {
fn set_note_pos (editor: &mut MidiEditor, pos: usize) -> Perhaps<Self> {
editor.set_note_pos(pos.min(127));
Ok(None)
}
fn note_len (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
fn set_note_len (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
//let note_len = editor.get_note_len();
//let time_zoom = editor.get_time_zoom();
editor.set_note_len(value);
@ -98,24 +100,24 @@ use crate::*;
//}
Ok(None)
}
fn note_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
fn set_note_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
editor.set_note_lo(value.min(127));
Ok(None)
}
fn time_pos (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
fn set_time_pos (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
editor.set_time_pos(value);
Ok(None)
}
fn time_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
fn set_time_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
editor.set_time_start(value);
Ok(None)
}
fn time_zoom (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
fn set_time_zoom (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
editor.set_time_zoom(value);
editor.redraw();
Ok(None)
}
fn time_lock (editor: &mut MidiEditor, value: bool) -> Perhaps<Self> {
fn set_time_lock (editor: &mut MidiEditor, value: bool) -> Perhaps<Self> {
editor.set_time_lock(value);
Ok(None)
}
@ -123,4 +125,5 @@ use crate::*;
editor.set_clip(clip.as_ref());
Ok(None)
}
// TODO: 1-9 seek markers that by default start every 8th of the clip
}

View file

@ -61,7 +61,7 @@ impl MidiEditor {
clip.notes[note_end].push(note_off);
}
if advance {
self.set_time_pos(note_end);
self.set_time_pos(note_end + 1);
}
redraw = true;
}