mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
refactor: jack proto-lib
This commit is contained in:
parent
4aadc712b8
commit
fe6ffea5df
12 changed files with 467 additions and 441 deletions
|
|
@ -38,22 +38,29 @@ impl Track {
|
|||
recording: false,
|
||||
overdub: true,
|
||||
sequence: None,
|
||||
phrases: phrases.unwrap_or_else(||vec![]),
|
||||
devices: devices.unwrap_or_else(||vec![]),
|
||||
phrases: phrases.unwrap_or_else(||Vec::with_capacity(16)),
|
||||
devices: devices.unwrap_or_else(||Vec::with_capacity(16)),
|
||||
device: 0,
|
||||
})
|
||||
}
|
||||
pub fn device (&self, i: usize) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
pub fn add_device (
|
||||
&mut self, device: JackDevice
|
||||
) -> &mut JackDevice {
|
||||
self.devices.push(device);
|
||||
let index = self.devices.len() - 1;
|
||||
&mut self.devices[index]
|
||||
}
|
||||
pub fn get_device (&self, i: usize) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.devices.get(i).map(|d|d.state.lock().unwrap())
|
||||
}
|
||||
pub fn active_device (&self) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.device(self.device)
|
||||
pub fn device (&self) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.get_device(self.device)
|
||||
}
|
||||
pub fn first_device (&self) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.device(0)
|
||||
self.get_device(0)
|
||||
}
|
||||
pub fn last_device (&self) -> Option<MutexGuard<Box<dyn Device>>> {
|
||||
self.device(self.devices.len().saturating_sub(1))
|
||||
self.get_device(self.devices.len().saturating_sub(1))
|
||||
}
|
||||
pub fn phrase (&self) -> Option<&Phrase> {
|
||||
if let Some(phrase) = self.sequence {
|
||||
|
|
@ -69,6 +76,13 @@ impl Track {
|
|||
None
|
||||
}
|
||||
}
|
||||
pub 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]
|
||||
}
|
||||
}
|
||||
|
||||
ports!(Track {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue