1
0
Fork 0

Add auto connecting for JACK MIDI ports

This commit is contained in:
Robbert van der Helm 2022-06-14 21:43:26 +02:00
parent 5cd4bb8de0
commit e967e04856
2 changed files with 23 additions and 1 deletions

View file

@ -133,7 +133,6 @@ impl Jack {
outputs.push(port); outputs.push(port);
} }
// TODO: CLI arguments to connect the MIDI input and output ports
let midi_input = if P::MIDI_INPUT >= MidiConfig::Basic { let midi_input = if P::MIDI_INPUT >= MidiConfig::Basic {
Some(Arc::new(client.register_port("midi_input", MidiIn)?)) Some(Arc::new(client.register_port("midi_input", MidiIn)?))
} else { } else {
@ -168,6 +167,17 @@ impl Jack {
} }
} }
if let (Some(port), Some(port_name)) = (&midi_input, config.connect_jack_midi_input) {
if let Err(err) = client.connect_ports_by_name(&port_name, &port.name()?) {
nih_error!("Could not connect to '{port_name}': {err}");
}
}
if let (Some(port), Some(port_name)) = (&midi_output, config.connect_jack_midi_output) {
if let Err(err) = client.connect_ports_by_name(&port.borrow().name()?, &port_name) {
nih_error!("Could not connect to '{port_name}': {err}");
}
}
Ok(Self { Ok(Self {
client: Some(client), client: Some(client),

View file

@ -37,6 +37,18 @@ pub struct WrapperConfig {
#[clap(value_parser, long)] #[clap(value_parser, long)]
pub connect_jack_inputs: Option<String>, pub connect_jack_inputs: Option<String>,
/// If set, then the plugin's MIDI input port will be connected to this JACK MIDI output port.
///
/// This option is only used with the JACK backend.
#[clap(value_parser, long)]
pub connect_jack_midi_input: Option<String>,
/// If set, then the plugin's MIDI output port will be connected to this JACK MIDI input port.
///
/// This option is only used with the JACK backend.
#[clap(value_parser, long)]
pub connect_jack_midi_output: Option<String>,
/// The editor's DPI scaling factor. /// The editor's DPI scaling factor.
/// ///
/// This option is ignored on macOS. /// This option is ignored on macOS.