mod handle; mod jack; mod render; pub use self::handle::*; pub use self::jack::*; pub use self::render::*; use crate::prelude::*; pub const ACTIONS: [(&'static str, &'static str);2] = [ ("Enter", "Play sample"), ("Ins/Del", "Add/remove sample"), ]; pub struct Sampler { exited: bool, jack: Jack, samples: Vec, selected_sample: usize, selected_column: usize, } impl Sampler { pub fn new () -> Result> { let (client, status) = Client::new( "bloop-sampler", ClientOptions::NO_START_SERVER )?; let jack = client.activate_async( Notifications, ClosureProcessHandler::new(Box::new( move |_: &Client, _: &ProcessScope| -> Control { Control::Continue }) as BoxControl + Send> ) )?; Ok(Self { exited: false, selected_sample: 0, selected_column: 0, samples: vec![ Sample::new("Kick")?, Sample::new("Snare")?, ], jack, }) } } pub struct Sample { name: String, rate: u32, gain: f64, channels: u8, data: Vec>, } impl Sample { pub fn new (name: &str) -> Result> { Ok(Self { name: name.into(), rate: 44100, channels: 1, gain: 0.0, data: vec![vec![]] }) } } impl Exitable for Sampler { fn exit (&mut self) { self.exited = true } fn exited (&self) -> bool { self.exited } }