From 076be5bcb3f248321b74fc823c3400dcd562ed20 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 1 Nov 2024 00:28:08 +0200 Subject: [PATCH] more weird formatting --- crates/tek_sequencer/src/sequencer.rs | 58 ++++++--------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/crates/tek_sequencer/src/sequencer.rs b/crates/tek_sequencer/src/sequencer.rs index be6cf235..c3480033 100644 --- a/crates/tek_sequencer/src/sequencer.rs +++ b/crates/tek_sequencer/src/sequencer.rs @@ -217,15 +217,12 @@ impl PhrasePool { } pub fn begin_rename (&mut self) { self.mode = Some(PhrasePoolMode::Rename( - self.phrase, - self.phrases[self.phrase].read().unwrap().name.clone() + self.phrase, self.phrases[self.phrase].read().unwrap().name.clone() )); } pub fn begin_length (&mut self) { self.mode = Some(PhrasePoolMode::Length( - self.phrase, - self.phrases[self.phrase].read().unwrap().length, - PhraseLengthFocus::Bar + self.phrase, self.phrases[self.phrase].read().unwrap().length, PhraseLengthFocus::Bar )); } pub fn move_up (&mut self) { @@ -273,20 +270,12 @@ impl PhraseEditor { pub fn note_cursor_inc (&self) { let mut axis = self.note_axis.write().unwrap(); axis.point_dec(1); - if let Some(point) = axis.point { - if point < axis.start { - axis.start = (point / 2) * 2; - } - } + if let Some(point) = axis.point { if point < axis.start { axis.start = (point / 2) * 2; } } } pub fn note_cursor_dec (&self) { let mut axis = self.note_axis.write().unwrap(); axis.point_inc(1); - if let Some(point) = axis.point { - if point > 73 { - axis.point = Some(73); - } - } + if let Some(point) = axis.point { if point > 73 { axis.point = Some(73); } } } pub fn note_page_up (&self) { let mut axis = self.note_axis.write().unwrap(); @@ -298,18 +287,10 @@ impl PhraseEditor { axis.start_inc(3); axis.point_inc(3); } - pub fn note_scroll_inc (&self) { - self.note_axis.write().unwrap().start_dec(1); - } - pub fn note_scroll_dec (&self) { - self.note_axis.write().unwrap().start_inc(1); - } - pub fn note_length_inc (&mut self) { - self.note_len = next_note_length(self.note_len) - } - pub fn note_length_dec (&mut self) { - self.note_len = prev_note_length(self.note_len) - } + pub fn note_scroll_inc (&self) { self.note_axis.write().unwrap().start_dec(1); } + pub fn note_scroll_dec (&self) { self.note_axis.write().unwrap().start_inc(1); } + pub fn note_length_inc (&mut self) { self.note_len = next_note_length(self.note_len) } + pub fn note_length_dec (&mut self) { self.note_len = prev_note_length(self.note_len) } pub fn time_cursor_advance (&self) { let point = self.time_axis.read().unwrap().point; let length = self.phrase.as_ref().map(|p|p.read().unwrap().length).unwrap_or(1); @@ -367,13 +348,9 @@ impl Phrase { clone.uuid = uuid::Uuid::new_v4(); clone } - pub fn toggle_loop (&mut self) { - self.loop_on = !self.loop_on; - } + pub fn toggle_loop (&mut self) { self.loop_on = !self.loop_on; } pub fn record_event (&mut self, pulse: usize, message: MidiMessage) { - if pulse >= self.length { - panic!("extend phrase first") - } + if pulse >= self.length { panic!("extend phrase first") } self.notes[pulse].push(message); } /// Check if a range `start..end` contains MIDI Note On `k` @@ -381,14 +358,7 @@ impl Phrase { //panic!("{:?} {start} {end}", &self); for events in self.notes[start.max(0)..end.min(self.notes.len())].iter() { for event in events.iter() { - match event { - MidiMessage::NoteOn {key,..} => { - if *key == k { - return true - } - } - _ => {} - } + if let MidiMessage::NoteOn {key,..} = event { if *key == k { return true } } } } return false @@ -438,11 +408,7 @@ impl PhrasePlayer { Some(TransportState::Rolling), Some((start_frame, _)), Some((_started, Some(ref phrase))) - ) = ( - *self.clock.playing.read().unwrap(), - self.started, - &self.phrase - ) { + ) = (*self.clock.playing.read().unwrap(), self.started, &self.phrase) { Some((start_frame, phrase.clone())) } else { None