Skip to content
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

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

porras
Copy link
Contributor

@porras porras commented Oct 30, 2023

Slightly different implementation of #3345, maybe see discussion there.

@samaaron samaaron merged commit 68edde6 into sonic-pi-net:dev Oct 30, 2023
10 checks passed
@samaaron
Copy link
Collaborator

Wonderful, thanks.

@samaaron
Copy link
Collaborator

@rbnpi, @porras - with this PR merged are both of you happy to see v4.5.0 tagged now - or is there other stuff to do with Linux?

@rbnpi
Copy link
Contributor

rbnpi commented Oct 30, 2023

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

QT_INSTALL_LOCATION=/usr/lib/qt6

2: add the start_sonic-pi_with_pw-jack script to the sonic-pi/bin folder
I'm still a bit unhappy about this because you have to hard code the pipewire jack buffer size in the call
pw-jack -p 1024 sonic-pi would use the default value, but I think Pi4,pi400 and certainly Pi5 should be able to use smaller values: maybe 512 for the 4/400 and perhaps 256 for the Pi5 but I don't have one to test it.
It might be safer to just use 1024 for initial release, and more advanced users who might want to try for lower latency could just launch SP from the command line with say pw-jack -p 512 sonic-pi

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:

#!/usr/bin/env bash
#THIS FILE SHOULD BE RUN IN THE SONIC-PI/BIN FOLDER
#first use proc/cpuinfo to determine which pi model being used
code=$(awk '/^Model/ {print $5}' /proc/cpuinfo)
#echo $code
#!/usr/bin/env bash
#determine if computer is slow machine pi2 or pi3 and set buf to 1024
[[ $code < 4 ]] && buf=1024 
#if pi4 or pi400 set buf to 512
[[ $code == 4  ||  $code == 400 ]] && buf=512
#if pi5 set buf to 256
[[ $code == 5 ]] && buf=256
#echo $buf

#set up cmd using appropriate buf value

#assemble bits for command
ABSPATH=$(cd $(dirname $0) &&pwd)
cmd2="/sonic-pi"
#check if pw-jack installed
if hash pw-jack 2>/dev/null; then
  pw="pw-jack -p "
  cmd1=$pw" "$buf" "   #cmd1=>/usr/bin/pw-jack -p <bofvalue>
  cmd=${cmd1}${ABSPATH}${cmd2}
  #echo $cmd  #typical cmd  pw-jack -p 256 /home/pi/dev/sonic-pi/bin/sonic-pi
else
  cmd=${ABSPATH}${cmd2} #fallback to no pw-jack
fi
#execute it
eval $cmd

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.

@samaaron
Copy link
Collaborator

@rbnpi - what's the purpose of start_sonic-pi_with_pw-jack and why can't it be integrated with daemon.rb? Why isn't it necessary for generic linux (or is it?)

@samaaron
Copy link
Collaborator

For v3.2.2 I think we need to patch that to use pipe wire rather than disable pipewire in the OS.

@samaaron
Copy link
Collaborator

@rbnpi - what's the purpose of start_sonic-pi_with_pw-jack and why can't it be integrated with daemon.rb? Why isn't it necessary for generic linux (or is it?)

It looks like it's just starting pw-jack with the correct arguments. Is this a fair assessment? If so the following should be considered:

  • This should likely be in daemon.rb as PWJackBooter or similar. We likely need to kill the pw-jack process at the end of using Sonic Pi too (which is what we do with vanilla jack).
  • @porras is an explicit pw-jack command not needed in Flatpack? If not, is this because Flatpack already starts one by default?
  • How might we detect whether pw-jack is already running?
  • Perhaps we should completely remove all calls to jackd in the existing codebase and go explicitly with pw-jack in v4.5.0+

@rbnpi
Copy link
Contributor

rbnpi commented Oct 30, 2023

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….

@samaaron
Copy link
Collaborator

Nice - I'm interested to see what you come up with.

I honestly think that we should be looking at replacing the JackBooter class with PWJackBooter and get rid of all references to jack. Jack has been the single biggest thorn in the side of Linux deployments of Sonic Pi so I'd be only too happy to see it be replaced with pw-jack if at all possible.

@rbnpi
Copy link
Contributor

rbnpi commented Oct 30, 2023

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.

#!/bin/sh
# This file is part of PipeWire.
#
# Copyright © 2020 Wim Taymans
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#

DEFAULT_SAMPLERATE=48000

while getopts 'hr:vs:p:' param ; do
	case $param in
		r)
			PIPEWIRE_REMOTE="$OPTARG"
			export PIPEWIRE_REMOTE
			;;
		v)
			if [ -z "$PIPEWIRE_DEBUG" ]; then
				PIPEWIRE_DEBUG=3
			else
				PIPEWIRE_DEBUG=$(( PIPEWIRE_DEBUG + 1 ))
			fi
			export PIPEWIRE_DEBUG
			;;
		s)
			SAMPLERATE="$OPTARG"
			;;
		p)
			PERIOD="$OPTARG"
			;;
		*)
			echo "$0 - run JACK applications on PipeWire"
			echo " "
			echo "$0 [options] application [arguments]"
			echo " "
			echo "options:"
			echo "	-h                  show brief help"
			echo "	-r <remote>         remote daemon name"
			echo "	-v                  verbose debug info"
			echo "	-s                  samplerate (default \"$DEFAULT_SAMPLERATE\")"
			echo "	-p                  period in samples"
			exit 0
			;;
	esac
done

shift $(( OPTIND - 1 ))

if [ -n "$PERIOD" ]; then
	if [ -n "$SAMPLERATE" ]; then
		PIPEWIRE_QUANTUM="$PERIOD/$SAMPLERATE"
	else
		PIPEWIRE_QUANTUM="$PERIOD/$DEFAULT_SAMPLERATE"
	fi
	export PIPEWIRE_QUANTUM
fi
LD_LIBRARY_PATH='/usr/${LIB}/pipewire-0.3/jack'"${LD_LIBRARY_PATH+":$LD_LIBRARY_PATH"}"
export LD_LIBRARY_PATH

exec "$@"

I've only got it to work by calling it before it calls the sonic-pi entry point.

@porras
Copy link
Contributor Author

porras commented Oct 30, 2023

@rbnpi, @porras - with this PR merged are both of you happy to see v4.5.0 tagged now - or is there other stuff to do with Linux?

This works for flatpak linux as it is now.

@porras is an explicit pw-jack command not needed in Flatpack? If not, is this because Flatpack already starts one by default?

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), pw-jack is a compatibility tool, for the case where a system has both pipewire and jack. It is not necessary if you have only pipewire, pipeware replaces jack. If you have both, you use pw-jack to ensure that applications calling jack call pipewire instead (without them "noticing"). The (4.5.0) flatpak doesn't have jack, so it doesn't need pw-jack.

In that sense (@rbnpi correct me if I'm wrong or if this is different in Raspberry OS), pw-jack is not a daemon but a wrapper (a very simple shell script indeed). You use it to call the executable (in this case sonic-pi) with, therefore it is not possible to run it from the executable.

@porras
Copy link
Contributor Author

porras commented Oct 30, 2023

It is not necessary if you have only pipewire, pipeware replaces jack.

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.

@porras
Copy link
Contributor Author

porras commented Oct 30, 2023

Oh sorry @rbnpi, we wrote almost the same at almost the same time 😮‍💨

@rbnpi
Copy link
Contributor

rbnpi commented Oct 30, 2023

I tried pw-jack -p 512 scsynth -u 30000 & in a terminal and that seemed work. I get the supercollider icon iwith ports n the qpwgraph window. I think the booter for scsynth would need tweaking as you pass a cmd parameter to it and it will object to getting something like 'pw-jack -p 512 scsynth" passed directly. However if this can be done then it gived the opportunity to be able to alter the -p parameter if users want to from a setting in the audio toml file.

@porras
Copy link
Contributor Author

porras commented Oct 30, 2023

I tried pw-jack -p 512 scsynth -u 30000 & in a terminal and that seemed work.

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.

@samaaron
Copy link
Collaborator

We could modify Paths.scsynth_path to point to pw-jack on linux:

https://github.com/sonic-pi-net/sonic-pi/blob/dev/app/server/ruby/bin/daemon.rb#L1147C9-L1147C33

and then slip in the -p 512 as prefixed args. That should work?

@samaaron
Copy link
Collaborator

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 scsynth's pid.

@porras
Copy link
Contributor Author

porras commented Oct 30, 2023

Another idea: all that pw-jack does is setting some environment variables before calling the command. Why not do that?

@samaaron
Copy link
Collaborator

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.

@rbnpi
Copy link
Contributor

rbnpi commented Oct 31, 2023

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.
I tried with the libraries in /etc/ld.so.conf followed by sudo ldconfig, and they are shown in ldconfig -p |grep jack but they only appear to be active if available through LD_LIBRARY_PATH

@xavriley
Copy link
Collaborator

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

@samaaron
Copy link
Collaborator

Something like this might be a good start:

diff --git forkSrcPrefix/app/server/ruby/bin/daemon.rb forkDstPrefix/app/server/ruby/bin/daemon.rb
index dc6523086d5e99e86a9cf14fbf75e8c263be790e..7758f9a0575af5a37d6d6b81bddb96cfb9ed4652 100755
--- forkSrcPrefix/app/server/ruby/bin/daemon.rb
+++ forkDstPrefix/app/server/ruby/bin/daemon.rb
@@ -744,7 +744,8 @@ module SonicPi
 
     class ProcessBooter
       attr_reader :pid, :args, :cmd, :log
-      def initialize(cmd, args, log_path, record_log=false)
+      def initialize(cmd, args, log_path, record_log=false, env=nil)
+        @env = env
         @pid = nil
         @log_file = nil
         @args = args.map {|el| el.to_s}
@@ -786,7 +787,11 @@ module SonicPi
       def boot
         Util.log "Process Booter - booting #{@cmd} with args #{@args.inspect}"
         Util.log "#{@cmd} #{@args.join(' ')}"
-        @stdin, @stdout_and_err, @wait_thr = Open3.popen2e @cmd, *@args
+        if @env
+          @stdin, @stdout_and_err, @wait_thr = Open3.popen2e @env, @cmd, *@args
+        else
+          @stdin, @stdout_and_err, @wait_thr = Open3.popen2e @cmd, *@args
+        end
         @pid = @wait_thr.pid
         if @log_file
           @io_thr = Thread.new do
@@ -1030,7 +1035,6 @@ module SonicPi
       end
     end
 
-
     class JackBooter < ProcessBooter
       def initialize
         cmd = "jackd"
@@ -1134,6 +1138,8 @@ module SonicPi
           toml_opts_hash = {}
         end
 
+
+
         Util.log "Got Audio Settings toml hash: #{toml_opts_hash.inspect}"
         opts = unify_toml_opts_hash(toml_opts_hash)
         Util.log "Unified Audio Settings toml hash: #{opts.inspect}"
@@ -1145,9 +1151,17 @@ module SonicPi
         @num_outputs = opts["-o"].to_i
         args = opts.to_a.flatten
         cmd = Paths.scsynth_path
+
+         case Util.os
+         when :linux, :raspberry
+          env = {}  # put env vars for pw-jack in this hashmap here...
+         else
+           env = nil
+         end
+
         @success = Promise.new
         run_pre_start_commands
-        super(cmd, args, Paths.scsynth_log_path, true)
+        super(cmd, args, Paths.scsynth_log_path, true, env)
         run_post_start_commands
         success = wait_for_boot
         disable_internal_log_recording!
@@ -1234,7 +1248,7 @@ module SonicPi
           end
         end
       end
-            
+
       def run_post_start_commands
         case Util.os
         when :raspberry, :linux

@samaaron
Copy link
Collaborator

samaaron commented Oct 31, 2023

Note that for the env hash map both the keys and vals need to be strings. From the pw-jack script it just seems you need to set PIPEWIRE_QUANTUM and LD_LIBRARY_PATH appropriately:

env = {"PIPEWIRE_QUANTUM" => "A",  "LD_LIBRARY_PATH" => "B"}

@rbnpi
Copy link
Contributor

rbnpi commented Oct 31, 2023

patched daemon and added
env = {"PIPEWIRE_QUANTUM" => "93", "LD_LIBRARY_PATH" => "/usr/lib/aarch64-linux-gnu/pipewire-0.3/jack"}
scsynth boots and I get supercollider in the qwpgraph connected to hdmi but error window produced on screen.
investigating....

Sonic Pi version: 4.5.0
OS: Debian GNU/Linux 12 (bookworm)
spider.log
Sonic Pi Spider Server booting...
The time is 2023-10-31 12:21:37 +0000
Using primary protocol: udp
Detecting port numbers...
Ports: {:server_port=>35047, :gui_port=>35048, :scsynth_port=>35049, :scsynth_send_port=>35049, :osc_cues_port=>35050, :tau_port=>35051, :listen_to_tau_port=>35055}
Token: 820223912
Opening UDP Server to listen to GUI on port: 35047
Spider - Pulling in modules...
Spider - Starting Runtime Server


daemon.log
[2023-10-31 12:21:32] Welcome to the Daemon Booter
[2023-10-31 12:21:32] ----------------------------
[2023-10-31 12:21:32] SuperCollider inputs enabled by GUI
[2023-10-31 12:21:32] Process Booter - booting compton with args []
[2023-10-31 12:21:32] compton 
[2023-10-31 12:21:32] checked port 35047, #<UDPSocket:0x0000007f7fa98b30>
[2023-10-31 12:21:32] checked port 35048, #<UDPSocket:0x0000007f7fa985e0>
[2023-10-31 12:21:32] checked port 35049, #<UDPSocket:0x0000007f7fa98338>
[2023-10-31 12:21:32] checked port 35050, #<UDPSocket:0x0000007f7fa9fea8>
[2023-10-31 12:21:32] checked port 35051, #<UDPSocket:0x0000007f7fa9fc50>
[2023-10-31 12:21:32] checked port 35052, #<UDPSocket:0x0000007f7fa9f980>
[2023-10-31 12:21:32] checked port 35053, #<UDPSocket:0x0000007f7fa9f5c0>
[2023-10-31 12:21:32] checked port 35054, #<UDPSocket:0x0000007f7fa9f318>
[2023-10-31 12:21:32] checked port 35055, #<UDPSocket:0x0000007f7fa9f070>
[2023-10-31 12:21:32] Selected ports: 
[2023-10-31 12:21:32] {"spider-listen-to-gui"=>35047, "gui-send-to-spider"=>35047, "gui-listen-to-spider"=>35048, "spider-send-to-gui"=>35048, "scsynth"=>35049, "scsynth-send"=>35049, "osc-cues"=>35050, "tau"=>35051, "spider"=>35052, "phx"=>35053, "daemon"=>35054, "spider-listen-to-tau"=>35055}
[2023-10-31 12:21:32] Booting Scsynth
[2023-10-31 12:21:32] Got Audio Settings toml hash: {:num_inputs=>4, :num_outputs=>16}
[2023-10-31 12:21:32] Unified Audio Settings toml hash: {"-i"=>"4", "-o"=>"16"}
[2023-10-31 12:21:32] Combined Audio Settings toml hash with GUI scsynth inputs hash: {"-i"=>"4", "-o"=>"16"}
[2023-10-31 12:21:32] Merged Audio Settings toml hash: {"-u"=>35049, "-a"=>"1024", "-m"=>"131072", "-D"=>"0", "-R"=>"0", "-l"=>"1", "-i"=>"4", "-o"=>"16", "-b"=>"4096", "-B"=>"127.0.0.1", "-c"=>"128", "-z"=>"128", "-U"=>"/usr/lib/SuperCollider/plugins"}
[2023-10-31 12:21:33] No need to start Jackd, using pipewire instead
[2023-10-31 12:21:33] Process Booter - booting scsynth with args ["-u", "35049", "-a", "1024", "-m", "131072", "-D", "0", "-R", "0", "-l", "1", "-i", "4", "-o", "16", "-b", "4096", "-B", "127.0.0.1", "-c", "128", "-z", "128", "-U", "/usr/lib/SuperCollider/plugins"]
[2023-10-31 12:21:33] scsynth -u 35049 -a 1024 -m 131072 -D 0 -R 0 -l 1 -i 4 -o 16 -b 4096 -B 127.0.0.1 -c 128 -z 128 -U /usr/lib/SuperCollider/plugins
[2023-10-31 12:21:33] Waiting for the SuperCollider Server to have booted...
[2023-10-31 12:21:33] Sending /status to server: localhost:35049
[2023-10-31 12:21:33] [scsynth] Found 0 LADSPA plugins
[2023-10-31 12:21:33] [scsynth] JackDriver: client name is 'SuperCollider'
[2023-10-31 12:21:33] [scsynth] SC_AudioDriver: sample rate = 48000.000000, driver's block size = 1024
[2023-10-31 12:21:33] [scsynth] SuperCollider 3 server ready.
[2023-10-31 12:21:34] Sending /status to server: localhost:35049
[2023-10-31 12:21:34] Receiving ack from scsynth
[2023-10-31 12:21:34] SuperCollider Server connection established
[2023-10-31 12:21:34] Extracting Scsynth info
[2023-10-31 12:21:34] Booting Tau...
[2023-10-31 12:21:34] Fetching Tau toml opts...
[2023-10-31 12:21:34] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051
[2023-10-31 12:21:34] Daemon listening to info from Tau on port 35054
[2023-10-31 12:21:34] Process Booter - booting sh with args ["/home/pi/dev/sonic-pi/app/server/beam/tau/boot-lin.sh"]
[2023-10-31 12:21:34] sh /home/pi/dev/sonic-pi/app/server/beam/tau/boot-lin.sh
[2023-10-31 12:21:34] Booting Spider Server
[2023-10-31 12:21:34] Process Booter - booting /usr/bin/ruby3.1 with args ["--enable-frozen-string-literal", "-E", "utf-8", "/home/pi/dev/sonic-pi/app/server/ruby/bin/spider-server.rb", "-u", "35047", "35048", "35049", "35049", "35050", "35051", "35055", "820223912"]
[2023-10-31 12:21:34] /usr/bin/ruby3.1 --enable-frozen-string-literal -E utf-8 /home/pi/dev/sonic-pi/app/server/ruby/bin/spider-server.rb -u 35047 35048 35049 35049 35050 35051 35055 820223912
[2023-10-31 12:21:34] [sh] Booting Tau on Linux...
[2023-10-31 12:21:34] 35054 35048 35047 35049 35050 35051 35053 820223912
[2023-10-31 12:21:34] Blocking main thread until exit signal received...
[2023-10-31 12:21:35] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051
[2023-10-31 12:21:35] Error talking to Tau - connection refused (perhaps Tau is still booting?)
[2023-10-31 12:21:36] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051
[2023-10-31 12:21:37] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051
[2023-10-31 12:21:37] Error talking to Tau - connection refused (perhaps Tau is still booting?)
[2023-10-31 12:21:37] [ruby3] Sonic Pi Spider Server booting...
[2023-10-31 12:21:37] [ruby3] The time is 2023-10-31 12:21:37 +0000
[2023-10-31 12:21:37] [ruby3] Using primary protocol: udp
[2023-10-31 12:21:37] [ruby3] Detecting port numbers...
[2023-10-31 12:21:37] [ruby3] Ports: {:server_port=>35047, :gui_port=>35048, :scsynth_port=>35049, :scsynth_send_port=>35049, :osc_cues_port=>35050, :tau_port=>35051, :listen_to_tau_port=>35055}
[2023-10-31 12:21:37] [ruby3] Token: 820223912
[2023-10-31 12:21:37] [ruby3] Opening UDP Server to listen to GUI on port: 35047
[2023-10-31 12:21:37] [ruby3] Spider - Pulling in modules...
[2023-10-31 12:21:37] [ruby3] Spider - Starting Runtime Server
[2023-10-31 12:21:38] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051
[2023-10-31 12:21:38] [scsynth] JackDriver: max output latency 21.3 ms
[2023-10-31 12:21:39] Sending scsynth info to GUI...
[2023-10-31 12:21:39] {:sc_sample_rate=>48000, :sc_block_size=>1024}
[2023-10-31 12:21:39] Sample Rate: 48000
Block Size: 1024
[2023-10-31 12:21:39] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051
[2023-10-31 12:21:39] Error talking to Tau - connection refused (perhaps Tau is still booting?)
[2023-10-31 12:21:40] Requesting tau send us its pid. Sending /send-pid-to-daemon, 820223912 to localhost:35051


scsynth.log
Found 0 LADSPA plugins
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 1024
SuperCollider 3 server ready.
JackDriver: max output latency 21.3 ms


gui.log

@rbnpi
Copy link
Contributor

rbnpi commented Oct 31, 2023

Got it working.! I reapplied the diff file and just changed the region show below...and it works.
@samaaron It would be nice to add these to the options to the toml file so they could easily. be changed or updated. I think you would be quicker and better at coding this than me.

         when :linux, :raspberry
          buffsize=1024      # the pw-jack period -p option buffer size for scsynth: default is 1024
          samplerate=48000    #default is 48000 for pw-jack
          ld_library_path = "/usr/lib/aarch64-linux-gnu/pipewire-0.3/jack" #prone to version changes: what do we do then?
          quantum ="#{buffsize}/#{samplerate}"
          env = { "PIPEWIRE_QUANTUM" => quantum ,  "LD_LIBRARY_PATH" => ld_library_path }  # put env vars for pw-jack in this hashmap here...
         else
           env = nil
         end

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

qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()

Searching on line shows that these are very common. Not sure what generates them on SP.

@samaaron
Copy link
Collaborator

Woooh! I can do a good first stab at a pr incorporating all of this later tonight.

@rbnpi
Copy link
Contributor

rbnpi commented Oct 31, 2023

maybe want to make the various extra variable instance ones? samplerate, buffsize, quantum ld_library_path?
quantum is actually exported as a fraction as I have done here, in pw-jack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants