Audacity in QjackCtl: Why are PortAudio capture ports incremented with each reconnect?


I’m an audio sysadmin at a small community radio station. Currently I’m preparing a setup for a new mixer that is playing its output through spdif over a Focusrite Scarlett interface into the computer. For recording we have so far always used Audacity. In my current setup I’m routing the input via QjackCtl into Audacity. Basically that is working.

My problem: spdif is coming in on channel 11 and 12. Now, when I want to do a simple stereo recording (the standard procedure for radio) by 1) clicking pause in Audacity and 2) click the record button, QjackCtl automatically connects ‘capture_1’ to PortAudio ‘in_’ and ‘capture_2’ to PortAudio ‘in_<number+1>’. That would be fine if the mixer output came over 1 and 2 but as already mentioned it’s 11 + 12 and hence the user has to manually re-connect ins and outs.

I’ve been able to to partially solve the problem by creating an xml patchbay setup that always connects ‘capture_11’ to ‘in_3’ and ‘capture_12’ to ‘in_4’. But that only works as long as a recording session isn’t stopped! (By ‘stopped’ I mean ‘stopped’ and not ‘paused’). Creating a new recording session in the way that I’ve described in the last paragraph will always increment the numbering of the PortAudio ‘in’ ports, and hence my patchbay setup doesn’t work anymore as it depends on fixed numbering of the PortAudio ins.

Is there any way to fix PortAudio in numbering in Audacity or is this something PortAudio does on its own and Audacity has no influence on? This is a real showstopper.

Any ideas what I could do?

There’s probably an easy solution, but I’m not sure how your setup appears in QjackCtl. Please post a screenshot of the “Connect” screen from QjackCtl (with everything set up and running).

  1. my Audacity preferences
  2. My QjackCtl setup. On the left side I added only 11 & 12 as these are the only inputs that I’m interested. in_4 & in_5 are the only capture ports that I get offered by PortAudio (resulting from the stereo track in Audacity by clicking “pause” and then “record”). Once stored somewhere on my computer I can load it from “Preferences” > “Options” > “Connections”
  3. After quitting Audacity, stopping QjackCtl, restarting QjackCtl, restarting Audacity, creating a new stereo track by clicking “pause” and then “record” I get the following connections in QjackCtl
  4. After stopping (not pausing), deleting the stereo track and again clicking “pause” and then “record” in Audacity I get the following connections. Note that instead of in_4 and in_5 I now get in_6 and in_7 which are not part of my stored setup, hence in_1 and in_2 get connected, not in_11 and in_12
    Does make the situation clearer?

Probably the easiest solution is to run a “dummy” jack plug-in, for example “jack mixer” or “jack rack”.
Configure the “dummy” plug-in so that it has two input channels that pass directly through to two output channels.

You can then use QjackCtl to connect the spdif (channels 11 and 12) to the input of the “dummy”, and in Audacity’s “Device Toolbar” ( select the output of the “dummy” as the recording input.

My sound card only is only stereo in / out, but this should give you an idea:


The alternative way is to select Audacity’s ports in QjackCtl using regex. This ancient post is about Audacity 1.3.x but it should still work:

Thanks very much for your reply, Steve. I guess, the “alternative” way is the easier option to achieve what I need - I’ve stumbled on that post before but just now I understood how it works. However I’ve improved the regex a bit, so now it works for arbitrarily high even and odd numbers, hence allowing the user to create as many new tracks as (s)he likes, always (automatically) creating the right connections in QjackCtl.

connect to even-numbered ins in PortAudio:


connect to odd-numbered ins in PortAudio:


I must confess I haven’t been able to create that “dummy” plugin that you described in your first post. I guess you meant defining a plugin in ~/.asoundrc or /etc/asoundrc.conf? I’ve followed instructions from and but the plugin I defined never appeared in the Audacity device toolbar or the list of devices in the Audacity preferences. Anyway, if I understood correctly, the connections would still have to be done manually in QjackCtl (which could probably be automated as described earlier).

The whole issue is about allowing users to record the S/P Dif input without ever having to touch QjackCtl (i.e. not having connect anything manually). As long as people only want to record a single stereo output (which is normal for radiomaking) I don’t want to impose an extra demand of having to connect the right ins and outs with every new take.

Thanks again, Stefan

Nothing so complicated :wink:
I just meant installing any Jack application that allows you to have it’s inputs connected directly to it’s outputs without modifying the audio data. In my example I used “Jack Mixer” (Ubuntu – Package Search Results -- jack mixer). “Jack Rack” also works (Ubuntu – Package Search Results -- jack rack)

Ah, thanks :smiley: :smiley: … I really didn’t think of that. Anyway, I think I’m perfectly happy with what I got now. A Jack plugin adds yet another layer of complication, I think. For someone who knows what can be done with these tools that might be perfect but in my case less is better - just a simple setup that sarts automatically when the computer gets booted, press ‘record’ and ‘stop’, repeated as often as needed, not having to worry about making the right connections in Jack. That’s what I want!

Thanks very much!

Can someone explain the regex trick? The link is sadly dead.