mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
big ass refactor (rip client)
This commit is contained in:
parent
94c1f83ef2
commit
8c3cf53c67
56 changed files with 2232 additions and 1891 deletions
48
src/model/track.rs
Normal file
48
src/model/track.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use crate::core::*;
|
||||
use crate::model::*;
|
||||
|
||||
pub struct Track {
|
||||
pub name: String,
|
||||
pub sequencer: Sequencer,
|
||||
pub chain: Chain,
|
||||
}
|
||||
|
||||
impl Track {
|
||||
pub fn new (
|
||||
name: &str,
|
||||
tempo: &Arc<Timebase>,
|
||||
devices: Option<Vec<Box<dyn Device>>>,
|
||||
phrases: Option<Vec<Phrase>>,
|
||||
) -> Usually<Self> {
|
||||
let sequencer = Sequencer::new(&name, tempo, phrases)?;
|
||||
let chain = Chain::new(&name, devices)?;
|
||||
let (client, _status) = Client::new("init", ClientOptions::NO_START_SERVER)?;
|
||||
{
|
||||
if let (Some(output), Some(input)) = (
|
||||
sequencer.midi_outs()?.get(0).clone(),
|
||||
if let Some(item) = chain.items.get(0) {
|
||||
if let Some(port) = item.midi_ins()?.get(0) {
|
||||
Some(port.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
) {
|
||||
client.connect_ports_by_name(&output, &input)?;
|
||||
}
|
||||
}
|
||||
Ok(Self { name: name.to_string(), sequencer, chain })
|
||||
}
|
||||
}
|
||||
|
||||
impl PortList for Track {
|
||||
fn midi_ins (&self) -> Usually<Vec<String>> {
|
||||
self.sequencer.midi_ins()
|
||||
}
|
||||
fn audio_outs (&self) -> Usually<Vec<String>> {
|
||||
self.chain.audio_outs()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue