theNizo / linux_rocksmith

Guides to get Rocksmith 2014 running on Linux
https://thenizo.github.io/linux_rocksmith/
GNU General Public License v3.0
110 stars 10 forks source link

Any way to persist jack routing? #41

Open akamensky opened 10 months ago

akamensky commented 10 months ago

Fedora 39

Proton 8.0 (current version)

yes pipewire-jack-audio-kit (as is default on Fedora)

I need to re-create routing in Jack patchbay every time I start Rocksmith. Not sure if it is expected and whether there are any workarounds for that. In theory jack can be told to auto-route devices based on last known configuration. And it appears to do so for other things, but not wineasio device.

Edit:

I switched to qJackCtl instead, where I can go to (less graphical) patchbay, setup the plugs and save the profile with these connections. Then when the "rocksmith 2014" device comes up (when game started), I can tab-out to qJackCtl and hit "Acitvate", which will reconnect all devices as I need them. Then when game exited I should de-activate the profile, otherwise the game will crash on next start. This is an improvement, though still not ideal.

theNizo commented 10 months ago

As far as I understand, there's NO connection in the patchbay at all to Rocksmith?

This is new behavior to me, unfortunately.

I'm pretty sure I've seen someone run a script to start the game and then set the connections up, but I wasn't able to find it right now. (Not on Customsforge, couldn't find it in the issues of this repo, maybe on Reddit, but I didn't look there.)

I don't have any other idea right now, I'm sorry. The following will be about a way to automate the patchbay setup.


I was thinking of something like this originally. I needed the package jack-example-tools on Arch, so my guess is jack-audio-connection-kit-example-clients on Fedora? It would look something like this, but write down the first command (launching the game) properly, but don't forget about the & at the end:

PIPEWIRE_LATENCY= [...] rocksmith_launcher.sh &

sleep 8 # or any value that fits

jack_connect "Rocksmith Guitar Adapter Mono:capture_MONO" "Rocksmith2014:in_1"
jack_connect "Rocksmith2014:out_1" <output_L>
jack_connect "Rocksmith2014:out_2" <output_R>

Or maybe the easier way since you have a qjackctl definition, you could also load that via qjackctl -a <file>.

akamensky commented 10 months ago

Basically what happens is that the asio device registers and deregisters when the RS started or stopped. But jack doesn't remember routes between those.

I found a C++ tool that listens for jack notifications for device registration and will patch devices according to configuration. I will give it a try later and update here if that works.

theNizo commented 8 months ago

In the last step, are you using the LD_PRELOAD route, or the start script one?

Autowiring works with the start script, not with LD_PRELOAD.

akamensky commented 8 months ago

In the last step, are you using the LD_PRELOAD route, or the start script one?

LDPRELOAD. I will try changing to the script and see whether this fixes it.

KczBen commented 5 months ago

Hey, I made a small script using jack-matchmaker to automatically make the connections on startup. It's not pretty, but it gets the job done without a wrapper script around the entire game.

#!/bin/bash
while [ "$(xdotool getwindowfocus getwindowname)" != "Rocksmith 2014" ]; do
    sleep 1
done

sleep 5

xdotool search --name "Rocksmith 2014" windowunmap
/home/bence/anaconda3/bin/jack-matchmaker -e 'Scarlett Solo (3rd Gen.) Pro:capture_AUX0' Rocksmith2014:in_1 'Scarlett Solo (3rd Gen.) Pro:capture_AUX1' Rocksmith2014:in_2 Rocksmith2014:out_1 'Arctis Nova Pro Wireless Analog Stereo:playback_FL' Rocksmith2014:out_2 'Arctis Nova Pro Wireless Analog Stereo:playback_FR' &

sleep 1
pkill jack-matchmaker
xdotool search --name "Rocksmith 2014" windowmap &

You'll need to replace the input and output nodes of your own. You can get them by first connecting the game manually in QJackCtl, and then run jack-matchmaker -c Rocksmith which will give you the nodes you need. Then you can include it in your launch options as such /path/to/script >> /tmp/rs-autoconnect.out 2>&1 & LD_PRELOAD=/usr/lib/i386-linux-gnu/pipewire-0.3/jack/libjack.so PIPEWIRE_LATENCY=128/48000 %command% && pkill jack-matchmaker Note that you need to kill jack-matchmaker at the end so the game doesn't crash if you restart it.

Short explanation on what the script does... or at least should do. Loops before the game starts, this should get around timing issues with different setups. Then it waits 5 seconds for the game to start, just to make sure. Next it unfocuses the window, which is surprisingly a necessary step to avoid the game crashing. It connects the nodes with jack-matchmaker, which might need the full file path as I noted there. Finally it refocuses the game and all should be well.

Could probably clean it up or even make the setup all automatic if there's interest?

Edit: Changed loop to be more reliable. Now it times from when the window shows up, not when the process spawns. Should make detection more consistent and help with slower drives.