tek/src/model/track.rs
2024-07-04 01:36:32 +03:00

49 lines
1.3 KiB
Rust

use crate::core::*;
use crate::model::*;
pub struct Track {
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,
devices: Option<Vec<Box<dyn Device>>>,
phrases: Option<Vec<Phrase>>,
) -> Usually<Self> {
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>> { Ok(vec![]) }
fn midi_outs (&self) -> Usually<Vec<String>> { Ok(vec![self.midi_out.name()?]) }
}