mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
plays crackly samples
This commit is contained in:
parent
de2e2a2124
commit
1672cbfc68
5 changed files with 90 additions and 26 deletions
39
src/main.rs
39
src/main.rs
|
|
@ -15,6 +15,25 @@ pub mod time;
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
macro_rules! sample {
|
||||
($note:expr, $name:expr, $src:expr) => {
|
||||
{
|
||||
let mut channels: Vec<wavers::Samples<f32>> = vec![];
|
||||
for channel in wavers::Wav::from_path($src)?.channels() {
|
||||
channels.push(channel);
|
||||
}
|
||||
let mut end = 0;
|
||||
let mut data: Vec<Vec<f32>> = vec![];
|
||||
for samples in channels.iter() {
|
||||
let channel = Vec::from(samples.as_ref());
|
||||
end = end.max(channel.len());
|
||||
data.push(channel);
|
||||
}
|
||||
(u7::from_int_lossy($note).into(), Sample::new($name, 0, end, data).into())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn main () -> Result<(), Box<dyn Error>> {
|
||||
let _cli = cli::Cli::parse();
|
||||
let xdg = microxdg::XdgApp::new("tek")?;
|
||||
|
|
@ -35,24 +54,8 @@ fn main () -> Result<(), Box<dyn Error>> {
|
|||
Track::new("Kick", &timebase, Some(vec![
|
||||
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
||||
Sampler::new("Sampler", Some(BTreeMap::from([
|
||||
(u7::from_int_lossy(35), Sample {
|
||||
name: "Kick 1".into(), start: 0, end: 100000, channels: vec![],
|
||||
}.into()),
|
||||
(u7::from_int_lossy(36).into(), Sample {
|
||||
name: "Kick 2".into(), start: 0, end: 100000, channels: vec![],
|
||||
}.into()),
|
||||
(u7::from_int_lossy(38).into(), Sample {
|
||||
name: "Snare 1".into(), start: 0, end: 100000, channels: vec![],
|
||||
}.into()),
|
||||
(u7::from_int_lossy(40).into(), Sample {
|
||||
name: "Snare 2".into(), start: 50000, end: 100000, channels: vec![],
|
||||
}.into()),
|
||||
(u7::from_int_lossy(42).into(), Sample {
|
||||
name: "HH Closed".into(), start: 0, end: 50000, channels: vec![],
|
||||
}.into()),
|
||||
(u7::from_int_lossy(46).into(), Sample {
|
||||
name: "HH Open".into(), start: 0, end: 25000, channels: vec![]
|
||||
}.into()),
|
||||
sample!(36, "Kick", "/home/user/Lab/Music/pak/kik.wav"),
|
||||
sample!(40, "Snare", "/home/user/Lab/Music/pak/sna.wav"),
|
||||
])))?.boxed(),
|
||||
]), Some(vec![
|
||||
Phrase::new("HelloKick", ppq * 4, Some(BTreeMap::from([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue