-
-
Notifications
You must be signed in to change notification settings - Fork 923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use pipewire on Linux if available (like on raspberry) #3347
Conversation
Wonderful, thanks. |
No I have three further changes that need to be implemented. 1: add an environmental variable to pi-build-gui.sh so that the build can find Qt6
2: add the start_sonic-pi_with_pw-jack script to the sonic-pi/bin folder 3: I have done a rewrite for the RASPBERRY-PI_BUILD.md which includes revised packages required, and details of how to start SP with the new start script. Also stuff about using qwpgraph to graphically alter audio device etc. It also has the script to let you do this from SP if you put it in your init.rb file. I've revised this to take on board better techniques used in Sergio's connection code. Code for the start script would be:
or we could set all the values the same at 1024 If you want to let me know your views I can send a PR for the three changes BTW I managed to get the debian version deb for 3.2.2 in their respository working but you have to switch off wayland and pipewire and install and use pavucontrol to control volume and change audio output becuase it is not at all happy with the RPi volume control widget. Not recommended. |
@rbnpi - what's the purpose of |
For v3.2.2 I think we need to patch that to use pipe wire rather than disable pipewire in the OS. |
It looks like it's just starting
|
I tried incorporating it elsewhere but I could only get it to work outside the entry to calling the sp binary. Just going to try another idea which might solve it…. |
Nice - I'm interested to see what you come up with. I honestly think that we should be looking at replacing the |
Basically pw-jack exports any parameters you give like the buffer size and then sets up a libarary path to the pipewire jack files before execiing the application. It just sets up the environment.
I've only got it to work by calling it before it calls the sonic-pi entry point. |
This works for flatpak linux as it is now.
It is not needed. If I understand correctly (take all this with a grain of salt, I'm by no means expert on any of this, I have learnt this only as I was fixing this for the flatpak), In that sense (@rbnpi correct me if I'm wrong or if this is different in Raspberry OS), |
Not completely true because it can be used for something else, which I guess it's why it's needed in raspberry: setting some values for the way jack apps interact with pipewire (sample rate and such) other than the defaults. |
Oh sorry @rbnpi, we wrote almost the same at almost the same time 😮💨 |
I tried |
Ah, that makes sense, wrapping SC is enough, you don't need to wrap the whole sonic pi. Well, if you go that route, that is ok with the linux flatpak. |
We could modify https://github.com/sonic-pi-net/sonic-pi/blob/dev/app/server/ruby/bin/daemon.rb#L1147C9-L1147C33 and then slip in the |
Although - I wonder how that would affect the ability to kill scsynth properly when we close down Sonic Pi as we won't have access to |
Another idea: all that |
Yep, that's also a good plan. The only thing that stopped me suggesting that before is that it means we need to keep up to date with whatever env vars pw-jack is setting. Assuming that's pretty static we should be fine. Of note, we already do significant env variable munging to start elixir as we can't use bat files on Windows due to security restrictions in some schools. Ruby is pretty good at this kind of thing. |
been playing around with it. The problem is retaining the setting. If you set LD_LIBRARY_PATH and then use Open3.popen2e to execute scsynth it is essentially in a different window and can't access the LD_LIBRARY_PATH entry. |
You can optionally pass an env argument to the popen2e method https://www.rubydoc.info/stdlib/open3/Open3.popen2e if you set the LD_LIBRARY_PATH in there it might work better |
Something like this might be a good start:
|
Note that for the env hash map both the keys and vals need to be strings. From the env = {"PIPEWIRE_QUANTUM" => "A", "LD_LIBRARY_PATH" => "B"} |
patched daemon and added
|
Got it working.! I reapplied the diff file and just changed the region show below...and it works.
I've tried different sample rates and buffsize and seems fine. Probably leave the sample rate but I have been running 512 and 256 rates on a Pi4. If we can supply changes via toml file that will be great. I'll try and PR the change to pibuild-gui-script later tonight, and I can remove stuff about start script from the documentation to before I commit that. I do notice 3 errors at startup
Searching on line shows that these are very common. Not sure what generates them on SP. |
Woooh! I can do a good first stab at a pr incorporating all of this later tonight. |
maybe want to make the various extra variable instance ones? samplerate, buffsize, quantum ld_library_path? |
Slightly different implementation of #3345, maybe see discussion there.