balena-io-experimental / balena-sound

Build a single or multi-room streamer for an existing audio device using a Raspberry Pi! Supports Bluetooth, Airplay and Spotify Connect
https://balena.io/blog/turn-your-old-speakers-or-hi-fi-into-bluetooth-receivers-using-only-a-raspberry-pi/
MIT License
2.4k stars 428 forks source link

Support to a Tidal Connect #371

Open nmcmartins opened 3 years ago

nmcmartins commented 3 years ago

An excellent improvement will be to include support for Tidal Connect.

shawaj commented 3 years ago

More info on Tidal connect

It appears to be closed source. You have to register your interest here and wait to hear back from them.

shawaj commented 3 years ago

Just found this after some googling https://github.com/seniorgod/ifi-tidal

Also this https://github.com/seniorgod/ifi-tidal-release ... which looks like it should work in balenaSound with some wrangling.

And this https://github.com/ppy2/ifi-tidal-release

Tidal Volumio plugin https://github.com/play-so-fun/volumio_tidal

Tidal API https://github.com/play-so-fun/TidalAPI and https://github.com/lucaslg26/TidalAPI and https://github.com/max-huster/TidalAPI

Python https://github.com/tamland/python-tidal

API reference https://github.com/spencercharest/tidal-api/blob/master/docs/api.md

Keys - https://gist.github.com/artworked/3003fa0183b464a0b0d2ca2e77afe477

openTidal - https://github.com/openTIDAL/docTIDAL/wiki/API-Keys https://github.com/openTIDAL/docTIDAL/wiki/ https://github.com/openTIDAL/libopenTIDAL

shawaj commented 3 years ago

Have almost got this running as a plugin. Have pushed my dev branch here #399

Full error output... ``` root@2ec9b5a:/usr/ifi/ifi-tidal-release/bin# /usr/ifi/ifi-tidal-release/bin/tidal_connect_application \ > --tc-certificate-path "/usr/ifi/ifi-tidal-release/id_certificate/IfiAudio_ZenStream.dat" \ > --netif-for-deviceid wlan0 \ > -f "balenaSound stream to project" \ > --codec-mpegh true \ > --codec-mqa false \ > --model-name "balenaSound Streamer" STARTING TidalConnect services, version: 1.1.3 [2021-01-03 21:19:00.254] [tisoc] [info] [HttpClient.cpp:25] certification path: /etc/ssl/certs Expression 'GetExactSampleRate( hwParams, &defaultSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 895 Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 924 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 934 Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 934 Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 934 Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback ALSA lib conf.c:5014:(snd_config_expand) Unknown parameters {AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0} ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0} ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock [2021-01-03 21:19:00.409] [tisoc] [debug] [DeviceInfo.cpp:103] mac addr : "dc:a6:32:a4:af:4d" [2021-01-03 21:19:00.409] [tisoc] [debug] [DeviceInfo.cpp:113] device id: "c263d56a5eb7cf4c137755762be5fb00" [2021-01-03 21:19:00.409] [tisoc] [trace] [avahiImpl.cpp:33] serviceName : balenaSound Streamer-e322c9768461956dbefe40c0d0bae127 [2021-01-03 21:19:00.409] [tisoc] [info] [ServiceManager.cpp:19] service registered: clientcomm [2021-01-03 21:19:00.409] [tisoc] [info] [ServiceManager.cpp:19] service registered: queue [2021-01-03 21:19:00.409] [tisoc] [info] [ServiceManager.cpp:19] service registered: playback [2021-01-03 21:19:00.409] [tisoc] [info] [ServiceManager.cpp:19] service registered: session [2021-01-03 21:19:00.409] [tisoc] [info] [ServiceManager.cpp:19] service registered: speaker [2021-01-03 21:19:00.409] [tisoc] [info] [ServiceManager.cpp:19] service registered: mdns [2021-01-03 21:19:00.409] [tisoc] [debug] [SpeakerCommunicatorImpl.cpp:72] ## SpeakerCommunicator Config ## [2021-01-03 21:19:00.409] [tisoc] [debug] [SpeakerCommunicatorImpl.cpp:73] controller-unix-socket-path : "/tmp/tisoc-controller" [2021-01-03 21:19:00.409] [tisoc] [info] [SpkconServer.cpp:38] SpkconServer start [2021-01-03 21:19:00.409] [tisoc] [info] [SpkconServer.cpp:442] updateConnectionState:0->1 [2021-01-03 21:19:00.410] [tisoc] [debug] [SpkconServer.cpp:156] socket create success. fd=3 [2021-01-03 21:19:00.411] [tisoc] [info] [SpkconServer.cpp:66] SpkconServer start ret:true [2021-01-03 21:19:00.412] [tisoc] [info] [SpkconServer.cpp:384] packetSenderThread start [2021-01-03 21:19:00.412] [tisoc] [debug] [Service.cpp:29] started :: speaker [2021-01-03 21:19:00.412] [tisoc] [debug] [avahiImpl.cpp:57] config.useDaemon_:false [2021-01-03 21:19:00.412] [tisoc] [debug] [avahiImpl.cpp:58] config.autoStart_:true [2021-01-03 21:19:00.412] [tisoc] [info] [SpkconServer.cpp:261] socketControlThread start. [2021-01-03 21:19:00.413] [tisoc] [debug] [SpkconServer.cpp:286] wait connect. [2021-01-03 21:19:00.413] [tisoc] [error] [avahiImpl.cpp:358] avahi_client_new() FAILED: Daemon not running [2021-01-03 21:19:00.413] [tisoc] [error] [avahiImpl.cpp:70] avahi start failed. [2021-01-03 21:19:00.413] [tisoc] [debug] [Service.cpp:29] started :: mdns [2021-01-03 21:19:00.413] [tisoc] [info] [ServiceManager.cpp:27] service started: mdns [2021-01-03 21:19:00.414] [tisoc] [info] [ServiceManager.cpp:28] useDaemon : 0 autoStart : 1 serviceName : balenaSound Streamer-e322c9768461956dbefe40c0d0bae127 serviceType : _tidalconnect._tcp modelName : balenaSound Streamer capability : 1 port : 2019 deviceId : e322c9768461956dbefe40c0d0bae127 friendlyName: balenaSound stream to project [2021-01-03 21:19:00.414] [tisoc] [trace] [PlaybackControllerImpl.cpp:79] ## PlaybackController Config ## [2021-01-03 21:19:00.414] [tisoc] [debug] [PlaybackControllerImpl.cpp:80] disable-web-security : false [2021-01-03 21:19:00.415] [tisoc] [debug] [Service.cpp:29] started :: playback [2021-01-03 21:19:00.415] [tisoc] [info] [ServiceManager.cpp:27] service started: playback [2021-01-03 21:19:00.415] [tisoc] [info] [ServiceManager.cpp:28] disableWebSecurity : 0 [2021-01-03 21:19:00.469] [tisoc] [debug] [Service.cpp:29] started :: clientcomm [2021-01-03 21:19:00.469] [tisoc] [info] [ServiceManager.cpp:27] service started: clientcomm [2021-01-03 21:19:00.470] [tisoc] [info] [ServiceManager.cpp:28] websocket-port : 2019 disable-app-security: 0 enable-websocket-log: 0 [2021-01-03 21:19:00.472] [tisoc] [debug] [Service.cpp:29] started :: session [2021-01-03 21:19:00.473] [tisoc] [info] [ServiceManager.cpp:27] service started: session [2021-01-03 21:19:00.473] [tisoc] [info] [ServiceManager.cpp:28] [2021-01-03 21:19:00.473] [tisoc] [trace] [QueueManagerImpl.cpp:43] ## QueueManager Config ## [2021-01-03 21:19:00.473] [tisoc] [debug] [QueueManagerImpl.cpp:44] disable-web-security : false [2021-01-03 21:19:00.474] [tisoc] [debug] [Service.cpp:29] started :: queue [2021-01-03 21:19:00.474] [tisoc] [info] [ServiceManager.cpp:27] service started: queue [2021-01-03 21:19:00.475] [tisoc] [info] [ServiceManager.cpp:28] disableWebSecurity_: 0 STARTED TidalConnect services. ```

The key error is:

[2021-01-03 21:19:00.413] [tisoc] [error] [avahiImpl.cpp:358] avahi_client_new() FAILED: Daemon not running
[2021-01-03 21:19:00.413] [tisoc] [error] [avahiImpl.cpp:70] avahi start failed.

Basically I think it is trying to use avahi / avahi-daemon - but it can't because balenaOS doesn't have systemd in the containers. So I think I maybe need to find some way to use DBUS to work with avahi in the balena HostOS.

Bit in over my head now to be honest! Will keep messing around with it.

But the good news is that the tidal connect service is authenticating and it is running - it just doesn't actually advertise properly over mDNS so the Tidal app can't find it.

Loads more info here too - https://github.com/balenalabs/balena-sound/pull/399#issuecomment-753691047

shawaj commented 3 years ago

@nmcmartins good news - i got it working https://github.com/balenalabs/balena-sound/pull/399#issuecomment-753708240

Need to tidy it up and sort out volume control and some other stuff but it is working so far. If you want you can test it using balena CLI...

npmstart-pray commented 2 years ago

Any updates/progress reports?

marcgarciamarti commented 2 years ago

@nmcmartins good news - i got it working https://github.com/balenalabs/balena-sound/pull/399#issuecomment-753708240

Need to tidy it up and sort out volume control and some other stuff but it is working so far. If you want you can test it using balena CLI...

Hi! Could you provide guidance on how to enable this?

Thanks!!