From 6ee3abed8c3198b056e4a07ad24d63700b63e866 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sat, 14 Dec 2024 23:41:57 +0100 Subject: [PATCH] MIDI -> Midi --- crates/tek/src/api/note.rs | 18 +++++++++--------- crates/tek/src/tui/phrase_editor.rs | 8 ++++---- crates/tek/src/tui/piano_horizontal.rs | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/tek/src/api/note.rs b/crates/tek/src/api/note.rs index 8aa38330..e39d0024 100644 --- a/crates/tek/src/api/note.rs +++ b/crates/tek/src/api/note.rs @@ -1,7 +1,7 @@ use crate::*; use Ordering::Relaxed; -pub trait MIDIViewport: MIDIRange + MIDIPoint + HasSize { +pub trait MidiViewport: MidiRange + MidiPoint + HasSize { /// Make sure cursor is within range fn autoscroll (&self) { let note_lo = self.note_lo(); @@ -20,7 +20,7 @@ pub trait MIDIViewport: MIDIRange + MIDIPoint + HasSize { } #[derive(Debug, Clone)] -pub struct MIDIRangeModel { +pub struct MidiRangeModel { /// Length of visible time axis pub time_axis: Arc, /// Earliest time displayed @@ -34,7 +34,7 @@ pub struct MIDIRangeModel { // Lowest note displayed pub note_lo: Arc, } -impl From<(usize, bool)> for MIDIRangeModel { +impl From<(usize, bool)> for MidiRangeModel { fn from ((time_zoom, time_lock): (usize, bool)) -> Self { Self { note_axis: Arc::new(0.into()), @@ -46,7 +46,7 @@ impl From<(usize, bool)> for MIDIRangeModel { } } } -pub trait MIDIRange { +pub trait MidiRange { fn time_zoom (&self) -> usize; fn set_time_zoom (&self, x: usize); fn time_lock (&self) -> bool; @@ -58,7 +58,7 @@ pub trait MIDIRange { fn note_axis (&self) -> usize; fn note_hi (&self) -> usize { self.note_lo() + self.note_axis() } } -impl MIDIRange for MIDIRangeModel { +impl MidiRange for MidiRangeModel { fn time_zoom (&self) -> usize { self.time_zoom.load(Relaxed) } fn set_time_zoom (&self, x: usize) { self.time_zoom.store(x, Relaxed); } fn time_lock (&self) -> bool { self.time_lock.load(Relaxed) } @@ -71,7 +71,7 @@ impl MIDIRange for MIDIRangeModel { } #[derive(Debug, Clone)] -pub struct MIDIPointModel { +pub struct MidiPointModel { /// Time coordinate of cursor pub time_point: Arc, /// Note coordinate of cursor @@ -79,7 +79,7 @@ pub struct MIDIPointModel { /// Length of note that will be inserted, in pulses pub note_len: Arc, } -impl Default for MIDIPointModel { +impl Default for MidiPointModel { fn default () -> Self { Self { time_point: Arc::new(0.into()), @@ -88,7 +88,7 @@ impl Default for MIDIPointModel { } } } -pub trait MIDIPoint { +pub trait MidiPoint { fn note_len (&self) -> usize; fn set_note_len (&self, x: usize); fn note_point (&self) -> usize; @@ -97,7 +97,7 @@ pub trait MIDIPoint { fn set_time_point (&self, x: usize); fn note_end (&self) -> usize { self.note_point() + self.note_len() } } -impl MIDIPoint for MIDIPointModel { +impl MidiPoint for MidiPointModel { fn note_len (&self) -> usize { self.note_len.load(Relaxed)} fn set_note_len (&self, x: usize) { self.note_len.store(x, Relaxed) } fn note_point (&self) -> usize { self.note_point.load(Relaxed) } diff --git a/crates/tek/src/tui/phrase_editor.rs b/crates/tek/src/tui/phrase_editor.rs index 92efbcc5..5caf119e 100644 --- a/crates/tek/src/tui/phrase_editor.rs +++ b/crates/tek/src/tui/phrase_editor.rs @@ -117,7 +117,7 @@ impl Default for PhraseEditorModel { render!(|self: PhraseEditorModel|self.mode); -pub trait PhraseViewMode: Render + HasSize + MIDIRange + MIDIPoint + Debug + Send + Sync { +pub trait PhraseViewMode: Render + HasSize + MidiRange + MidiPoint + Debug + Send + Sync { fn buffer_size (&self, phrase: &Phrase) -> (usize, usize); fn redraw (&mut self); fn phrase (&self) -> &Option>>; @@ -128,11 +128,11 @@ pub trait PhraseViewMode: Render + HasSize + MIDIRange + MIDIPoint + D } } -impl MIDIViewport for PhraseEditorModel {} +impl MidiViewport for PhraseEditorModel {} has_size!(|self:PhraseEditorModel|self.mode.size()); -impl MIDIRange for PhraseEditorModel { +impl MidiRange for PhraseEditorModel { fn time_zoom (&self) -> usize { self.mode.time_zoom() } fn set_time_zoom (&self, x: usize) { self.mode.set_time_zoom(x); } fn time_lock (&self) -> bool { self.mode.time_lock() } @@ -144,7 +144,7 @@ impl MIDIRange for PhraseEditorModel { fn note_axis (&self) -> usize { self.mode.note_lo() } fn note_hi (&self) -> usize { self.note_lo() + self.note_axis() } } -impl MIDIPoint for PhraseEditorModel { +impl MidiPoint for PhraseEditorModel { fn note_len (&self) -> usize { self.mode.note_len()} fn set_note_len (&self, x: usize) { self.mode.set_note_len(x) } fn note_point (&self) -> usize { self.mode.note_point() } diff --git a/crates/tek/src/tui/piano_horizontal.rs b/crates/tek/src/tui/piano_horizontal.rs index 5cabba28..38516249 100644 --- a/crates/tek/src/tui/piano_horizontal.rs +++ b/crates/tek/src/tui/piano_horizontal.rs @@ -9,9 +9,9 @@ pub struct PianoHorizontal { /// Width and height of notes area at last render size: Measure, /// The display window - range: MIDIRangeModel, + range: MidiRangeModel, /// The note cursor - point: MIDIPointModel, + point: MidiPointModel, /// The highlight color palette color: ItemPalette, } @@ -19,7 +19,7 @@ pub struct PianoHorizontal { impl PianoHorizontal { pub fn new (phrase: Option<&Arc>>) -> Self { let size = Measure::new(); - let mut range = MIDIRangeModel::from((24, true)); + let mut range = MidiRangeModel::from((24, true)); range.time_axis = size.x.clone(); range.note_axis = size.y.clone(); let phrase = phrase.map(|p|p.clone()); @@ -28,7 +28,7 @@ impl PianoHorizontal { .unwrap_or(ItemPalette::from(ItemColor::from(TuiTheme::g(64)))); Self { buffer: Default::default(), - point: MIDIPointModel::default(), + point: MidiPointModel::default(), size, range, phrase, @@ -243,7 +243,7 @@ impl PianoHorizontal { has_size!(|self:PianoHorizontal|&self.size); -impl MIDIRange for PianoHorizontal { +impl MidiRange for PianoHorizontal { fn time_zoom (&self) -> usize { self.range.time_zoom() } fn set_time_zoom (&self, x: usize) { self.range.set_time_zoom(x); } fn time_lock (&self) -> bool { self.range.time_lock() } @@ -255,7 +255,7 @@ impl MIDIRange for PianoHorizontal { fn note_axis (&self) -> usize { self.range.note_lo() } fn note_hi (&self) -> usize { self.note_lo() + self.note_axis() } } -impl MIDIPoint for PianoHorizontal { +impl MidiPoint for PianoHorizontal { fn note_len (&self) -> usize { self.point.note_len()} fn set_note_len (&self, x: usize) { self.point.set_note_len(x) } fn note_point (&self) -> usize { self.point.note_point() }