mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: edn minefield
This commit is contained in:
parent
98d2107e4e
commit
6f51872856
7 changed files with 150 additions and 210 deletions
|
|
@ -10,22 +10,24 @@ mod groovebox_audio; pub use self::groovebox_audio::*;
|
|||
mod groovebox_command; pub use self::groovebox_command::*;
|
||||
mod groovebox_tui; pub use self::groovebox_tui::*;
|
||||
|
||||
pub struct Groovebox {
|
||||
pub struct Groovebox<'a> {
|
||||
_jack: Arc<RwLock<JackConnection>>,
|
||||
pub view: EdnView<'a, Tui, Self>,
|
||||
|
||||
pub player: MidiPlayer,
|
||||
pub pool: PoolModel,
|
||||
pub editor: MidiEditor,
|
||||
pub sampler: Sampler,
|
||||
pub player: MidiPlayer,
|
||||
pub pool: PoolModel,
|
||||
pub editor: MidiEditor,
|
||||
pub sampler: Sampler,
|
||||
|
||||
pub compact: bool,
|
||||
pub size: Measure<Tui>,
|
||||
pub status: bool,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub perf: PerfModel,
|
||||
pub compact: bool,
|
||||
pub size: Measure<Tui>,
|
||||
pub status: bool,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub perf: PerfModel,
|
||||
}
|
||||
impl Groovebox {
|
||||
|
||||
impl<'a> Groovebox<'a> {
|
||||
pub fn new (
|
||||
jack: &Arc<RwLock<JackConnection>>,
|
||||
midi_from: &[impl AsRef<str>],
|
||||
|
|
@ -55,7 +57,49 @@ impl Groovebox {
|
|||
midi_buf: vec![vec![];65536],
|
||||
note_buf: vec![],
|
||||
perf: PerfModel::default(),
|
||||
|
||||
view: EdnView::from(include_str!("groovebox/groovebox.edn")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
has_clock!(|self: Groovebox|self.player.clock());
|
||||
|
||||
impl<'a> EdnLayout<'a, Tui> for Groovebox {
|
||||
fn get_bool (&self, item: &Item<&str>) -> bool { todo!() }
|
||||
fn get_unit (&self, item: &Item<&str>) -> u16 {
|
||||
match item {
|
||||
Sym(":sample-h") => if self.compact { 0 } else { 5 },
|
||||
Sym(":samples-w") => if self.compact { 4 } else { 11 },
|
||||
Sym(":samples-y") => if self.compact { 1 } else { 0 },
|
||||
Sym(":pool-w") => if self.compact { 5 } else {
|
||||
let w = self.size.w();
|
||||
if w > 60 { 20 } else if w > 40 { 15 } else { 10 }
|
||||
},
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
fn get_content (&self, item: &Item<&str>) -> Box<dyn Render<Tui> + '_> {
|
||||
match item {
|
||||
Sym(":input-meter-l") => Box::new(Meter("L/", self.sampler.input_meter[0])),
|
||||
Sym(":input-meter-r") => Box::new(Meter("R/", self.sampler.input_meter[1])),
|
||||
|
||||
Sym(":transport") => Box::new(TransportView::new(true, &self.player.clock)),
|
||||
Sym(":clip-play") => Box::new(ClipSelected::play_phrase(&self.player)),
|
||||
Sym(":clip-next") => Box::new(ClipSelected::next_phrase(&self.player)),
|
||||
Sym(":clip-edit") => Box::new(MidiEditClip(&self.editor)),
|
||||
Sym(":edit-stat") => Box::new(MidiEditStatus(&self.editor)),
|
||||
Sym(":pool-view") => Box::new(PoolView(self.compact, &self.pool)),
|
||||
Sym(":midi-view") => Box::new(&self.editor),
|
||||
|
||||
Sym(":sample-view") => Box::new(SampleViewer::from_sampler(
|
||||
&self.sampler, self.editor.note_point())),
|
||||
Sym(":sample-stat") => Box::new(SamplerStatus(
|
||||
&self.sampler, self.editor.note_point())),
|
||||
Sym(":samples-view") => Box::new(SampleList::new(
|
||||
self.compact, &self.sampler, &self.editor)),
|
||||
|
||||
_ => Box::new(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,45 +4,6 @@ use std::marker::ConstParamTy;
|
|||
use tek_engine::Render;
|
||||
use Item::*;
|
||||
|
||||
impl EdnLayout<Tui> for Groovebox {
|
||||
fn get_bool (&self, item: &Item<&str>) -> bool { todo!() }
|
||||
fn get_unit (&self, item: &Item<&str>) -> u16 {
|
||||
match item {
|
||||
Sym(":sample-h") => if self.compact { 0 } else { 5 },
|
||||
Sym(":samples-w") => if self.compact { 4 } else { 11 },
|
||||
Sym(":samples-y") => if self.compact { 1 } else { 0 },
|
||||
Sym(":pool-w") => if self.compact { 5 } else {
|
||||
let w = self.size.w();
|
||||
if w > 60 { 20 } else if w > 40 { 15 } else { 10 }
|
||||
},
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
fn get_content (&self, item: &Item<&str>) -> Box<dyn Render<Tui> + '_> {
|
||||
match item {
|
||||
Sym(":input-meter-l") => Box::new(Meter("L/", self.sampler.input_meter[0])),
|
||||
Sym(":input-meter-r") => Box::new(Meter("R/", self.sampler.input_meter[1])),
|
||||
|
||||
Sym(":transport") => Box::new(TransportView::new(true, &self.player.clock)),
|
||||
Sym(":clip-play") => Box::new(ClipSelected::play_phrase(&self.player)),
|
||||
Sym(":clip-next") => Box::new(ClipSelected::next_phrase(&self.player)),
|
||||
Sym(":clip-edit") => Box::new(MidiEditClip(&self.editor)),
|
||||
Sym(":edit-stat") => Box::new(MidiEditStatus(&self.editor)),
|
||||
Sym(":pool-view") => Box::new(PoolView(self.compact, &self.pool)),
|
||||
Sym(":midi-view") => Box::new(&self.editor),
|
||||
|
||||
Sym(":sample-view") => Box::new(SampleViewer::from_sampler(
|
||||
&self.sampler, self.editor.note_point())),
|
||||
Sym(":sample-stat") => Box::new(SamplerStatus(
|
||||
&self.sampler, self.editor.note_point())),
|
||||
Sym(":samples-view") => Box::new(SampleList::new(
|
||||
self.compact, &self.sampler, &self.editor)),
|
||||
|
||||
_ => Box::new(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render!(Tui: (self: Groovebox) => self.size.of(
|
||||
Bsp::s(self.toolbar_view(),
|
||||
Bsp::n(self.selector_view(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue