mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
fixed up some parsing and removed some edn mentions
This commit is contained in:
parent
5e7b867aba
commit
452bdf9598
15 changed files with 290 additions and 292 deletions
|
|
@ -349,22 +349,22 @@ impl Sampler {
|
|||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
type MidiSample = (Option<u7>, Arc<RwLock<crate::Sample>>);
|
||||
from_edn!("sampler" => |jack: &Arc<RwLock<JackConnection>>, args| -> crate::Sampler {
|
||||
from_atom!("sampler" => |jack: &Arc<RwLock<JackConnection>>, args| -> crate::Sampler {
|
||||
let mut name = String::new();
|
||||
let mut dir = String::new();
|
||||
let mut samples = BTreeMap::new();
|
||||
edn!(edn in args {
|
||||
Edn::Map(map) => {
|
||||
if let Some(Edn::Str(n)) = map.get(&Edn::Key(":name")) {
|
||||
atom!(atom in args {
|
||||
Atom::Map(map) => {
|
||||
if let Some(Atom::Str(n)) = map.get(&Atom::Key(":name")) {
|
||||
name = String::from(*n);
|
||||
}
|
||||
if let Some(Edn::Str(n)) = map.get(&Edn::Key(":dir")) {
|
||||
if let Some(Atom::Str(n)) = map.get(&Atom::Key(":dir")) {
|
||||
dir = String::from(*n);
|
||||
}
|
||||
},
|
||||
Edn::List(args) => match args.first() {
|
||||
Some(Edn::Symbol("sample")) => {
|
||||
let (midi, sample) = MidiSample::from_edn((jack, &dir), &args[1..])?;
|
||||
Atom::List(args) => match args.first() {
|
||||
Some(Atom::Symbol("sample")) => {
|
||||
let (midi, sample) = MidiSample::from_atom((jack, &dir), &args[1..])?;
|
||||
if let Some(midi) = midi {
|
||||
samples.insert(midi, sample);
|
||||
} else {
|
||||
|
|
@ -373,27 +373,27 @@ from_edn!("sampler" => |jack: &Arc<RwLock<JackConnection>>, args| -> crate::Samp
|
|||
},
|
||||
_ => panic!("unexpected in sampler {name}: {args:?}")
|
||||
},
|
||||
_ => panic!("unexpected in sampler {name}: {edn:?}")
|
||||
_ => panic!("unexpected in sampler {name}: {atom:?}")
|
||||
});
|
||||
Self::new(jack, &name)
|
||||
});
|
||||
from_edn!("sample" => |(_jack, dir): (&Arc<RwLock<JackConnection>>, &str), args| -> MidiSample {
|
||||
from_atom!("sample" => |(_jack, dir): (&Arc<RwLock<JackConnection>>, &str), args| -> MidiSample {
|
||||
let mut name = String::new();
|
||||
let mut file = String::new();
|
||||
let mut midi = None;
|
||||
let mut start = 0usize;
|
||||
edn!(edn in args {
|
||||
Edn::Map(map) => {
|
||||
if let Some(Edn::Str(n)) = map.get(&Edn::Key(":name")) {
|
||||
atom!(atom in args {
|
||||
Atom::Map(map) => {
|
||||
if let Some(Atom::Str(n)) = map.get(&Atom::Key(":name")) {
|
||||
name = String::from(*n);
|
||||
}
|
||||
if let Some(Edn::Str(f)) = map.get(&Edn::Key(":file")) {
|
||||
if let Some(Atom::Str(f)) = map.get(&Atom::Key(":file")) {
|
||||
file = String::from(*f);
|
||||
}
|
||||
if let Some(Edn::Int(i)) = map.get(&Edn::Key(":start")) {
|
||||
if let Some(Atom::Int(i)) = map.get(&Atom::Key(":start")) {
|
||||
start = *i as usize;
|
||||
}
|
||||
if let Some(Edn::Int(m)) = map.get(&Edn::Key(":midi")) {
|
||||
if let Some(Atom::Int(m)) = map.get(&Atom::Key(":midi")) {
|
||||
midi = Some(u7::from(*m as u8));
|
||||
}
|
||||
},
|
||||
|
|
@ -661,14 +661,14 @@ pub enum SamplerMode {
|
|||
Select(usize),
|
||||
Sample(SamplerCommand),
|
||||
}
|
||||
edn_command!(SamplerTuiCommand: |state: SamplerTui| {
|
||||
atom_command!(SamplerTuiCommand: |state: SamplerTui| {
|
||||
("select" [i: usize] Self::Select(i.expect("no index")))
|
||||
("import" [a, ..b] if let Some(command) = FileBrowserCommand::from_edn(state, a, b) {
|
||||
("import" [a, ..b] if let Some(command) = FileBrowserCommand::from_atom(state, a, b) {
|
||||
Self::Import(command)
|
||||
} else {
|
||||
return None
|
||||
})
|
||||
("sample" [a, ..b] if let Some(command) = SamplerCommand::from_edn(&state.state, a, b) {
|
||||
("sample" [a, ..b] if let Some(command) = SamplerCommand::from_atom(&state.state, a, b) {
|
||||
Self::Sample(command)
|
||||
} else {
|
||||
return None
|
||||
|
|
@ -677,7 +677,7 @@ edn_command!(SamplerTuiCommand: |state: SamplerTui| {
|
|||
provide!(usize: |self: SamplerTui| {});
|
||||
provide!(PathBuf: |self: SamplerTui| {});
|
||||
provide!(Arc<str>: |self: SamplerTui| {});
|
||||
edn_command!(FileBrowserCommand: |state: SamplerTui| {
|
||||
atom_command!(FileBrowserCommand: |state: SamplerTui| {
|
||||
("begin" [] Self::Begin)
|
||||
("cancel" [] Self::Cancel)
|
||||
("confirm" [] Self::Confirm)
|
||||
|
|
@ -695,7 +695,7 @@ edn_command!(FileBrowserCommand: |state: SamplerTui| {
|
|||
NoteOn(u7, u7),
|
||||
NoteOff(u7),
|
||||
}
|
||||
edn_command!(SamplerCommand: |state: Sampler| {
|
||||
atom_command!(SamplerCommand: |state: Sampler| {
|
||||
("record/begin" [i: u7]
|
||||
Self::RecordBegin(i.expect("no index")))
|
||||
("record/cancel" []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue