Thank you for your donation!


BLuetooth Headphone and Airplay
#1
Hi all
I bought a BT Heahphone to be used for my job (smart working at all in this fucking covid times...). 
I try to pair them with Moode, only for testing how they works for hearing music. I set up the BT renderer and it works very well.
Then I try to send from my iPhone a musci streaming from TIDAL app through Airplay.. but in this case no sounds from the headphones.
So I suppose that Moode is able to send output to the headphone via BT only from MPD, not from other renderers. Is is true ?
Is there any guide/procedure to enable it directly from consolle?

Thanks
Andrea
Reply
#2
I think it is possible but you will need to hack /var/www/inc/playerlib.php and then reboot.

In function startSps() make the following edit to the else block. Comment out the existing $device line and then add the new one that specifies 'bitstream' as the device.

Code:
    else {
        //$device = 'plughw:' . $array[0]['value'];
        $device = 'btstream';
    }


Here's the complete function.
Code:
function startSps() {
    // verbose logging
    if ($_SESSION['debuglog'] == '1') {
        $logging = '-vv';
        $logfile = '/var/log/shairport-sync.log';
    }
    else {
        $logging = '';
        $logfile = '/dev/null';
    }

    // get device num
    $array = sdbquery('select value from cfg_mpd where param="device"', cfgdb_connect());
    $device = $array[0]['value'];

    if ($_SESSION['alsaequal'] != 'Off') {
        $device = 'alsaequal';
    }
    elseif ($_SESSION['eqfa4p'] != 'Off') {
        $device = 'eqfa4p';
    }
    else {
        //$device = 'plughw:' . $array[0]['value'];
        $device = 'btstream';
    }

    // interpolation param handled in config file
    $cmd = '/usr/local/bin/shairport-sync ' . $logging .
        ' -a "' . $_SESSION['airplayname'] . '" ' .
        //'-w -B /var/local/www/commandw/spspre.sh -E /var/local/www/commandw/spspost.sh ' .
        '-- -d ' . $device . ' > ' . $logfile . ' 2>&1 &';

    debugLog('worker: (' . $cmd . ')');
    sysCmd($cmd);
}

if it works for you maybe I can look at adding this capability for upcoming moOde 6.6.0.
-Tim
Reply
#3
(06-18-2020, 01:15 PM)Tim Curtis Wrote: I think it is possible but you will need to hack /var/www/inc/playerlib.php and then reboot.

In function startSps() make the following edit to the else block. Comment out the existing $device line and then add the new one that specifies 'bitstream' as the device.

Code:
    else {
        //$device = 'plughw:' . $array[0]['value'];
        $device = 'btstream';
    }


Here's the complete function.
Code:
function startSps() {
    // verbose logging
    if ($_SESSION['debuglog'] == '1') {
        $logging = '-vv';
        $logfile = '/var/log/shairport-sync.log';
    }
    else {
        $logging = '';
        $logfile = '/dev/null';
    }

    // get device num
    $array = sdbquery('select value from cfg_mpd where param="device"', cfgdb_connect());
    $device = $array[0]['value'];

    if ($_SESSION['alsaequal'] != 'Off') {
        $device = 'alsaequal';
    }
    elseif ($_SESSION['eqfa4p'] != 'Off') {
        $device = 'eqfa4p';
    }
    else {
        //$device = 'plughw:' . $array[0]['value'];
        $device = 'btstream';
    }

    // interpolation param handled in config file
    $cmd = '/usr/local/bin/shairport-sync ' . $logging .
        ' -a "' . $_SESSION['airplayname'] . '" ' .
        //'-w -B /var/local/www/commandw/spspre.sh -E /var/local/www/commandw/spspost.sh ' .
        '-- -d ' . $device . ' > ' . $logfile . ' 2>&1 &';

    debugLog('worker: (' . $cmd . ')');
    sysCmd($cmd);
}

if it works for you maybe I can look at adding this capability for upcoming moOde 6.6.0.
-Tim

Hi Tim, it works! I'm able to hear music in my headphones from Airplay renderer.
Anyway, with some disturbance and buzz every 10-15 secs. The stream seems to hang for 2-3 secs, then flows well, then hangs...and so on. Maybe some settings to adjust about buffering or similar things?  Maybe we're on right path, but something still be tuned.
Any other suggestion?

- Andrea
Reply
#4
I tried the hack earlier today and it worked fine. No audio glitches.

What Pi and what kind of WiFi adapter?

Try just an Airplay connection and see if the issue occurs.
Reply
#5
(06-18-2020, 04:07 PM)Tim Curtis Wrote: I tried the hack earlier today and it worked fine. No audio glitches.

What Pi and what kind of WiFi adapter?

Try just an Airplay connection and see if the issue occurs.

Raspberry PI 2 Model B Rev 1.1

Below is the result of lsusb 

Device 005: ID ....... BroadCom Corp. BCM207002A0 Bluetooth 4.0
Device 004: ID .....   Ralink Technology, Corp. RT5370 Wireless Adapter
Device 003: ID ......  Standard Microsystem Corp. SMSC9512/9514 Fast
Device 002: ID......   Standard Microsystems Corp. SMC9514 Hub
Device 001: ID.....    Linux Foundation 2.0 root lib

What do you mean by "try just an Airplay connection and see if the issue occurs" ? Not playing music from TIDAL? 
thanks
Andrea


Does it depend from the  Wifi or from the BT adapter?
I will check also connecting the Raspy with ethernet cable..
Reply
#6
The troubleshooting approach is to first try to isolate the issue.

You would try playing your source (Tidal, etc) via Airplay to some speakers connected to Pi. This would take the Bluetooth connection out of the picture.
Reply
#7
(06-18-2020, 04:34 PM)Tim Curtis Wrote: The troubleshooting approach is to first try to isolate the issue.

You would try playing your source (Tidal, etc) via Airplay to some speakers connected to Pi. This would take the Bluetooth connection out of the picture.

Of course!
Well, until the code change, I was able to connect simple headphones to the 3.5" output of the RPi, playing music through Airplay, with no audio glitch .
Now, to make a test,  I turned off the BT Headphone, removing also it from the connected BT device on BT Bluez setting page, changing also the MPD->Local instead of MPD->Bluetooth. Then I plug the cable headphones in the 3.5" audio output. Gosh! Trying to play music from any Airplay source (TIDAL, Amazon Music, Spotify), no sound from the headphone.
Playing instead something from other sources (Radio, music stored in my NAS) the sound comes out from the headphones ! It seems that now the Airplay renderer works ONLY towards BT headphones.

In fact, re-coupling the BT headphones, connecting them, and setting MPD->BLuetooth, the Airplay stream works (even sometimes with glitches...). Very strange, isn't it?

Anyway, making some tests with different Airplay sources, it seems that the one having less glitches is Amazon Music, while Spotify and Tidal have some glitches (but I think that this has nothing to do with the main issue....)
Reply
#8
@mancio61 

I'm not sure from your description of your test in this latest post. Did you revert startSps() to the original code? If not, then the Spotify renderer will try to output to BT no matter what the MPD setting.

Regards,
Kent
Reply
#9
no, I still maintain the modified code.
Reply
#10
So, try to revert the code to the original one, and the situation now is this:

Case 1) BT on an BT Headphones connected: MPD related music can be hear from BT Headphone, Airplay is mute
Case 2) BT off: MPD related music can be hear from std heaphone with 3.5" audio output, same for Airplay

Using instead the modified code:
Case 3) BT on; both MPD and Airplay can be hear (Airplay with some noise and glitch every 15-20 secs)
Case 4) BT OFF: only MPD from std headphones, Airplay is muted

maybe, with some adjustment to the code, it should be possibile to make the things work in every use cases (with BT or std Headphones, with MPD or Airplay...)
Reply


Forum Jump: