osamc.de/archiv/talk-mod-host-pisound-button/index.adoc

56 lines
1.8 KiB
Plaintext

= mod-host vs Pisound button
:customcss: presentation.css
:source-highlighter: highlight.js
:linkattrs:
link:https://https://sonoj.org/[Sonoj Convention, window="_blank"]
link:https://github.com/danielappelt[Daniel Appelt, window="_blank"] / 2023-09-30
== Pisound & the button
[%step]
* link:https://blokas.io/pisound/[Pisound] is a sound card and MIDI interface for the Raspberry Pi
* It comes with one link:https://github.com/BlokasLabs/pisound/blob/master/pisound-btn/pisound.conf[configurable button]
* Bash scripts are used for button action (link:scripts/pisound-btn/toggle_wifi_hotspot.sh[example])
== mod-host
[%step]
* link:https://github.com/moddevices/mod-host[mod-host] is an LV2 host for JACK, controllable via socket or command line
* link:https://github.com/moddevices/mod-ui[mod-ui] is started together with mod-host in MODEP
* mod-ui uses file socket to communicate with mod-host
== Problem
[%step]
* Syncing mod-host as secondary via MIDI clock was unreliable
* How to start/stop transport in mod-host as MIDI clock primary not using mod-ui?
== Solution
[%step]
* Let Pisound button start/stop mod-host via web socket
* link:https://github.com/vi/websocat[websocat] is like netcat, curl and socat for WebSockets
* Example script to start/stop transport in mod-host
== Code
[source, bash]
----
#!/bin/sh
. /usr/local/pisound/scripts/common/common.sh
# Use websocket interface to mod-ui as the regular socket is exclusively used for
# communication between mod-ui and mod-host.
if [ -z $(echo -n '' | /usr/local/bin/websocat --text ws://127.0.0.1:80/websocket/ | grep 'transport 1') ]; then
# Start transport and blinking
echo 'transport-rolling 1' | /usr/local/bin/websocat ws://127.0.0.1:80/websocket/
else
# Stop transport and blinking
echo 'transport-rolling 0' | /usr/local/bin/websocat ws://127.0.0.1:80/websocket/
fi
----