mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
refactor vertical arranger
This commit is contained in:
parent
e62fcc333e
commit
a7a798b484
3 changed files with 116 additions and 180 deletions
|
|
@ -96,30 +96,18 @@ impl Track {
|
|||
reset: true,
|
||||
})
|
||||
}
|
||||
fn get_device (&self, i: usize) -> Option<RwLockReadGuard<Box<dyn Device>>> {
|
||||
self.devices.get(i).map(|d|d.state.read().unwrap())
|
||||
}
|
||||
fn get_device_mut (&self, i: usize) -> Option<RwLockWriteGuard<Box<dyn Device>>> {
|
||||
self.devices.get(i).map(|d|d.state.write().unwrap())
|
||||
}
|
||||
fn device (&self) -> Option<RwLockReadGuard<Box<dyn Device>>> {
|
||||
self.get_device(self.device)
|
||||
}
|
||||
pub fn device_mut (&self) -> Option<RwLockWriteGuard<Box<dyn Device>>> {
|
||||
self.get_device_mut(self.device)
|
||||
}
|
||||
fn first_device (&self) -> Option<RwLockReadGuard<Box<dyn Device>>> {
|
||||
self.get_device(0)
|
||||
}
|
||||
pub fn connect_first_device (&self) -> Usually<()> {
|
||||
if let (Some(port), Some(device)) = (&self.midi_out, self.devices.get(0)) {
|
||||
device.client.as_client().connect_ports(&port, &device.midi_ins()?[0])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn last_device (&self) -> Option<RwLockReadGuard<Box<dyn Device>>> {
|
||||
self.get_device(self.devices.len().saturating_sub(1))
|
||||
}
|
||||
pub fn connect_last_device (&self, app: &App) -> Usually<()> {
|
||||
Ok(match self.devices.get(self.devices.len().saturating_sub(1)) {
|
||||
Some(device) => {
|
||||
|
|
@ -135,37 +123,6 @@ impl Track {
|
|||
let index = self.devices.len() - 1;
|
||||
Ok(&mut self.devices[index])
|
||||
}
|
||||
fn add_device_with_cb (
|
||||
&mut self,
|
||||
mut device: JackDevice,
|
||||
init: impl Fn(&Self, &mut JackDevice)->Usually<()>
|
||||
) -> Usually<&mut JackDevice> {
|
||||
init(&self, &mut device)?;
|
||||
self.devices.push(device);
|
||||
let index = self.devices.len() - 1;
|
||||
Ok(&mut self.devices[index])
|
||||
}
|
||||
fn phrase (&self) -> Option<&Phrase> {
|
||||
if let Some(phrase) = self.sequence {
|
||||
return self.phrases.get(phrase)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn phrase_mut (&mut self) -> Option<&mut Phrase> {
|
||||
if let Some(phrase) = self.sequence {
|
||||
return self.phrases.get_mut(phrase)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn add_phrase (
|
||||
&mut self, name: &str, length: usize, data: Option<PhraseData>
|
||||
) -> &mut Phrase {
|
||||
self.phrases.push(Phrase::new(name, length, data));
|
||||
let index = self.phrases.len() - 1;
|
||||
&mut self.phrases[index]
|
||||
}
|
||||
pub fn toggle_monitor (&mut self) {
|
||||
self.monitoring = !self.monitoring;
|
||||
}
|
||||
|
|
@ -201,8 +158,6 @@ impl Track {
|
|||
all_notes_off(&mut self.midi_out_buf);
|
||||
}
|
||||
}
|
||||
// For highlighting keys and note repeat
|
||||
// Currently playing phrase
|
||||
if let (
|
||||
Some(TransportState::Rolling), Some((start_frame, _)), Some(phrase)
|
||||
) = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue