From 6b8b72ccfd725d34f72be29e46b87752156f45c7 Mon Sep 17 00:00:00 2001 From: David Sutton Date: Fri, 24 Mar 2023 15:26:16 +1030 Subject: [PATCH 1/2] local-looper: Add a simplified looper system that is not dependent on network connectivity. --- cmd/local-looper/README.md | 14 ++++++++++++++ cmd/local-looper/looper.service | 11 +++++++++++ cmd/local-looper/looper.sh | 6 ++++++ 3 files changed, 31 insertions(+) create mode 100644 cmd/local-looper/README.md create mode 100644 cmd/local-looper/looper.service create mode 100644 cmd/local-looper/looper.sh diff --git a/cmd/local-looper/README.md b/cmd/local-looper/README.md new file mode 100644 index 00000000..2be85fb2 --- /dev/null +++ b/cmd/local-looper/README.md @@ -0,0 +1,14 @@ +# DESCRIPTION + local looper is a process which will continually loop a pcm audio file + (like looper). The intended hardware for this system is a raspberry pi + zero W, with a USB sound card (AUDIODEV=hw:(1,0)). + +# AUTHORS + David Sutton + +# SETUP + 1) move looper.sh to home/pi and run "chmod u+x looper.sh. + 2) move looper.service to /etc/systemd/system. + 3) run systemctl enable looper.service. + 4) run sudo systemctl start looper.service. + 5) restart the device, and wait for boot and audio should play. \ No newline at end of file diff --git a/cmd/local-looper/looper.service b/cmd/local-looper/looper.service new file mode 100644 index 00000000..3b303097 --- /dev/null +++ b/cmd/local-looper/looper.service @@ -0,0 +1,11 @@ +[Unit] +Description=Loop PCM audio file on boot +After=network.target + +[Service] +User=pi +WorkingDirectory=/home/pi/ +ExecStart=/bin/bash /home/pi/looper.sh + +[Install] +WantedBy=multi-user.target diff --git a/cmd/local-looper/looper.sh b/cmd/local-looper/looper.sh new file mode 100644 index 00000000..a800dfe7 --- /dev/null +++ b/cmd/local-looper/looper.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export AUDIODEV=hw:1,0 +while true; do + play -q -V0 -t raw -r 44.1k -e signed -b 16 -c 1 /home/pi/shrimp.pcm +done From dafb51d34e531a229f07df5cc245a439f261d0da Mon Sep 17 00:00:00 2001 From: David Sutton Date: Tue, 4 Apr 2023 14:42:36 +0930 Subject: [PATCH 2/2] local-looper: Utilise service watchdog. --- cmd/local-looper/README.md | 2 +- cmd/local-looper/looper.service | 4 ++++ cmd/local-looper/looper.sh | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/local-looper/README.md b/cmd/local-looper/README.md index 2be85fb2..465876b1 100644 --- a/cmd/local-looper/README.md +++ b/cmd/local-looper/README.md @@ -1,6 +1,6 @@ # DESCRIPTION local looper is a process which will continually loop a pcm audio file - (like looper). The intended hardware for this system is a raspberry pi + (like looper: "av/cmd/looper/"). The intended hardware for this system is a raspberry pi zero W, with a USB sound card (AUDIODEV=hw:(1,0)). # AUTHORS diff --git a/cmd/local-looper/looper.service b/cmd/local-looper/looper.service index 3b303097..a6d3570b 100644 --- a/cmd/local-looper/looper.service +++ b/cmd/local-looper/looper.service @@ -7,5 +7,9 @@ User=pi WorkingDirectory=/home/pi/ ExecStart=/bin/bash /home/pi/looper.sh +Type=notify +WatchdogSec=70s +Restart=on-failure + [Install] WantedBy=multi-user.target diff --git a/cmd/local-looper/looper.sh b/cmd/local-looper/looper.sh index a800dfe7..3dbd2a71 100644 --- a/cmd/local-looper/looper.sh +++ b/cmd/local-looper/looper.sh @@ -1,6 +1,9 @@ #!/bin/bash +systemd-notify --ready + export AUDIODEV=hw:1,0 while true; do play -q -V0 -t raw -r 44.1k -e signed -b 16 -c 1 /home/pi/shrimp.pcm + systemd-notify --status="service is running" WATCHDOG=1 done