mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
75 lines
1.7 KiB
Rust
75 lines
1.7 KiB
Rust
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);0] = [];
|
|
|
|
pub struct Sampler {
|
|
exited: bool,
|
|
jack: Jack<Notifications>,
|
|
samples: Vec<Sample>,
|
|
selected_sample: usize,
|
|
selected_column: usize,
|
|
}
|
|
|
|
impl Sampler {
|
|
pub fn new () -> Result<Self, Box<dyn Error>> {
|
|
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 Box<dyn FnMut(&Client, &ProcessScope)->Control + 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<Vec<u8>>,
|
|
}
|
|
|
|
impl Sample {
|
|
|
|
pub fn new (name: &str) -> Result<Self, Box<dyn Error>> {
|
|
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
|
|
}
|
|
}
|