bye chain

This commit is contained in:
🪞👃🪞 2024-07-03 18:46:19 +03:00
parent 316fe45b2a
commit 2601592d17
8 changed files with 115 additions and 164 deletions

View file

@ -1,46 +0,0 @@
use crate::{core::*, view::*};
pub struct Chain {
pub name: String,
pub focused: bool,
pub focus: usize,
pub items: Vec<Box<dyn Device>>,
pub view: ChainViewMode,
pub adding: bool,
}
render!(Chain = crate::view::chain::render);
handle!(Chain = crate::control::chain::handle);
process!(Chain);
impl Chain {
pub fn new (name: &str, items: Option<Vec<Box<dyn Device>>>) -> Usually<Self> {
Ok(Self {
name: name.into(),
focused: false,
focus: 0,
items: items.unwrap_or_else(||vec![]),
view: ChainViewMode::Column,
adding: false
})
}
}
impl PortList for Chain {
fn midi_ins (&self) -> Usually<Vec<String>> {
if let Some(device) = self.items.get(0) {
device.midi_ins()
} else {
Ok(vec![])
}
}
fn audio_outs (&self) -> Usually<Vec<String>> {
if let Some(device) = self.items.get(self.items.len().saturating_sub(1)) {
device.audio_outs()
} else {
Ok(vec![])
}
}
}
pub fn process (_: &mut Chain, _: &Client, _: &ProcessScope) -> Control {
Control::Continue
}

View file

@ -18,7 +18,9 @@ pub struct Track {
/// Red keys on piano roll.
pub notes_on: Vec<bool>,
/// Device chain
pub chain: Chain,
pub devices: Vec<Box<dyn Device>>,
/// Device selector
pub device: usize,
}
impl Track {
@ -30,14 +32,15 @@ impl Track {
) -> 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![])
phrases: phrases.unwrap_or_else(||vec![]),
devices: devices.unwrap_or_else(||vec![]),
device: 0,
})
}
}