more weird formatting

This commit is contained in:
🪞👃🪞 2024-11-01 00:28:08 +02:00
parent d64f4b8af7
commit 076be5bcb3

View file

@ -217,15 +217,12 @@ impl<E: Engine> PhrasePool<E> {
} }
pub fn begin_rename (&mut self) { pub fn begin_rename (&mut self) {
self.mode = Some(PhrasePoolMode::Rename( self.mode = Some(PhrasePoolMode::Rename(
self.phrase, self.phrase, self.phrases[self.phrase].read().unwrap().name.clone()
self.phrases[self.phrase].read().unwrap().name.clone()
)); ));
} }
pub fn begin_length (&mut self) { pub fn begin_length (&mut self) {
self.mode = Some(PhrasePoolMode::Length( self.mode = Some(PhrasePoolMode::Length(
self.phrase, self.phrase, self.phrases[self.phrase].read().unwrap().length, PhraseLengthFocus::Bar
self.phrases[self.phrase].read().unwrap().length,
PhraseLengthFocus::Bar
)); ));
} }
pub fn move_up (&mut self) { pub fn move_up (&mut self) {
@ -273,20 +270,12 @@ impl<E: Engine> PhraseEditor<E> {
pub fn note_cursor_inc (&self) { pub fn note_cursor_inc (&self) {
let mut axis = self.note_axis.write().unwrap(); let mut axis = self.note_axis.write().unwrap();
axis.point_dec(1); axis.point_dec(1);
if let Some(point) = axis.point { if let Some(point) = axis.point { if point < axis.start { axis.start = (point / 2) * 2; } }
if point < axis.start {
axis.start = (point / 2) * 2;
}
}
} }
pub fn note_cursor_dec (&self) { pub fn note_cursor_dec (&self) {
let mut axis = self.note_axis.write().unwrap(); let mut axis = self.note_axis.write().unwrap();
axis.point_inc(1); axis.point_inc(1);
if let Some(point) = axis.point { if let Some(point) = axis.point { if point > 73 { axis.point = Some(73); } }
if point > 73 {
axis.point = Some(73);
}
}
} }
pub fn note_page_up (&self) { pub fn note_page_up (&self) {
let mut axis = self.note_axis.write().unwrap(); let mut axis = self.note_axis.write().unwrap();
@ -298,18 +287,10 @@ impl<E: Engine> PhraseEditor<E> {
axis.start_inc(3); axis.start_inc(3);
axis.point_inc(3); axis.point_inc(3);
} }
pub fn note_scroll_inc (&self) { pub fn note_scroll_inc (&self) { self.note_axis.write().unwrap().start_dec(1); }
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_scroll_dec (&self) { pub fn note_length_dec (&mut self) { self.note_len = prev_note_length(self.note_len) }
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) { pub fn time_cursor_advance (&self) {
let point = self.time_axis.read().unwrap().point; let point = self.time_axis.read().unwrap().point;
let length = self.phrase.as_ref().map(|p|p.read().unwrap().length).unwrap_or(1); 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.uuid = uuid::Uuid::new_v4();
clone clone
} }
pub fn toggle_loop (&mut self) { pub fn toggle_loop (&mut self) { self.loop_on = !self.loop_on; }
self.loop_on = !self.loop_on;
}
pub fn record_event (&mut self, pulse: usize, message: MidiMessage) { pub fn record_event (&mut self, pulse: usize, message: MidiMessage) {
if pulse >= self.length { if pulse >= self.length { panic!("extend phrase first") }
panic!("extend phrase first")
}
self.notes[pulse].push(message); self.notes[pulse].push(message);
} }
/// Check if a range `start..end` contains MIDI Note On `k` /// Check if a range `start..end` contains MIDI Note On `k`
@ -381,14 +358,7 @@ impl Phrase {
//panic!("{:?} {start} {end}", &self); //panic!("{:?} {start} {end}", &self);
for events in self.notes[start.max(0)..end.min(self.notes.len())].iter() { for events in self.notes[start.max(0)..end.min(self.notes.len())].iter() {
for event in events.iter() { for event in events.iter() {
match event { if let MidiMessage::NoteOn {key,..} = event { if *key == k { return true } }
MidiMessage::NoteOn {key,..} => {
if *key == k {
return true
}
}
_ => {}
}
} }
} }
return false return false
@ -438,11 +408,7 @@ impl<E: Engine> PhrasePlayer<E> {
Some(TransportState::Rolling), Some(TransportState::Rolling),
Some((start_frame, _)), Some((start_frame, _)),
Some((_started, Some(ref phrase))) 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())) Some((start_frame, phrase.clone()))
} else { } else {
None None