mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 15:56:57 +02:00
restruct: 25e
This commit is contained in:
parent
c737c7d839
commit
3bbe52093e
11 changed files with 454 additions and 432 deletions
57
src/app.rs
57
src/app.rs
|
|
@ -1,4 +1,5 @@
|
|||
use crate::*;
|
||||
pub mod audio; pub use self::audio::*;
|
||||
pub mod bind; pub use self::bind::*;
|
||||
pub mod cli; pub use self::cli::*;
|
||||
pub mod config; pub use self::config::*;
|
||||
|
|
@ -123,57 +124,6 @@ impl App {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn jack_process (
|
||||
&mut self, client: &Client, scope: &ProcessScope
|
||||
) -> Control {
|
||||
let t0 = self.perf.get_t0();
|
||||
self.clock().update_from_scope(scope).unwrap();
|
||||
let midi_in = self.project.midi_input_collect(scope);
|
||||
if let Some(editor) = &self.editor() {
|
||||
let mut pitch: Option<u7> = None;
|
||||
for port in midi_in.iter() {
|
||||
for event in port.iter() {
|
||||
if let (_, Ok(LiveEvent::Midi {message: MidiMessage::NoteOn {key, ..}, ..}))
|
||||
= event
|
||||
{
|
||||
pitch = Some(key.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(pitch) = pitch {
|
||||
editor.set_note_pos(pitch.as_int() as usize);
|
||||
}
|
||||
}
|
||||
let result = self.project.process_tracks(client, scope);
|
||||
self.perf.update_from_jack_scope(t0, scope);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn jack_event (
|
||||
&mut self, event: JackEvent
|
||||
) {
|
||||
use JackEvent::*;
|
||||
match event {
|
||||
SampleRate(sr) => { self.clock().timebase.sr.set(sr as f64); },
|
||||
PortRegistration(_id, true) => {
|
||||
//let port = self.jack().port_by_id(id);
|
||||
//println!("\rport add: {id} {port:?}");
|
||||
//println!("\rport add: {id}");
|
||||
},
|
||||
PortRegistration(_id, false) => {
|
||||
/*println!("\rport del: {id}")*/
|
||||
},
|
||||
PortsConnected(_a, _b, true) => { /*println!("\rport conn: {a} {b}")*/ },
|
||||
PortsConnected(_a, _b, false) => { /*println!("\rport disc: {a} {b}")*/ },
|
||||
ClientRegistration(_id, true) => {},
|
||||
ClientRegistration(_id, false) => {},
|
||||
ThreadInit => {},
|
||||
XRun => {},
|
||||
GraphReorder => {},
|
||||
_ => { panic!("{event:?}"); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Update memoized render of clock values.
|
||||
/// ```
|
||||
/// tek::App::default().update_clock();
|
||||
|
|
@ -389,8 +339,6 @@ impl_as_mut_opt!(MidiEditor: |self: App|self.project.as_mut_opt());
|
|||
|
||||
impl_has_clips!( |self: App|self.pool.clips);
|
||||
|
||||
impl_audio!(App: tek_jack_process, tek_jack_event);
|
||||
|
||||
namespace!(App: Arc<str> { literal = |dsl|Ok(dsl.src()?.map(|x|x.into())); });
|
||||
|
||||
namespace!(App: u8 { literal = |dsl|try_to_u8(dsl); });
|
||||
|
|
@ -564,13 +512,14 @@ fn app_interpret_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usua
|
|||
})))
|
||||
}.draw(to),
|
||||
|
||||
Some(":sessions") => h_exact(Some(6), w_min(30, thunk(|to: &mut Tui|{
|
||||
Some(":sessions") => h_exact(Some(6), w_min(Some(30), thunk(|to: &mut Tui|{
|
||||
let fg = Rgb(224, 192, 128);
|
||||
for (index, name) in ["session1", "session2", "session3"].iter().enumerate() {
|
||||
let bg = if index == 0 { Rgb(50,50,50) } else { Rgb(40,40,40) };
|
||||
y_push((2 * index) as u16,
|
||||
&h_exact(2, w_full(bg(bg, origin_w(fg(fg, name)))))).draw(to);
|
||||
}
|
||||
Ok(())
|
||||
}))).draw(to),
|
||||
|
||||
Some(":browse/title") => w_full(origin_w(field_v(ItemColor::default(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue