include!("./lib.rs"); pub fn main () -> Usually<()> { SamplerCli::parse().run() } #[derive(Debug, Parser)] #[command(version, about, long_about = None)] pub struct SamplerCli { /// Name of JACK client #[arg(short, long)] name: Option, /// Path to plugin #[arg(short, long)] path: Option, /// MIDI outs to connect to MIDI input #[arg(short='i', long)] midi_from: Vec, /// Audio outs to connect to left input #[arg(short='l', long)] l_from: Vec, /// Audio outs to connect to right input #[arg(short='r', long)] r_from: Vec, /// Audio ins to connect from left output #[arg(short='L', long)] l_to: Vec, /// Audio ins to connect from right output #[arg(short='R', long)] r_to: Vec, } impl SamplerCli { fn run (&self) -> Usually<()> { let name = self.name.as_deref().unwrap_or("tek_sampler"); let engine = Tui::new()?; let state = JackConnection::new(name)?.activate_with(|jack|{ Ok(tek::SamplerTui { cursor: (0, 0), editing: None, mode: None, size: Measure::new(), note_lo: 36.into(), note_pt: 36.into(), color: ItemPalette::from(Color::Rgb(64, 128, 32)), state: Sampler::new( jack, &"sampler", &self.midi_from.as_slice(), &[&self.l_from.as_slice(), &self.r_from.as_slice()], &[&self.l_to.as_slice(), &self.r_to.as_slice()], )?, }) })?; engine.run(&state) } }