mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
api: compact
This commit is contained in:
parent
e4808f8fc1
commit
3ef3d5eb6f
22 changed files with 441 additions and 558 deletions
|
|
@ -127,7 +127,7 @@
|
|||
//});
|
||||
|
||||
//struct SamplesTui {
|
||||
//color: ItemPalette,
|
||||
//color: ItemTheme,
|
||||
//note_hi: usize,
|
||||
//note_pt: usize,
|
||||
//height: usize,
|
||||
|
|
|
|||
|
|
@ -22,12 +22,13 @@ pub(crate) use symphonia::{
|
|||
pub(crate) use ratatui::{prelude::Rect, widgets::{Widget, canvas::{Canvas, Line}}};
|
||||
|
||||
mod sampler_api; pub use self::sampler_api::*;
|
||||
mod sampler_data; pub use self::sampler_data::*;
|
||||
mod sampler_audio; pub use self::sampler_audio::*;
|
||||
mod sampler_browse; pub use self::sampler_browse::*;
|
||||
mod sampler_midi; pub use self::sampler_midi::*;
|
||||
mod sampler_model; pub use self::sampler_model::*;
|
||||
mod sampler_view; pub use self::sampler_view::*;
|
||||
|
||||
mod sampler_data;
|
||||
mod sampler_view;
|
||||
|
||||
#[cfg(test)] #[test] fn test_sampler () {
|
||||
// TODO!
|
||||
|
|
|
|||
|
|
@ -1,25 +1,48 @@
|
|||
use crate::*;
|
||||
|
||||
expose! {
|
||||
[self: Sampler] {
|
||||
[Arc<str>] => {}
|
||||
[Option<Arc<RwLock<Sample>>>] => {}
|
||||
[PathBuf] => {}
|
||||
[f32] => {}
|
||||
[u7] => {
|
||||
":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,
|
||||
}
|
||||
}
|
||||
}
|
||||
expose!([self: Sampler]
|
||||
([Arc<str>])
|
||||
([Option<Arc<RwLock<Sample>>>])
|
||||
([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)));
|
||||
|
||||
impose!([state: Sampler]
|
||||
(FileBrowserCommand:
|
||||
("begin" [] Some(Self::Begin))
|
||||
("cancel" [] Some(Self::Cancel))
|
||||
("confirm" [] Some(Self::Confirm))
|
||||
("select" [i: usize] Some(Self::Select(i.expect("no index"))))
|
||||
("chdir" [p: PathBuf] Some(Self::Chdir(p.expect("no path"))))
|
||||
("filter" [f: Arc<str>] Some(Self::Filter(f.expect("no filter")))))
|
||||
(SamplerCommand:
|
||||
("import" [,..a]
|
||||
FileBrowserCommand::try_from_expr(state, a).map(Self::Import))
|
||||
("select" [i: usize]
|
||||
Some(Self::Select(i.expect("no index"))))
|
||||
("record/begin" [i: u7]
|
||||
Some(Self::RecordBegin(i.expect("no index"))))
|
||||
("record/cancel" []
|
||||
Some(Self::RecordCancel))
|
||||
("record/finish" []
|
||||
Some(Self::RecordFinish))
|
||||
("set/sample" [i: u7, s: Option<Arc<RwLock<Sample>>>]
|
||||
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"))))
|
||||
("set/gain" [i: u7, g: f32]
|
||||
Some(Self::SetGain(i.expect("no index"), g.expect("no gain"))))
|
||||
("note/on" [p: u7, v: u7]
|
||||
Some(Self::NoteOn(p.expect("no pitch"), v.expect("no velocity"))))
|
||||
("note/off" [p: u7]
|
||||
Some(Self::NoteOff(p.expect("no pitch"))))));
|
||||
|
||||
defcom! { |self, state: Sampler|
|
||||
|
||||
SamplerCommand {
|
||||
|
||||
Import(cmd: FileBrowserCommand) => match cmd {
|
||||
|
|
@ -86,28 +109,3 @@ defcom! { |self, state: Sampler|
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
atom_command!(FileBrowserCommand: |state: Sampler| {
|
||||
("begin" [] Some(Self::Begin))
|
||||
("cancel" [] Some(Self::Cancel))
|
||||
("confirm" [] Some(Self::Confirm))
|
||||
("select" [i: usize] Some(Self::Select(i.expect("no index"))))
|
||||
("chdir" [p: PathBuf] Some(Self::Chdir(p.expect("no path"))))
|
||||
("filter" [f: Arc<str>] Some(Self::Filter(f.expect("no filter")))) });
|
||||
|
||||
atom_command!(SamplerCommand: |state: Sampler| {
|
||||
("import" [,..a] FileBrowserCommand::try_from_expr(state, a).map(Self::Import))
|
||||
("select" [i: usize] Some(Self::Select(i.expect("no index"))))
|
||||
("record/begin" [i: u7] Some(Self::RecordBegin(i.expect("no index"))))
|
||||
("record/cancel" [] Some(Self::RecordCancel))
|
||||
("record/finish" [] Some(Self::RecordFinish))
|
||||
("set/sample" [i: u7, s: Option<Arc<RwLock<Sample>>>]
|
||||
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"))))
|
||||
("set/gain" [i: u7, g: f32]
|
||||
Some(Self::SetGain(i.expect("no index"), g.expect("no garin"))))
|
||||
("note/on" [p: u7, v: u7]
|
||||
Some(Self::NoteOn(p.expect("no pitch"), v.expect("no velocity"))))
|
||||
("note/off" [p: u7]
|
||||
Some(Self::NoteOff(p.expect("no pitch")))) });
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub struct Sampler {
|
|||
pub note_pt: AtomicUsize,
|
||||
/// Selected note as row/col
|
||||
pub cursor: (AtomicUsize, AtomicUsize),
|
||||
pub color: ItemPalette
|
||||
pub color: ItemTheme
|
||||
}
|
||||
|
||||
impl Default for Sampler {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue