Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Spotify output to Bluetooth
#1
I'm new to Moode Audio, using the latest version 4.3 2018-09-27 on a Pi Zero W and it's working nicely.

I noticed the Bluetooth output streaming only supports MPD. I'm using librespot for Spotify Connect and it always outputs to the  default ALSA device (i don't use i2s). There's a similar thread regarding Airplay here.

Are there any plans to change this, i.e. customizable output device for each renderer, changing the default ALSA device when a Bluetooth device is connected or some other way to auto-detect the 'active' device? 

If I manually run librespot with --device  btstreamit works fine. I found the code responsible for starting librespot in playerlib.php. Is there a way to detect that bt streaming is enabled? Maybe in one of the session vars? Running a shell command should work but may be expensive. It would be trivial to change the device string to 'btstream' to make it work. And restart it when a bt device connects/disconnects to switch the output device.
I'm not very familiar with alsa / bluealsa, so not sure if this is the right approach.
Reply
#2
Hi,

The problem is that IIRC not all the renderers support virtual ALSA devices e.g., Airplay. If Airplay supported it and since Spotify supports it I'd be interested in coding the support into moOde since these are the two most widely used renderers.

Are you able to add your request to the shairport-sync Git issue you referenced. MikeB might be inclined to look into it :-)

You can determine the configuration of audio output by:

Code:
$_SESSION['audioout']
sqlite3 /var/local/www/db/moode-sqlite3.db "select value from cfg_system where param='audioout'"

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
I don't know about Airplay / shairport-sync, don't own any Apple devices. Shairport-sync starts when I use '-d btstream', without a mixer-control. But i was unable to find a decent solution to stream music from my Linux pc (pulseaudio struggles with airplay support).

For Spotify, some minor changes in playerlib.php make it work for me:

Code:
--- playerlib.php.bak   2018-11-30 23:15:37.896253863 +0100
+++ playerlib.php       2018-11-30 22:31:35.256929700 +0100
@@ -1736,18 +1736,22 @@
               $cfg_spotify[$row['param']] = $row['value'];
       }
 
-       $result = sysCmd('aplay -L | grep -v ALSA | grep -w default');
-       if ($_SESSION['cardnum'] == '0') {
-               if ($_SESSION['i2sdevice'] == 'none') { // On-board audio
-                       $device = 'default:CARD=ALSA';
+       if ($_SESSION['audioout'] == 'Bluetooth') {
+               $device = 'btstream';
+       } else {
+               $result = sysCmd('aplay -L | grep -v ALSA | grep -w default');
+               if ($_SESSION['cardnum'] == '0') {
+                       if ($_SESSION['i2sdevice'] == 'none') { // On-board audio
+                               $device = 'default:CARD=ALSA';
+                       }
+                       else { // I2S audio
+                               $device = $result[0];
+                       }
               }
-               else { // I2S audio
+               else { // USB audio (cardnum = 1)
                       $device = $result[0];
               }
       }
-       else { // USB audio (cardnum = 1)
-               $device = $result[0];
-       }
 
       $linear_volume = $cfg_spotify['volume_curve'] == 'Linear' ? ' --linear-volume' : '';
       $volume_normalization = $cfg_spotify['volume_normalization'] == 'Yes' ? ' --enable-volume-normalisation --normalisation-pregain ' .  $cfg_spotify['normalization_pregain'] : '';
@@ -2484,6 +2488,9 @@
       }
 
       sysCmd('systemctl restart mpd');
+       sysCmd('killall librespot');
+       startSpotify();
+
}
 
// reconfigure MPD volume
Reply
#4
Interesting. I'll test shairport-sync w/o mixer.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: