mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
samples in main
This commit is contained in:
parent
15f71d0973
commit
fad0caef88
3 changed files with 30 additions and 45 deletions
|
|
@ -11,7 +11,7 @@ mod transport;
|
||||||
pub use self::track::Track;
|
pub use self::track::Track;
|
||||||
pub use self::launcher::{Launcher, Scene};
|
pub use self::launcher::{Launcher, Scene};
|
||||||
pub use self::sequencer::{Sequencer, Phrase};
|
pub use self::sequencer::{Sequencer, Phrase};
|
||||||
pub use self::chain::{Chain, Sampler, Plugin};
|
pub use self::chain::{Chain, Plugin, Sampler, Sample, Voice};
|
||||||
|
|
||||||
pub use self::looper::Looper;
|
pub use self::looper::Looper;
|
||||||
pub use self::mixer::Mixer;
|
pub use self::mixer::Mixer;
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ impl Voice {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Sample {
|
pub struct Sample {
|
||||||
name: String,
|
pub name: String,
|
||||||
start: usize,
|
pub start: usize,
|
||||||
end: usize,
|
pub end: usize,
|
||||||
channels: Vec<Vec<f32>>,
|
pub channels: Vec<Vec<f32>>,
|
||||||
}
|
}
|
||||||
impl Sample {
|
impl Sample {
|
||||||
fn new (name: &str) -> Arc<Self> {
|
fn new (name: &str) -> Arc<Self> {
|
||||||
|
|
@ -41,49 +41,15 @@ pub struct Sampler {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sampler {
|
impl Sampler {
|
||||||
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
pub fn new (
|
||||||
|
name: &str,
|
||||||
|
samples: Option<BTreeMap<u7, Arc<Sample>>>,
|
||||||
|
) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||||
let (client, _) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
let (client, _) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
||||||
DynamicDevice::new(render, handle, Self::process, Self {
|
DynamicDevice::new(render, handle, Self::process, Self {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
cursor: (0, 0),
|
cursor: (0, 0),
|
||||||
samples: BTreeMap::from([
|
samples: samples.unwrap_or(BTreeMap::new()),
|
||||||
(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()),
|
|
||||||
]),
|
|
||||||
voices: vec![],
|
voices: vec![],
|
||||||
midi_in: client.register_port("midi", ::jack::MidiIn::default())?,
|
midi_in: client.register_port("midi", ::jack::MidiIn::default())?,
|
||||||
audio_ins: vec![
|
audio_ins: vec![
|
||||||
|
|
|
||||||
21
src/main.rs
21
src/main.rs
|
|
@ -34,7 +34,26 @@ fn main () -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
Track::new("Kick", &timebase, Some(vec![
|
Track::new("Kick", &timebase, Some(vec![
|
||||||
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
//Plugin::lv2("Kick/ChowKick", "file:///home/user/.lv2/ChowKick.lv2", &[1, 1, 0, 2])?.boxed(),
|
||||||
Sampler::new("Sampler")?.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()),
|
||||||
|
])))?.boxed(),
|
||||||
]), Some(vec![
|
]), Some(vec![
|
||||||
Phrase::new("HelloKick", ppq * 4, Some(BTreeMap::from([
|
Phrase::new("HelloKick", ppq * 4, Some(BTreeMap::from([
|
||||||
( ppq * 0, vec![MidiMessage::NoteOn { key: 36.into(), vel: 100.into() }] ),
|
( ppq * 0, vec![MidiMessage::NoteOn { key: 36.into(), vel: 100.into() }] ),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue