mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
95 lines
3.7 KiB
Rust
95 lines
3.7 KiB
Rust
use crate::*;
|
|
impl HasJack for Tek { fn jack (&self) -> &Jack { &self.jack } }
|
|
audio!(
|
|
|self: Tek, client, scope|{
|
|
// Start profiling cycle
|
|
let t0 = self.perf.get_t0();
|
|
// Update transport clock
|
|
self.clock().update_from_scope(scope).unwrap();
|
|
// Collect MIDI input (TODO preallocate)
|
|
let midi_in = self.midi_ins.iter()
|
|
.map(|port|port.port().iter(scope)
|
|
.map(|RawMidi { time, bytes }|(time, LiveEvent::parse(bytes)))
|
|
.collect::<Vec<_>>())
|
|
.collect::<Vec<_>>();
|
|
// Update standalone MIDI sequencer
|
|
//if let Some(player) = self.player.as_mut() {
|
|
//if Control::Quit == PlayerAudio(
|
|
//player,
|
|
//&mut self.note_buf,
|
|
//&mut self.midi_buf,
|
|
//).process(client, scope) {
|
|
//return Control::Quit
|
|
//}
|
|
//}
|
|
// Update standalone sampler
|
|
//if let Some(sampler) = self.sampler.as_mut() {
|
|
//if Control::Quit == SamplerAudio(sampler).process(client, scope) {
|
|
//return Control::Quit
|
|
//}
|
|
//for port in midi_in.iter() {
|
|
//for message in port.iter() {
|
|
//match message {
|
|
//Ok(M
|
|
//}
|
|
//}
|
|
//}
|
|
//}
|
|
// TODO move these to editor and sampler?:
|
|
//for port in midi_in.iter() {
|
|
//for event in port.iter() {
|
|
//match event {
|
|
//(time, Ok(LiveEvent::Midi {message, ..})) => match message {
|
|
//MidiMessage::NoteOn {ref key, ..} if let Some(editor) = self.editor.as_ref() => {
|
|
//editor.set_note_pos(key.as_int() as usize);
|
|
//},
|
|
//MidiMessage::Controller {controller, value} if let (Some(editor), Some(sampler)) = (
|
|
//self.editor.as_ref(),
|
|
//self.sampler.as_ref(),
|
|
//) => {
|
|
//// TODO: give sampler its own cursor
|
|
//if let Some(sample) = &sampler.mapped[editor.note_pos()] {
|
|
//sample.write().unwrap().handle_cc(*controller, *value)
|
|
//}
|
|
//}
|
|
//_ =>{}
|
|
//},
|
|
//_ =>{}
|
|
//}
|
|
//}
|
|
//}
|
|
// Update track sequencers
|
|
for track in self.tracks.iter_mut() {
|
|
if PlayerAudio(
|
|
track.player_mut(), &mut self.note_buf, &mut self.midi_buf
|
|
).process(client, scope) == Control::Quit {
|
|
return Control::Quit
|
|
}
|
|
}
|
|
// End profiling cycle
|
|
self.perf.update_from_jack_scope(t0, scope);
|
|
Control::Continue
|
|
};
|
|
|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:?}"); }
|
|
}
|
|
}
|
|
);
|