mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: reenable sampling
This commit is contained in:
parent
e9c825e865
commit
efd182f302
6 changed files with 61 additions and 38 deletions
|
|
@ -2,15 +2,17 @@ use crate::*;
|
|||
|
||||
expose!([self: Sampler]
|
||||
([Arc<str>])
|
||||
([Option<Arc<RwLock<Sample>>>])
|
||||
([MaybeSample])
|
||||
([PathBuf])
|
||||
([f32])
|
||||
([u7] (":pitch" (self.note_pos() as u8).into()) // TODO
|
||||
(":sample" (self.note_pos() as u8).into()))
|
||||
([usize] (":sample-up" self.note_pos().min(119) + 8)
|
||||
(":sample-down" self.note_pos().max(8) - 8)
|
||||
(":sample-left" self.note_pos().min(126) + 1)
|
||||
(":sample-right" self.note_pos().max(1) - 1)));
|
||||
([u7]
|
||||
(":pitch" (self.note_pos() as u8).into()) // TODO
|
||||
(":sample" (self.note_pos() as u8).into()))
|
||||
([usize]
|
||||
(":sample-up" self.note_pos().min(119) + 8)
|
||||
(":sample-down" self.note_pos().max(8) - 8)
|
||||
(":sample-left" self.note_pos().min(126) + 1)
|
||||
(":sample-right" self.note_pos().max(1) - 1)));
|
||||
|
||||
impose!([state: Sampler]
|
||||
(FileBrowserCommand:
|
||||
|
|
@ -31,7 +33,7 @@ impose!([state: Sampler]
|
|||
Some(Self::RecordCancel))
|
||||
("record/finish" []
|
||||
Some(Self::RecordFinish))
|
||||
("set/sample" [i: u7, s: Option<Arc<RwLock<Sample>>>]
|
||||
("set/sample" [i: u7, s: MaybeSample]
|
||||
Some(Self::SetSample(i.expect("no index"), s.expect("no sampler"))))
|
||||
("set/start" [i: u7, s: usize]
|
||||
Some(Self::SetStart(i.expect("no index"), s.expect("no start"))))
|
||||
|
|
@ -42,17 +44,21 @@ impose!([state: Sampler]
|
|||
("note/off" [p: u7]
|
||||
Some(Self::NoteOff(p.expect("no pitch"))))));
|
||||
|
||||
macro_rules! cmd { ($cmd:expr) => {{ $cmd; None }}; }
|
||||
macro_rules! cmd_todo { ($msg:literal) => {{ println!($msg); None }}; }
|
||||
|
||||
defcom!([self, state: Sampler]
|
||||
(SamplerCommand
|
||||
(Select [i: usize] Some(Self::Select(state.set_note_pos(i))))
|
||||
(RecordBegin [p: u7] { state.begin_recording(p.as_int() as usize); None })
|
||||
(RecordCancel [] { state.cancel_recording(); None })
|
||||
(RecordFinish [] { state.finish_recording(); None })
|
||||
(SetStart [pitch: u7, frame: usize] { println!("\n\rtodo: {self:?}"); None })
|
||||
(SetGain [pitch: u7, gain: f32] { println!("\n\rtodo: {self:?}"); None })
|
||||
(NoteOn [pitch: u7, velocity: u7] { println!("\n\rtodo: {self:?}"); None })
|
||||
(NoteOff [pitch: u7] { println!("\n\rtodo: {self:?}"); None })
|
||||
(Import [cmd: FileBrowserCommand] match cmd {
|
||||
(Select [i: usize] Some(Self::Select(state.set_note_pos(i))))
|
||||
(RecordBegin [p: u7] cmd!(state.begin_recording(p.as_int() as usize)))
|
||||
(RecordCancel [] cmd!(state.cancel_recording()))
|
||||
(RecordFinish [] cmd!(state.finish_recording()))
|
||||
(SetStart [p: u7, frame: usize] cmd_todo!("\n\rtodo: {self:?}"))
|
||||
(SetGain [p: u7, gain: f32] cmd_todo!("\n\rtodo: {self:?}"))
|
||||
(NoteOn [p: u7, velocity: u7] cmd_todo!("\n\rtodo: {self:?}"))
|
||||
(NoteOff [p: u7] cmd_todo!("\n\rtodo: {self:?}"))
|
||||
(SetSample [p: u7, s: MaybeSample] Some(Self::SetSample(p, state.set_sample(p, s))))
|
||||
(Import [c: FileBrowserCommand] match c {
|
||||
FileBrowserCommand::Begin => {
|
||||
//let voices = &state.state.voices;
|
||||
//let sample = Arc::new(RwLock::new(Sample::new("", 0, 0, vec![])));
|
||||
|
|
@ -60,13 +66,7 @@ defcom!([self, state: Sampler]
|
|||
None
|
||||
},
|
||||
_ => {
|
||||
println!("\n\rtodo: import: filebrowser: {cmd:?}");
|
||||
println!("\n\rtodo: import: filebrowser: {c:?}");
|
||||
None
|
||||
}
|
||||
})
|
||||
(SetSample [pitch: u7, sample: Option<Arc<RwLock<Sample>>>] {
|
||||
let i = pitch.as_int() as usize;
|
||||
let old = state.mapped[i].clone();
|
||||
state.mapped[i] = sample;
|
||||
Some(Self::SetSample(pitch, old))
|
||||
})));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue