mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
more sensible port creation
This commit is contained in:
parent
4028b3bb29
commit
bbe49ad463
7 changed files with 133 additions and 125 deletions
|
|
@ -1,7 +1,6 @@
|
|||
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();
|
||||
|
|
@ -14,20 +13,20 @@ audio!(
|
|||
.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
|
||||
}
|
||||
}
|
||||
//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
|
||||
}
|
||||
//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 {
|
||||
|
|
@ -35,30 +34,30 @@ audio!(
|
|||
//}
|
||||
//}
|
||||
//}
|
||||
}
|
||||
//}
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
_ =>{}
|
||||
},
|
||||
_ =>{}
|
||||
}
|
||||
}
|
||||
}
|
||||
//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(
|
||||
|
|
@ -71,20 +70,19 @@ audio!(
|
|||
self.perf.update(t0, scope);
|
||||
Control::Continue
|
||||
};
|
||||
|
||||
|self, event|{
|
||||
use JackEvent::*;
|
||||
match event {
|
||||
SampleRate(sr) =>
|
||||
{ self.clock.timebase.sr.set(sr as f64); },
|
||||
PortRegistration(id, true) =>
|
||||
{},
|
||||
{ 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) =>
|
||||
|
|
@ -93,6 +91,8 @@ audio!(
|
|||
{},
|
||||
XRun =>
|
||||
{},
|
||||
GraphReorder =>
|
||||
{},
|
||||
_ => { panic!("{event:?}"); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue