bye sequencer

This commit is contained in:
🪞👃🪞 2024-07-03 18:36:16 +03:00
parent 2165e5d45d
commit 316fe45b2a
12 changed files with 510 additions and 759 deletions

View file

@ -2,50 +2,48 @@ use crate::core::*;
use crate::model::*;
pub struct Track {
pub name: String,
pub sequencer: Sequencer,
pub chain: Chain,
pub midi_out: Port<MidiOut>,
pub name: String,
/// Play input through output.
pub monitoring: bool,
/// Write input to sequence.
pub recording: bool,
/// Overdub input to sequence.
pub overdub: bool,
/// Map: tick -> MIDI events at tick
pub phrases: Vec<Phrase>,
/// Phrase selector
pub sequence: Option<usize>,
/// Output from current sequence.
pub midi_out: Port<MidiOut>,
/// Red keys on piano roll.
pub notes_on: Vec<bool>,
/// Device chain
pub chain: Chain,
}
impl Track {
pub fn new (
name: &str,
jack: &Client,
timebase: &Arc<Timebase>,
devices: Option<Vec<Box<dyn Device>>>,
phrases: Option<Vec<Phrase>>,
name: &str,
jack: &Client,
devices: Option<Vec<Box<dyn Device>>>,
phrases: Option<Vec<Phrase>>,
) -> Usually<Self> {
let sequencer = Sequencer::new(&name, timebase, phrases)?;
let chain = Chain::new(&name, devices)?;
let midi_out = jack.register_port(name, MidiOut)?;
//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, midi_out })
Ok(Self {
name: name.to_string(),
chain: Chain::new(&name, devices)?,
midi_out: jack.register_port(name, MidiOut)?,
notes_on: vec![],
monitoring: false,
recording: false,
overdub: true,
sequence: None,
phrases: phrases.unwrap_or_else(||vec![])
})
}
}
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()
}
fn midi_ins (&self) -> Usually<Vec<String>> { Ok(vec![]) }
fn midi_outs (&self) -> Usually<Vec<String>> { Ok(vec![self.midi_out.name()?]) }
}