falkTX / Cadence

Collection of tools useful for audio production
GNU General Public License v2.0
368 stars 80 forks source link

Allow creation of multiple named Pulse Audio Sink/Sources #290

Open markjfisher opened 4 years ago

markjfisher commented 4 years ago

This is to implement #234

I have changed the Jack Bridges UI configuration into a new tab, grouped the ALSA, and created a new table that allows creating/editing new Pulse Audio connections.

This also allows users to change the default names of the Pulse Audio source/sinks

For illustration:

image

I am by no means a QT UI developer, but have tried to make it as intuitive as possible.

The configuration for the table is stored in GlobalSettings.conf for the UI, and also into ~/.pulse/jack-connections for the script cadence-pulse2jack to read and use.

My apologies for not pushing this change previously, but I haven't had access to a linux laptop for over a year, so the work was left almost complete, and I decided to resurrect it and complete it.

markjfisher commented 4 years ago

Here's a view of the pulse created connections in a Carla session:

image

And here they are in my system sound settings:

image

falkTX commented 4 years ago

That looks quite awesome, really.

Really makes me want to dedicate some time to Cadence. I have a couple of other things to finish, but will get on this afterwards. Sorry Cadence has been kinda lacking attention, I had to make a decision on what to do with the project. (and conclusion is: split the cadence tools into their own subprojects (Catia, jack-render, etc) while at the same time deprecating claudia/ladish and focus on NSM instead. Cadence will be for only managing jack and bridges)

markjfisher commented 4 years ago

Thanks! I hope it's useful for people.

Houston4444 commented 3 years ago

Hi ! I just took a look to this PR, it seems nice. Note that I made a similar PR https://github.com/falkTX/Cadence/pull/265 last year, and I think we could improve yours which is more complete. I have to admit, I didn't know we could change the name of a PulseAudio JACK group and its auto-connect mode.

But there is something important we can't do with your PR now: Add/remove alive a group without removing the running ones. It is important because you can choose to add/remove a source to gain some DSP, but many programs will complain if we shut off them audio output (worse, sometime they won't complain but they will stay muted).

TBH, I don't really see the interest of undo/save buttons, I don't think anyone will configure a very complex situation so long to write to really need this, I'd prefer an "update" button which could update all the PA bridges as I said in foregoing paragraph.

Little notes:

Something's bothering me a little. PA jack ports can take different names, and cadence-pulse2jack still checks if pulseaudio is brigded with

 if (`jack_lsp | grep "PulseAudio JACK Sink:" > /dev/null`); then
    {
        echo "PulseAudio is already running and bridged to JACK"
    }

So it's not correct if main group has a different name. Do you see any alternative to this ? Do you know if pulseaudio bridge writes some file somewhere, or maybe in dbus ?

Best Regards

markjfisher commented 3 years ago

Hi @Houston4444 - one of the things that drove me to finish this work was I'd seen your patch too!

I did notice the bug in the bridge name and have it changed locally, but haven't pushed the change to my branch yet

I've used this as a fix

-{
-
-    if (`jack_lsp | grep "PulseAudio JACK Sink:" > /dev/null`); then
-    {
+    # get the first sink name from the table
+    FIRST_SINK_NAME=$(grep '|sink|' $JACK_CONNFILE | head -1 | cut -d\| -f1)
+    if ($(jack_lsp 2>/dev/null | grep "$FIRST_SINK_NAME" > /dev/null)); then
         echo "PulseAudio is already running and bridged to JACK"

However, there may be other applications that use it as a default. But that's no excuse not to make it changeable.

Regarding your other comments:

I think @falkTX was talking of some big changes to Cadence to make it just an application for managing Jack and Bridges, so there's going to be some pretty major changes in hand, hopefully this PR will get in, or at least be a useful point to rebuild Cadence from.

Also, I hadn't discovered NSM until the comment above, and have moved over to that from Ladish myself, including picking up raysession this weekend too - small world.

markjfisher commented 3 years ago

@Houston4444 Also regarding your comment about adding a new group while running - this is an interesting point. I think it could be done with some clever handling of pa_ctl commands to insert just the new ones. It will probably require a rewrite of the bash script, as that's where all the logic occurs. I'll have a look at that too.

Houston4444 commented 3 years ago

Finally, "Undo" button can be useful, especially because Cadence goes to systray and the modifications wont be erased until a cadence restart, but I still think "Save" is useless and could be replaced by a direct "Update". Regarding your JACK_CONNFILE, Editing group name in table should be limited to alphanumeric + ' '. I had the vicious idea to include a '|' in a group name, obviously it does not works ;) , I can take a look if you don't see how to do that.

Also regarding your comment about adding a new group while running - this is an interesting point. I think it could be done with some clever handling of pa_ctl commands to insert just the new ones. It will probably require a rewrite of the bash script, as that's where all the logic occurs. I'll have a look at that too.

You can check the cadence-pulse2jack from my PR, it does this job.

my PR also allows a dialog box to configure channels from systray, this could be easily doable moving all your verticalLayout_21 (cadence.ui) in a QFrame. We could also add this dialog to Catia menu, but I don't know if it takes sense if Catia will be separated from the Cadence suite. @falkTX ?

Also, I hadn't discovered NSM until the comment above, and have moved over to that from Ladish myself, including picking up raysession this weekend too - small world.

TBH, I've seen your PR the day you pushed it, telling me I had to look at it. Your face looked familiar on your yesterday message ;) .

markjfisher commented 3 years ago

I've pushed a few changes:

I'm not removing the save button, as for me that is the key purpose. I only ever invoke Cadence to set the table values, and then save the data (which saves to ~/.pulse/jack-connections), and then use cadence-pulse2jack to load that data into pulse.

I'll look at the "live update" button tomorrow to change the currently running pulseaudio.

markjfisher commented 3 years ago

image

Houston4444 commented 3 years ago

Very good !

I'm not removing the save button, as for me that is the key purpose. I only ever invoke Cadence to set the table values, and then save the data (which saves to ~/.pulse/jack-connections), and then use cadence-pulse2jack to load that data into pulse.

I understand the idea. However, I still think that a "Save" and an "Update" (or "Apply') button will be counter-intuitive, I can already see myself clicking on "Apply" and wondering why nothing changes. Ohhh, I forgot to save.

I have some problems with combobox margins, also with the bridge status label, see below: Screenshot_20200721_095005

I saw in the code that the table headers are not translatable, please use translatable values here. I also have a little doubt about the "source" and "sink" display names, maybe "capture" and "playback" would be more understandable (or simply add loud speaker or microphone icon to combo items).

markjfisher commented 3 years ago

Really useful feedback @Houston4444, thankyou!

I've just pushed a cosmetic change to the auto-connect checkboxes to be centred. I still need to work out why it has a scroll bar at the bottom and a weird box on the right side of the checkbox header.

I was thinking about the save/apply, and think it's the same thing. I'll call it "Apply", so that it does 2 things; save and update the live changes. I still need the save because when I restart my laptop, I just want to apply the pulse changes using a script, rather than firing up cadence.

So, I'll work on:

What do you mean by "bridge status label"? Do you mean the "Pulseaudio started and bridged to JACK"? If so, what do you need to change? A bit more space above?

Houston4444 commented 3 years ago

I'll call it "Apply", so that it does 2 things; save and update the live changes.

Yes, that's what I was thinking.

What do you mean by "bridge status label"? Do you mean the "Pulseaudio started and bridged to JACK"? If so, what do you need to change? A bit more space above?

Exactly.

I will make you a PR for icons on type, it's really nicer.

markjfisher commented 3 years ago

I meant to comment on the icons; that sounds like a great idea too. PRs to this PR are more than welcome - i'm learning this as I go (I'm a java/kotlin backend dev rather than python/UI)

unbellver commented 3 years ago

Hi I installed this and add an alternative source and sink (having now in cadence jack bridges page 2 sinks and 2 sources) save it but doesnt show up in catia nor in pavucontrol as option in output/input tabs, only the original default bridges ("pulseaudio JACK source" and sink). Tried rebooting, stopping/starting jack server. I am in Kubuntu 20.04 kernel 5.4. I had previously installed and running kxstudio cadence version. What could i do? Sorry my english. Thnaks, i really need this functionallity! Fernando

falkTX commented 3 years ago

Just leaving a note here in case anyone is waiting on my feedback. I am quite busy with work lately, preparing for the launch of the MOD Dwarf unit.

There are big changes for cadence coming yes, but mostly it is about a split of catia and the tools into separate projects (so catia will be its own standalone thing, just like carla) claudia will be set as completely unsupported, still wondering if it is the best to remove it... but anyway, cadence itself stays, just more thin in the future as the "bigger" projects it includes will be either be made separate or killed.

ipatrol commented 1 year ago

Is there any reason this hasn't been pulled that I could help with? This feature would be very useful for mixing streams from programs that are not JACK-native.

Houston4444 commented 1 year ago

@ipatrol : note that I have already done something similar here: https://github.com/Houston4444/Cadence/tree/lzk4 . This is the Cadence version for Librazik4, fast adaptation never tested on another distribution.

markjfisher commented 1 year ago

Is there any reason this hasn't been pulled that I could help with? This feature would be very useful for mixing streams from programs that are not JACK-native.

I didn't follow up on Filipe's comment, and this lost priority for me, and my Python QT skills are pretty low so this was taking me more time than I'd have liked. Also, I wasn't sure of the longevity of this work if there was going to be a bit of a shake up with Cadence anyway, but that was 2 years ago.