mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
55 lines
1.9 KiB
Rust
55 lines
1.9 KiB
Rust
use crate::*;
|
|
impl HasJack<'static> for App {
|
|
fn jack (&self) -> &Jack<'static> {
|
|
&self.jack
|
|
}
|
|
}
|
|
audio!(
|
|
|self: App, client, scope|{
|
|
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 {ref 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
|
|
};
|
|
|self, event|{
|
|
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:?}"); }
|
|
}
|
|
}
|
|
);
|