mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
partially fix port autoconnect
This commit is contained in:
parent
32dc708096
commit
8f3c83f8c3
3 changed files with 30 additions and 15 deletions
19
src/jack.rs
19
src/jack.rs
|
|
@ -45,20 +45,13 @@ impl JackClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn transport (&self) -> Transport {
|
pub fn transport (&self) -> Transport {
|
||||||
match self {
|
self.client().transport()
|
||||||
Self::Inactive(client) =>
|
|
||||||
client.transport(),
|
|
||||||
Self::Active(client) =>
|
|
||||||
client.as_client().transport(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn register_port <PS: PortSpec> (&self, name: &str, spec: PS) -> Usually<Port<PS>> {
|
pub fn port_by_name (&self, name: &str) -> Option<Port<Unowned>> {
|
||||||
Ok(match self {
|
self.client().port_by_name(name)
|
||||||
Self::Inactive(client) =>
|
}
|
||||||
client.register_port(name, spec)?,
|
pub fn register_port <PS: PortSpec> (&self, name: &str, spec: PS) -> Usually<Port<PS>> {
|
||||||
Self::Active(client) =>
|
Ok(self.client().register_port(name, spec)?)
|
||||||
client.as_client().register_port(name, spec)?,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
pub fn activate <T: Send + Sync + 'static> (
|
pub fn activate <T: Send + Sync + 'static> (
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
23
src/main.rs
23
src/main.rs
|
|
@ -18,6 +18,29 @@ pub fn main () -> Usually<()> {
|
||||||
.with_midi_ins(&["nanoKEY Studio.*capture.*"])?
|
.with_midi_ins(&["nanoKEY Studio.*capture.*"])?
|
||||||
.with_audio_outs(&["Komplete.+:playback_FL", "Komplete.+:playback_FR"])?
|
.with_audio_outs(&["Komplete.+:playback_FL", "Komplete.+:playback_FR"])?
|
||||||
.activate(Some(|app: &Arc<RwLock<App>>| {
|
.activate(Some(|app: &Arc<RwLock<App>>| {
|
||||||
|
let (midi_in, mut midi_outs) = {
|
||||||
|
let app = app.read().unwrap();
|
||||||
|
let jack = app.jack.as_ref().unwrap();
|
||||||
|
let midi_in = jack.register_port("midi-in", MidiIn)?;
|
||||||
|
let midi_outs = app.tracks.iter()
|
||||||
|
.map(|t|Some(jack.register_port(&t.name, MidiOut).unwrap()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
(midi_in, midi_outs)
|
||||||
|
};
|
||||||
|
{
|
||||||
|
let mut app = app.write().unwrap();
|
||||||
|
let jack = app.jack.as_ref().unwrap();
|
||||||
|
for name in app.midi_ins.iter() {
|
||||||
|
if let Some(port) = jack.client().port_by_name(&name) {
|
||||||
|
jack.client().connect_ports(&port, &midi_in)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.midi_in = Some(Arc::new(midi_in));
|
||||||
|
for (index, track) in app.tracks.iter_mut().enumerate() {
|
||||||
|
track.midi_out = midi_outs[index].take();
|
||||||
|
track.connect_first_device()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}))?;
|
}))?;
|
||||||
run(app)?;
|
run(app)?;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub struct App {
|
||||||
pub jack: Option<JackClient>,
|
pub jack: Option<JackClient>,
|
||||||
/// Map of external MIDI outs in the jack graph
|
/// Map of external MIDI outs in the jack graph
|
||||||
/// to internal MIDI ins of this app.
|
/// to internal MIDI ins of this app.
|
||||||
pub midi_in: Option<Port<MidiIn>>,
|
pub midi_in: Option<Arc<Port<MidiIn>>>,
|
||||||
/// Names of ports to connect to main MIDI IN.
|
/// Names of ports to connect to main MIDI IN.
|
||||||
pub midi_ins: Vec<String>,
|
pub midi_ins: Vec<String>,
|
||||||
/// Main audio outputs.
|
/// Main audio outputs.
|
||||||
|
|
@ -172,7 +172,6 @@ impl App {
|
||||||
})
|
})
|
||||||
.collect::<Usually<()>>())
|
.collect::<Usually<()>>())
|
||||||
.collect::<Usually<()>>()?;
|
.collect::<Usually<()>>()?;
|
||||||
self.midi_in = Some(midi_in);
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
pub fn activate (mut self, init: Option<impl FnOnce(&Arc<RwLock<Self>>)->Usually<()>>) -> Usually<Arc<RwLock<Self>>> {
|
pub fn activate (mut self, init: Option<impl FnOnce(&Arc<RwLock<Self>>)->Usually<()>>) -> Usually<Arc<RwLock<Self>>> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue