use crate::core::*; use crate::device::*; use crate::layout::*; pub struct Track { pub name: String, pub sequencer: DynamicDevice, pub chain: DynamicDevice, } impl Track { pub fn new ( name: &str, tempo: &Arc, devices: Option>>, phrases: Option>, ) -> Usually { let sequencer = Sequencer::new(&name, tempo, phrases)?; let chain = Chain::new(&name, devices)?; { if let (Some(output), Some(input)) = ( sequencer.midi_outs()?.get(0).clone(), if let Some(item) = chain.state().items.get(0) { if let Some(port) = item.midi_ins()?.get(0) { Some(port.clone()) } else { None } } else { None } ) { if let Some(client) = &sequencer.client { client.as_client().connect_ports_by_name(&output, &input)?; } } } Ok(Self { name: name.to_string(), sequencer, chain }) } } impl PortList for Track { fn midi_ins (&self) -> Usually> { self.sequencer.midi_ins() } fn audio_outs (&self) -> Usually> { self.chain.audio_outs() } }