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

@ -1,25 +1,24 @@
(@up editor note-pos :note-pos-next)
(@down editor note-pos :note-pos-prev)
(@pgup editor note-pos :note-pos-next-octave)
(@pgdn editor note-pos :note-pos-prev-octave)
(@left editor set-time-pos :time-pos-prev)
(@right editor set-time-pos :time-pos-next)
(@comma editor note-len :note-len-prev)
(@period editor note-len :note-len-next)
(@lt editor note-len :note-len-prev)
(@gt editor note-len :note-len-next)
(@equal editor set-time-zoom :time-zoom-prev)
(@minus editor set-time-zoom :time-zoom-next)
(@plus editor set-time-zoom :time-zoom-next-fine)
(@underscore editor set-time-zoom :time-zoom-prev-fine)
(@plus editor note-range :note-range-next)
(@underscore editor note-range :note-range-prev)
(@z editor set-time-lock)
(@left editor time-pos :time-pos-prev)
(@right editor time-pos :time-pos-next)
(@up editor set-note-pos :note-pos-next)
(@down editor set-note-pos :note-pos-prev)
(@pgup editor set-note-pos :note-pos-next-octave)
(@pgdn editor set-note-pos :note-pos-prev-octave)
(@equal editor time-zoom :time-zoom-prev)
(@minus editor time-zoom :time-zoom-next)
(@comma editor set-note-len :note-len-prev)
(@period editor set-note-len :note-len-next)
(@lt editor set-note-len :note-len-prev)
(@gt editor set-note-len :note-len-next)
(@z editor time-lock)
(@enter editor note-put)
(@shift-enter editor note-append)
(@del editor note-del)
(@shift-del editor note-del)
(@a editor append-note :true)
(@enter editor append-note :false)
(@del editor delete-note)
(@shift-del editor delete-note)

View file

@ -280,7 +280,7 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
// update linked sampler after editor action
app.sampler_mut().map(|sampler|match command {
// autoselect: automatically select sample in sampler
MidiEditCommand::NotePos { pos } => { sampler.set_note_pos(pos); },
MidiEditCommand::SetNotePos { pos } => { sampler.set_note_pos(pos); },
_ => {}
});
undo

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;
}