diff --git a/src/wrapper/standalone/backend/jack.rs b/src/wrapper/standalone/backend/jack.rs index c730c3f6..b50c4328 100644 --- a/src/wrapper/standalone/backend/jack.rs +++ b/src/wrapper/standalone/backend/jack.rs @@ -125,7 +125,25 @@ impl Jack { outputs.push(port); } - // TODO: Command line argument to connect the inputs? + // This option can either be set to a single port all inputs should be connected to, or a + // comma separated list of ports + if let Some(port_name) = config.connect_jack_inputs { + if port_name.contains(',') { + for (port_name, input) in port_name.split(',').zip(&inputs) { + if let Err(err) = client.connect_ports_by_name(port_name, &input.name()?) { + nih_error!("Could not connect to '{port_name}': {err}"); + break; + } + } + } else { + for input in &inputs { + if let Err(err) = client.connect_ports_by_name(&port_name, &input.name()?) { + nih_error!("Could not connect to '{port_name}': {err}"); + break; + } + } + } + } Ok(Self { client: Some(client), diff --git a/src/wrapper/standalone/config.rs b/src/wrapper/standalone/config.rs index 798a3f44..317a7bb5 100644 --- a/src/wrapper/standalone/config.rs +++ b/src/wrapper/standalone/config.rs @@ -28,6 +28,15 @@ pub struct WrapperConfig { #[clap(value_parser, short = 'p', long, default_value = "512")] pub period_size: u32, + /// If set to a port name ('foo:bar_1'), then all all inputs will be connected to that port. If + /// the option is set to a comma separated list of port names ('foo:bar_1,foo:bar_2') then the + /// input ports will be connected in that order. No inputs will be connected if the port option + /// is not set. + /// + /// This option is only used with the JACK backend. + #[clap(value_parser, long)] + pub connect_jack_inputs: Option, + /// The editor's DPI scaling factor. /// /// This option is ignored on macOS.