Alsa error starting PD from button script

With the Pure Data module loaded in patchbox and launching PD with the pi sound button I get an ALSA audio in/out error “device or resource not available” Starting PD from the Application menu with a mouse works fine however. So PD in gui mode is trying to start with the alsa driver which has already been taken by JACK. Editing the script at /usr/local/pisound/scripts/common/start_puredata.sh and changing the audio driver from alsa to jack has sorted the issue. Curious to know why starting PD with the button means that PD does not show up in the task manager app.

I’m not sure about why it wouldn’t show up in task manager, but try running:

ps -ef

in a terminal - it should list all the processes, including their command lines.

Btw, what is the output of these commands:

cd /usr/local/pisound/scripts/common/
git status

I’m interested to know which branch the scripts repository is on. :slight_smile:

The command ps -ef shows the following info:

patch@Pisound:~ $ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  1 09:07 ?        00:00:04 /sbin/init
root         2     0  0 09:07 ?        00:00:00 [kthreadd]
root         3     2  0 09:07 ?        00:00:00 [rcu_gp]
root         4     2  0 09:07 ?        00:00:00 [rcu_par_gp]
root         5     2  0 09:07 ?        00:00:01 [kworker/0:0-events]
root         6     2  0 09:07 ?        00:00:00 [kworker/0:0H-mmc_complete]
root         7     2  0 09:07 ?        00:00:00 [kworker/u8:0-events_unbound]
root         8     2  0 09:07 ?        00:00:00 [mm_percpu_wq]
root         9     2  0 09:07 ?        00:00:00 [rcu_tasks_rude_]
root        10     2  0 09:07 ?        00:00:00 [rcu_tasks_trace]
root        11     2  0 09:07 ?        00:00:00 [ksoftirqd/0]
root        12     2  0 09:07 ?        00:00:00 [rcu_sched]
root        13     2  0 09:07 ?        00:00:00 [migration/0]
root        14     2  0 09:07 ?        00:00:00 [cpuhp/0]
root        15     2  0 09:07 ?        00:00:00 [cpuhp/1]
root        16     2  0 09:07 ?        00:00:00 [migration/1]
root        17     2  0 09:07 ?        00:00:00 [ksoftirqd/1]
root        18     2  0 09:07 ?        00:00:00 [kworker/1:0-events]
root        19     2  0 09:07 ?        00:00:00 [kworker/1:0H-kblockd]
root        20     2  0 09:07 ?        00:00:00 [cpuhp/2]
root        21     2  0 09:07 ?        00:00:00 [migration/2]
root        22     2  0 09:07 ?        00:00:00 [ksoftirqd/2]
root        23     2  0 09:07 ?        00:00:00 [kworker/2:0-mm_percpu_wq]
root        24     2  0 09:07 ?        00:00:00 [kworker/2:0H-kblockd]
root        25     2  0 09:07 ?        00:00:00 [cpuhp/3]
root        26     2  0 09:07 ?        00:00:00 [migration/3]
root        27     2  0 09:07 ?        00:00:00 [ksoftirqd/3]
root        28     2  0 09:07 ?        00:00:00 [kworker/3:0-events]
root        29     2  0 09:07 ?        00:00:00 [kworker/3:0H-kblockd]
root        30     2  0 09:07 ?        00:00:00 [kdevtmpfs]
root        31     2  0 09:07 ?        00:00:00 [netns]
root        32     2  0 09:07 ?        00:00:00 [kworker/0:1-pm]
root        33     2  0 09:07 ?        00:00:00 [kworker/1:1-events]
root        34     2  0 09:07 ?        00:00:00 [kworker/2:1-events]
root        35     2  0 09:07 ?        00:00:00 [kauditd]
root        36     2  0 09:07 ?        00:00:00 [khungtaskd]
root        37     2  0 09:07 ?        00:00:00 [oom_reaper]
root        38     2  0 09:07 ?        00:00:00 [writeback]
root        39     2  0 09:07 ?        00:00:00 [kcompactd0]
root        57     2  0 09:07 ?        00:00:00 [kblockd]
root        58     2  0 09:07 ?        00:00:00 [blkcg_punt_bio]
root        59     2  0 09:07 ?        00:00:00 [watchdogd]
root        60     2  0 09:07 ?        00:00:00 [kworker/3:1-events_freezable]
root        61     2  0 09:07 ?        00:00:00 [kworker/0:1H-kblockd]
root        62     2  0 09:07 ?        00:00:00 [rpciod]
root        63     2  0 09:07 ?        00:00:00 [kworker/u9:0-hci0]
root        64     2  0 09:07 ?        00:00:00 [xprtiod]
root        65     2  0 09:07 ?        00:00:00 [kswapd0]
root        66     2  0 09:07 ?        00:00:00 [nfsiod]
root        67     2  0 09:07 ?        00:00:00 [kthrotld]
root        68     2  0 09:07 ?        00:00:00 [iscsi_eh]
root        69     2  0 09:07 ?        00:00:00 [iscsi_destroy]
root        70     2  0 09:07 ?        00:00:00 [kworker/u8:1-events_unbound]
root        72     2  0 09:07 ?        00:00:00 [DWC Notificatio]
root        73     2  0 09:07 ?        00:00:00 [uas]
root        74     2  0 09:07 ?        00:00:01 [kworker/0:2-events]
root        75     2  0 09:07 ?        00:00:00 [vchiq-slot/0]
root        76     2  0 09:07 ?        00:00:00 [vchiq-recy/0]
root        77     2  0 09:07 ?        00:00:00 [vchiq-sync/0]
root        78     2  0 09:07 ?        00:00:00 [zswap-shrink]
root        79     2  0 09:07 ?        00:00:00 [kworker/0:3-rcu_gp]
root        80     2  0 09:07 ?        00:00:00 [sdhci]
root        81     2  0 09:07 ?        00:00:00 [irq/50-mmc0]
root        82     2  0 09:07 ?        00:00:00 [kworker/3:2-mm_percpu_wq]
root        83     2  0 09:07 ?        00:00:00 [mmc_complete]
root        84     2  0 09:07 ?        00:00:00 [kworker/3:1H-kblockd]
root        85     2  0 09:07 ?        00:00:00 [kworker/2:1H-kblockd]
root        86     2  0 09:07 ?        00:00:00 [kworker/2:2H]
root        87     2  0 09:07 ?        00:00:00 [jbd2/mmcblk0p2-]
root        88     2  0 09:07 ?        00:00:00 [ext4-rsv-conver]
root        89     2  0 09:07 ?        00:00:00 [ipv6_addrconf]
root        90     2  0 09:07 ?        00:00:00 [kworker/2:2-mm_percpu_wq]
root        94     2  0 09:07 ?        00:00:00 [kworker/1:1H-kblockd]
root       106     2  0 09:07 ?        00:00:00 [kworker/1:2H]
root       107     2  0 09:07 ?        00:00:00 [kworker/3:2H-kblockd]
root       111     1  0 09:07 ?        00:00:00 /lib/systemd/systemd-journald
root       114     2  0 09:07 ?        00:00:00 [kworker/0:2H-mmc_complete]
root       148     1  0 09:07 ?        00:00:00 /lib/systemd/systemd-udevd
root       174     2  0 09:07 ?        00:00:00 [kworker/1:2-mm_percpu_wq]
root       187     2  0 09:07 ?        00:00:00 [vchiq-keep/0]
root       189     2  0 09:07 ?        00:00:00 [SMIO]
root       197     2  0 09:07 ?        00:00:00 [mmal-vchiq]
root       204     2  0 09:07 ?        00:00:00 [spi0]
root       213     2  0 09:07 ?        00:00:00 [mmal-vchiq]
root       214     2  0 09:07 ?        00:00:00 [mmal-vchiq]
root       216     2  0 09:07 ?        00:00:00 [mmal-vchiq]
root       230     2  0 09:07 ?        00:00:00 [irq/65-data_ava]
root       231     2  0 09:07 ?        00:00:00 [pisnd_workqueue]
root       252     2  0 09:07 ?        00:00:00 [cfg80211]
root       260     2  0 09:07 ?        00:00:00 [brcmf_wq/mmc1:0]
root       261     2  0 09:07 ?        00:00:00 [brcmf_wdog/mmc1]
root       262     2  0 09:07 ?        00:00:00 [kworker/1:3-events_power_effici
systemd+   389     1  0 09:07 ?        00:00:00 /lib/systemd/systemd-timesyncd
root       424     1  0 09:07 ?        00:00:00 /usr/sbin/alsactl -E HOME=/run/a
message+   429     1  0 09:07 ?        00:00:00 /usr/bin/dbus-daemon --system --
root       430     1  1 09:07 ?        00:00:02 /usr/bin/pisound-ctl
root       431     1  0 09:07 ?        00:00:00 /usr/sbin/cron -f
root       433     1  0 09:07 ?        00:00:00 /sbin/wpa_supplicant -u -s -O /r
root       435     1  0 09:07 ?        00:00:00 /usr/lib/udisks2/udisksd
root       439     1  0 09:07 ?        00:00:00 /usr/sbin/rsyslogd -n -iNONE
root       441     1  0 09:07 ?        00:00:00 /lib/systemd/systemd-logind
avahi      444     1  0 09:07 ?        00:00:00 avahi-daemon: running [Pisound.l
nobody     449     1  0 09:07 ?        00:00:00 /usr/sbin/thd --triggers /etc/tr
root       455     1  0 09:07 ?        00:00:00 /usr/sbin/cupsd -l
root       474     1  0 09:07 ?        00:00:00 /usr/sbin/rngd -r /dev/hwrng
avahi      486   444  0 09:07 ?        00:00:00 avahi-daemon: chroot helper
root       489     2  0 09:07 ?        00:00:00 [kworker/2:3-cgroup_destroy]
root       521     2  0 09:07 ?        00:00:00 [kworker/u8:2-events_unbound]
root       523     1  0 09:07 ?        00:00:00 /usr/sbin/cups-browsed
root       527     1  0 09:07 ?        00:00:00 /usr/bin/pisound-btn
jack       530     1  4 09:07 ?        00:00:10 /usr/bin/jackd -t 2000 -R -P 95 
root       532     1  0 09:07 ?        00:00:00 /usr/bin/amidiauto
root       545     2  0 09:07 ?        00:00:00 [kworker/u8:3]
root       546     2  0 09:07 ?        00:00:00 [kworker/3:3-cgroup_destroy]
root       547     1  0 09:07 ?        00:00:00 /usr/lib/policykit-1/polkitd --n
colord     557     1  0 09:07 ?        00:00:00 /usr/lib/colord/colord
root       567     1  0 09:07 ?        00:00:00 wpa_supplicant -B -c/etc/wpa_sup
root       602     2  0 09:07 ?        00:00:00 [kworker/u9:1-hci0]
root       603     1  0 09:07 ?        00:00:00 /usr/bin/hciattach /dev/serial1 
root       604     2  0 09:07 ?        00:00:00 [kworker/u9:2-hci0]
root       607     1  0 09:07 ?        00:00:00 /usr/lib/bluetooth/bluetoothd
root       608     1  0 09:07 ?        00:00:00 /usr/bin/bluealsa
root       618     2  0 09:07 ?        00:00:00 [krfcommd]
root       620   430  0 09:07 ?        00:00:00 /bin/sh /usr/bin/mec /etc/mec-bl
root       624   430  0 09:07 ?        00:00:00 osc2midi pisound-ctl 127.0.0.1 5
root       626   620  0 09:07 ?        00:00:02 mec-app /etc/mec-blokas.json
root       675     1  0 09:07 ?        00:00:00 /sbin/dhcpcd -q -w
root       680     1  0 09:07 ?        00:00:00 /usr/bin/python3 /usr/bin/toucho
root       683     1  0 09:07 ?        00:00:00 /usr/bin/vncserver-x11-serviced 
root       687     1  0 09:07 ?        00:00:00 /usr/sbin/lightdm
root       690   683  5 09:07 ?        00:00:13 /usr/bin/vncserver-x11-core -ser
root       691     1  0 09:07 ?        00:00:00 /usr/sbin/sshd -D
root       693     1  0 09:07 ?        00:00:00 /usr/sbin/netatalk
root       694   693  0 09:07 ?        00:00:01 /usr/sbin/afpd -d -F /etc/netata
root       696   693  0 09:07 ?        00:00:00 /usr/sbin/cnid_metad -d -F /etc/
root       703     1  0 09:07 tty1     00:00:00 /sbin/agetty -o -p -- \u --nocle
root       704   687 16 09:07 tty7     00:00:42 /usr/lib/xorg/Xorg :0 -seat seat
root       706     1  0 09:07 ttyS0    00:00:00 /sbin/agetty -o -p -- \u --keep-
root       723     1  0 09:07 ?        00:00:01 /usr/bin/vncagent service 15
root       932   687  0 09:07 ?        00:00:00 lightdm --session-child 14 21
root      1049   691  0 09:08 ?        00:00:00 sshd: patch [priv]
patch     1053     1  0 09:08 ?        00:00:00 /lib/systemd/systemd --user
patch     1054  1053  0 09:08 ?        00:00:00 (sd-pam)
patch     1068  1049  0 09:08 ?        00:00:00 sshd: patch@pts/0
patch     1069  1068  0 09:08 pts/0    00:00:00 -bash
lp        1178   455  0 09:09 ?        00:00:00 /usr/lib/cups/notifier/dbus dbus
patch     1184   932  0 09:09 ?        00:00:00 /usr/bin/lxsession -s LXDE-pi -e
patch     1192  1053  0 09:09 ?        00:00:00 /usr/bin/dbus-daemon --session -
patch     1213  1184  0 09:09 ?        00:00:00 /usr/bin/ssh-agent x-session-man
patch     1224  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfsd
patch     1229  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfsd-fuse /run/us
patch     1239  1184  0 09:09 ?        00:00:00 openbox --config-file /home/patc
patch     1240  1184  0 09:09 ?        00:00:00 lxpolkit
patch     1243  1184  0 09:09 ?        00:00:01 lxpanel --profile LXDE-pi
patch     1246  1184  0 09:09 ?        00:00:01 pcmanfm --desktop --profile LXDE
patch     1247  1184  0 09:09 ?        00:00:00 xscreensaver -no-splash
patch     1256     1  0 09:09 ?        00:00:00 /usr/bin/ssh-agent -s
patch     1261     1  0 09:09 ?        00:00:00 /usr/bin/python3 /usr/share/syst
patch     1276  1053  0 09:09 ?        00:00:00 /usr/bin/pulseaudio --daemonize=
rtkit     1281     1  0 09:09 ?        00:00:00 /usr/lib/rtkit/rtkit-daemon
patch     1293  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfs-udisks2-volum
patch     1299     1  0 09:09 ?        00:00:00 /usr/lib/menu-cache/menu-cached 
patch     1304  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfs-afc-volume-mo
patch     1309  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfs-mtp-volume-mo
patch     1313  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volum
patch     1317  1053  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfs-goa-volume-mo
patch     1319     1  0 09:09 ?        00:00:00 /usr/bin/vncserverui service 19
patch     1331  1319  0 09:09 ?        00:00:00 /usr/bin/vncserverui -statusicon
patch     1334  1224  0 09:09 ?        00:00:00 /usr/lib/gvfs/gvfsd-trash --spaw
patch     1464  1243  1 09:09 ?        00:00:01 lxtask
patch     1550  1243  0 09:10 ?        00:00:00 lxterminal
patch     1564  1550  0 09:10 pts/1    00:00:00 bash
root      1628     1  0 09:10 ?        00:00:00 /bin/sh /usr/local/pisound/scrip
root      1636  1628  9 09:10 ?        00:00:07 puredata -jack -audioadddev piso
root      1639  1636  0 09:10 ?        00:00:00 sh -c TCL_LIBRARY="/usr/lib/pure
root      1640  1639 11 09:10 ?        00:00:08 wish /usr/lib/puredata/tcl//pd-g
root      1647  1636  0 09:10 ?        00:00:00 sh -c /usr/lib/puredata/bin/pd-w
root      1648  1647  0 09:10 ?        00:00:00 /usr/lib/puredata/bin/pd-watchdo
patch     1673  1564  0 09:11 pts/1    00:00:00 ps -ef

Output from git status:

patch@Pisound:/usr/local/pisound/scripts/common $ git status
On branch patchbox
Your branch is up to date with 'origin/patchbox'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   start_puredata.sh

no changes added to commit (use "git add" and/or "git commit -a")

Here you can see PD running.

Could you run

git diff

in the scripts folder? The branch is correct, but something was modified.

The patchbox branch of scripts doesn’t specify the audio engine to use at all, maybe you had previously modified the command line to use ALSA, then switched to Jack?

The original script version for patchbox branch is here: pisound/scripts/common/start_puredata.sh at patchbox · BlokasLabs/pisound · GitHub

Thank you Giedrius. Yes I’m reminded that I had to modify it some time ago. I was having trouble with jack and also wanted to see the GUI…perhaps I should undergo diagnosis for memory loss :confused:

git diff below:

diff --git a/scripts/common/start_puredata.sh b/scripts/common/start_puredata.sh
index b8be476..4f9767f 100755
--- a/scripts/common/start_puredata.sh
+++ b/scripts/common/start_puredata.sh
@@ -51,7 +51,9 @@ start_puredata()
        shift
 
        log "Launching Pure Data."
-       cd "$PATCH_DIR" && puredata -stderr $NO_GUI -send ";pd dsp 1" "$PATCH" $@ &
+       # to run pd in NO_GUI mode swop the 2 lines below: uncomment the line below and comment the line below that...
+       #cd "$PATCH_DIR" && puredata -stderr $NO_GUI -send ";pd dsp 1" "$PATCH" $@ &
+       cd "$PATCH_DIR" && puredata -jack -audioadddev pisound -alsamidi -channels 2 -r 48000 -mididev 1 -send ";pd dsp 1" "$PATCH" $@ &
        PD_PID=$!
 
        log "Pure Data started!"
@@ -60,6 +62,5 @@ start_puredata()
        flash_leds 1
        sleep 0.3
        flash_leds 1
-
        wait_process $PD_PID
 }

Hey, I’d suggest restoring the original version as on https://github.com/BlokasLabs/pisound/blob/patchbox/scripts/common/start_puredata.sh#L54

You may choose to remove the $NO_GUI argument, but it is doing it’s best to see if GUI is up, and if it is - then start PD with GUI enabled. If it doesn’t start with a GUI, for some reason, having a terminal window up in the GUI helps it find which X display to use and start PD with GUI enabled, so if using $NO_GUI, the PD doesn’t show up, try starting a terminal and restarting PD.

Yes, I restored the original file and that works in gui mode so long as I have a terminal window open, although to add to the fun I note that when starting PD from the button, the PD print object will not print to the PD console. (ps -ef tells us the program is being run as root which might have something to do with it?)

The log goes to ‘stderr’ because of -stderr argument, then it shows up in the pisound-btn daemon log:

journalctl -u pisound-btn -f

Or if it was started via the Pisound App, it’d go to the Pisound App Console output tab.

Unfortunately AFAIK there’s no way to get output both in PD and to be sent to other processes at the same time. If you’d like, you may remove -stderr in the launcher script.

Hey, actually that’s pretty cool to see the print output from PD in a separate terminal window. Thank you for your extraordinary level of support (and patience).

1 Like