mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: optional dependency from mixer to sampler and plugin
This commit is contained in:
parent
a819e042c7
commit
6dd4caeb42
18 changed files with 330 additions and 316 deletions
|
|
@ -14,7 +14,7 @@ tek_sampler = { path = "../tek_sampler" }
|
|||
tek_sequencer = { path = "../tek_sequencer" }
|
||||
tek_timer = { path = "../tek_timer" }
|
||||
tek_chain = { path = "../tek_chain" }
|
||||
tek_mixer = { path = "../tek_mixer" }
|
||||
tek_mixer = { path = "../tek_mixer", features = ["standalone_devices"] }
|
||||
#jack = "0.10"
|
||||
#crossterm = "0.27"
|
||||
#ratatui = { version = "0.26.3", features = [ "unstable-widget-ref", "underline-color" ] }
|
||||
|
|
@ -32,7 +32,6 @@ tek_mixer = { path = "../tek_mixer" }
|
|||
#fraction = "0.15.3"
|
||||
#rlsf = "0.2.1"
|
||||
#r8brain-rs = "0.3.5"
|
||||
#once_cell = "1.19.0"
|
||||
|
||||
#symphonia = { version = "0.5.4", features = [ "all" ] }
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ pub const KEYMAP_GLOBAL: &'static [KeyBinding<App>] = keymap!(App {
|
|||
/// Generic key bindings for views that support focus.
|
||||
pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
|
||||
[Char(';'), NONE, "command", "open command palette", |_: &mut App| {
|
||||
*MODAL.lock().unwrap() = Some(Box::new(crate::devices::help::HelpModal::new()));
|
||||
*MODAL.lock().unwrap() = Some(Box::new(HelpModal::new()));
|
||||
Ok(true)
|
||||
}],
|
||||
[Tab, NONE, "focus_next", "focus next area", focus_next],
|
||||
|
|
|
|||
|
|
@ -14,26 +14,15 @@
|
|||
//! * [LV2Plugin::load_edn]
|
||||
|
||||
use crate::*;
|
||||
use clojure_reader::{edn::{read, Edn}, error::Error as EdnError};
|
||||
|
||||
/// EDN parsing helper.
|
||||
macro_rules! edn {
|
||||
($edn:ident { $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
match $edn { $($pat => $expr),* }
|
||||
};
|
||||
($edn:ident in $args:ident { $($pat:pat => $expr:expr),* $(,)? }) => {
|
||||
for $edn in $args {
|
||||
edn!($edn { $($pat => $expr),* })
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
||||
pub fn from_edn (src: &str) -> Usually<Self> {
|
||||
let mut app = Self::new()?;
|
||||
app.load_edn(src)?;
|
||||
Ok(app)
|
||||
}
|
||||
|
||||
pub fn load_edn (&mut self, mut src: &str) -> Usually<&mut Self> {
|
||||
loop {
|
||||
match read(src) {
|
||||
|
|
@ -55,6 +44,7 @@ impl App {
|
|||
}
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
fn load_edn_one <'e> (&mut self, edn: Edn<'e>) -> Usually<()> {
|
||||
match edn {
|
||||
Edn::List(items) => {
|
||||
|
|
@ -69,10 +59,10 @@ impl App {
|
|||
}
|
||||
},
|
||||
Some(Edn::Symbol("scene")) => {
|
||||
tek_sequencer::Scene::load_edn(self, &items[1..])?;
|
||||
tek_sequencer::Scene::from_edn(self, &items[1..])?;
|
||||
},
|
||||
Some(Edn::Symbol("track")) => {
|
||||
tek_mixer::Track::load_edn(self, &items[1..])?;
|
||||
tek_mixer::MixerTrack::from_edn(self, &items[1..])?;
|
||||
},
|
||||
Some(Edn::Symbol("midi-in")) => {
|
||||
self.midi_ins = items[1..].iter().map(|x|match x {
|
||||
|
|
@ -105,62 +95,5 @@ impl App {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Phrase {
|
||||
fn load_edn <'e> (ppq: usize, args: &[Edn<'e>]) -> Usually<Self> {
|
||||
let mut phrase = Self::default();
|
||||
let mut name = String::new();
|
||||
let mut beats = 0usize;
|
||||
let mut steps = 0usize;
|
||||
edn!(edn in args {
|
||||
Edn::Map(map) => {
|
||||
if let Some(Edn::Str(n)) = map.get(&Edn::Key(":name")) {
|
||||
name = String::from(*n);
|
||||
}
|
||||
if let Some(Edn::Int(b)) = map.get(&Edn::Key(":beats")) {
|
||||
beats = *b as usize;
|
||||
phrase.length = ppq * beats;
|
||||
for _ in phrase.notes.len()..phrase.length {
|
||||
phrase.notes.push(Vec::with_capacity(16))
|
||||
}
|
||||
}
|
||||
if let Some(Edn::Int(s)) = map.get(&Edn::Key(":steps")) {
|
||||
steps = *s as usize;
|
||||
}
|
||||
},
|
||||
Edn::List(args) => {
|
||||
let time = (match args.get(0) {
|
||||
Some(Edn::Key(text)) => text[1..].parse::<f64>()?,
|
||||
Some(Edn::Int(i)) => *i as f64,
|
||||
Some(Edn::Double(f)) => f64::from(*f),
|
||||
_ => panic!("unexpected in phrase '{name}': {:?}", args.get(0)),
|
||||
} * beats as f64 * ppq as f64 / steps as f64) as usize;
|
||||
for edn in args[1..].iter() {
|
||||
match edn {
|
||||
Edn::List(args) => if let (
|
||||
Some(Edn::Int(key)),
|
||||
Some(Edn::Int(vel)),
|
||||
) = (
|
||||
args.get(0),
|
||||
args.get(1),
|
||||
) {
|
||||
let (key, vel) = (
|
||||
u7::from((*key as u8).min(127)),
|
||||
u7::from((*vel as u8).min(127)),
|
||||
);
|
||||
phrase.notes[time].push(MidiMessage::NoteOn { key, vel })
|
||||
} else {
|
||||
panic!("unexpected list in phrase '{name}'")
|
||||
},
|
||||
_ => panic!("unexpected in phrase '{name}': {edn:?}")
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => panic!("unexpected in phrase '{name}': {edn:?}"),
|
||||
});
|
||||
phrase.name = name;
|
||||
Ok(phrase)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ render!(SetupModal |self, buf, area| {
|
|||
Ok(area)
|
||||
});
|
||||
handle!(SetupModal |self, e| {
|
||||
if let AppEvent::Input(::crossterm::event::Event::Key(KeyEvent {
|
||||
if let AppEvent::Input(Event::Key(KeyEvent {
|
||||
code: KeyCode::Enter,
|
||||
..
|
||||
})) = e {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue