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

[WIP]: Tidal connect plugin #399

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ services:
network_mode: host
ports:
- 49494:49494

tidal:
build: ./plugins/tidal
restart: on-failure
privileged: true
network_mode: host
labels:
io.balena.features.dbus: 1
15 changes: 11 additions & 4 deletions docs/05-audio-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ In the balenaCloud dashboard:

![DAC Configuration](https://raw.githubusercontent.com/balenalabs/balena-sound/master/docs/images/dac-vars.png)

Alternatively, you can set this configuration variable in the `Define DT overlays` section under the `Device configuration` menu item:

![DAC Configuration Option 2](https://raw.githubusercontent.com/balenalabs/balena-sound/master/docs/images/dac-vars-2.png)

As per the above steps, after adding this power cycling your device will then pull in the new overlay.

If you're using multiple devices with multiple DACs for multi-room audio, you'll want to do this process per unique device that is using a DAC. Do not set this variable fleet-wide as it will affect every device within your application.

### dtoverlay values
Expand Down Expand Up @@ -65,11 +71,11 @@ These are the DACs that are known to work with balenaSound. If your DAC is not o
| [Hifiberry Beocreate][22] | hifiberry-dac | Yes
| [Hifiberry DAC+ DSP][23] | hifiberry-dac | Yes
| [Hifiberry MiniAmp][24] | hifiberry-dac | Yes
| [Hifiberry DAC2 HD][27] | hifiberry-dacplushd | Yes
| [Hifiberry DAC2 HD][27] | hifiberry-dacplushd | [Yes][41]
| [Adafruit I2S Audio Bonnet][26]| "hifiberry-dac","i2s-mmap" | Yes
| [Adafruit MAX98357 I2S Class-D Mono Amp][28]| "hifiberry-dac,"i2s-mmap" | Yes
| [RasPiAudio Audio+ DAC][37] | hifiberry-dac | Yes[38]
| [AUDIOPHONICS I-Sabre DAC ES9023][39]| hifiberry-dac | Yes[40]
| [Adafruit MAX98357 I2S Class-D Mono Amp][28]| "hifiberry-dac","i2s-mmap" | Yes
| [RasPiAudio Audio+ DAC][37] | hifiberry-dac | [Yes][38]
| [AUDIOPHONICS I-Sabre DAC ES9023][39]| hifiberry-dac | [Yes][40]

[1]: http://www.suptronics.com/Xseries/x400.html
[2]: https://shop.pimoroni.com/products/phat-dac
Expand Down Expand Up @@ -111,3 +117,4 @@ These are the DACs that are known to work with balenaSound. If your DAC is not o
[38]: https://github.com/balenalabs/balena-sound/issues/355
[39]: https://www.audiophonics.fr/fr/dac-et-interfaces-pour-raspberry-pi/audiophonics-i-sabre-dac-es9023-tcxo-raspberry-pi-a-b-20-i2s-p-9978.html
[40]: https://github.com/balenalabs/balena-sound/issues/345
[41]: https://github.com/balenalabs/balena-sound/issues/377
Binary file added docs/images/dac-vars-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions plugins/tidal/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:buster

# Audio block setup
ENV PULSE_SERVER=tcp:localhost:4317
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh

RUN echo "deb http://archive.raspbian.org/raspbian stretch main" >> /etc/apt/sources.list \
&& apt update \
&& install_packages multiarch-support libavformat57 git libportaudio2* libflac++6v5* libavahi-common3 libavahi-client3 alsa-utils \
&& mkdir /usr/ifi \
&& cd /usr/ifi \
&& curl -k -O -L http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u12_armhf.deb \
&& apt install ./libssl1.0.0_1.0.1t-1+deb8u12_armhf.deb \
&& curl -k -O -L http://security.debian.org/debian-security/pool/updates/main/c/curl/libcurl3_7.38.0-4+deb8u16_armhf.deb \
&& apt install ./libcurl3_7.38.0-4+deb8u16_armhf.deb \
&& git clone https://github.com/seniorgod/ifi-tidal-release \
&& chmod +x /usr/ifi/ifi-tidal-release/play \
&& chmod +x /usr/ifi/ifi-tidal-release/bin/tidal_connect_application \
&& chmod +x /usr/ifi/ifi-tidal-release/pa_devs/run.sh

COPY start.sh /usr/src/

CMD [ "/bin/bash", "/usr/src/start.sh" ]
55 changes: 55 additions & 0 deletions plugins/tidal/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

if [[ -n "$SOUND_DISABLE_TIDAL" ]]; then
echo "TIDAL is disabled, exiting..."
exit 0
fi

# --- ENV VARS ---
# SOUND_DEVICE_NAME: Set the device broadcast name for TIDAL
# SOUND_TIDAL_LOGLEVEL: Set the log-level flag between 0 and 6
# SOUND_TIDAL_WEBSOCKLOG: Set the web socket log level between 0 and 3

SOUND_DEVICE_NAME=${SOUND_DEVICE_NAME:-"balenaSound TIDAL $(hostname | cut -c -4)"}
SOUND_TIDAL_LOGLEVEL=${SOUND_TIDAL_LOGLEVEL:-3}
SOUND_TIDAL_WEBSOCKLOG=${SOUND_TIDAL_WEBSOCKLOG:-0}

# removed flag --netif-for-deviceid wlan0 \
# SOUND_TIDAL_ENABLE_MQA_PASSTHROUGH: Disable volume normalisation
# if [[ -z "$SOUND_SPOTIFY_DISABLE_NORMALISATION" ]]; then
# set -- "$@" \
# --enable-volume-normalisation
# fi

# SOUND_SPOTIFY_USERNAME: Login username for Spotify
# SOUND_SPOTIFY_PASSWORD: Login password for Spotify
# if [[ -n "$SOUND_SPOTIFY_USERNAME" ]] && [[ -n "$SOUND_SPOTIFY_PASSWORD" ]]; then
# set -- "$@" \
# --username "$SOUND_SPOTIFY_USERNAME" \
# --password "$SOUND_SPOTIFY_PASSWORD"
# fi

# Start TIDAL Connect Application
# We use set/$@ because application for some reason does not like env vars and quote escapes
# Full list of flags for tidal_connect_application are at https://github.com/balenalabs/balena-sound/pull/399#issuecomment-753691047

echo "Starting TIDAL plugin..."
echo "Device name: $SOUND_DEVICE_NAME"

# [[ -n "$SOUND_SPOTIFY_USERNAME" ]] && [[ -n "$SOUND_SPOTIFY_PASSWORD" ]] && echo "Using provided credentials for Spotify login."
# [[ -z "$SOUND_SPOTIFY_DISABLE_NORMALISATION" ]] && echo "Volume normalization enabled."

set -- /usr/ifi/ifi-tidal-release/bin/tidal_connect_application \
--tc-certificate-path "/usr/ifi/ifi-tidal-release/id_certificate/IfiAudio_ZenStream.dat" \
-f "$SOUND_DEVICE_NAME" \
--codec-mpegh true \
--codec-mqa false \
--model-name "$SOUND_DEVICE_NAME" \
--disable-app-security false \
--disable-web-security false \
--enable-mqa-passthrough false \
--log-level "$SOUND_TIDAL_LOGLEVEL" \
--enable-websocket-log "$SOUND_TIDAL_WEBSOCKLOG"
"$@"

exec "$@"