mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
transport is rolling
This commit is contained in:
parent
1f928fba9d
commit
4fd208d53f
18 changed files with 540 additions and 498 deletions
|
|
@ -1,78 +0,0 @@
|
|||
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<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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue