Moode Audio Player for Raspberry Pi

Hi Kent,

Couple of constraints drive the design of the radio station feature in Moode.

- Stations don't transmit logo images in their metadata.
- MPD does not maintain the name of the station pls file when it initiates playback. It only provides the station url.

Thus there is a sql table keyed by station url that makes the following possible:

- logo display from either local image file or url
- auto-update of station url from permalink
- uniform station name in Browse, Playlist and in metadata underneath the station logo.

-Tim
Thanks a lot Kent and Tim for the very detailed answer, loud and clear! I'll add entries in the SQL database and add logos in /var/www/images/radio-logos, for a couple of missing stations. Fingers crossed that the setup survives the next Moode update :) (wouldn't be a big deal if it doesn't).
 
Hi Kent,

Station logo and pls file have same base name.

The Jazz Groove.pls
The Jazz Groove.png

-Tim

Hi, Tim.

I abided by this requirement when I was constructing those new station files I sent you last year and I think it makes sense for others to do the same.

However, even without reviewing the code which manages and plays radio stations (though I've started), it is clear that in Release 3.1 this is not, or at least is no longer, a strict requirement.

Take BBC Asian Network for example. We have two .pls files and only one .png file:

BBC Asian Network.pls
BBC 320K Asian Network.pls
BBC Asian Network.png

and similarly for the other BBC high- and low- data rate channels.

Comparing the cfg_radio entries for these stations makes it obvious what's going on here and why, but let's leave the technical discussion for another time. I don't want my nibbling around the edges to distract you from core progress on 3.2.

And thank you for your continuing patience.

Regards,
Kent
 
Thanks a lot Kent and Tim for the very detailed answer, loud and clear! I'll add entries in the SQL database and add logos in /var/www/images/radio-logos, for a couple of missing stations. Fingers crossed that the setup survives the next Moode update :) (wouldn't be a big deal if it doesn't).

Glad to see you're the adventuresome type, Alec.

I have some thoughts about how to survive the updates but I need to review the code first.

Regards,
Kent
 
...How is volume handled in Spotify Connect?

I assume the client sends volume cmds to Spotify Connect server which interfaces to ALSA directly, overriding Moode/MPD volume setting.

-Tim
This is a bit of a puzzle. The Spotify Connect Server reveives the volume change signals and reports them correctly. But, either the Moode fix volume takes precedence, or the control is not working, because it has no effect.

I was assuming this was due to the volume being set as fixed, I'll try changing the setting and see if it affects the volume for a final answer.

Good catch.
Rafa.
 
Hi, Tim.

I abided by this requirement when I was constructing those new station files I sent you last year and I think it makes sense for others to do the same.

However, even without reviewing the code which manages and plays radio stations (though I've started), it is clear that in Release 3.1 this is not, or at least is no longer, a strict requirement.

Take BBC Asian Network for example. We have two .pls files and only one .png file:

BBC Asian Network.pls
BBC 320K Asian Network.pls
BBC Asian Network.png

and similarly for the other BBC high- and low- data rate channels.

Comparing the cfg_radio entries for these stations makes it obvious what's going on here and why, but let's leave the technical discussion for another time. I don't want my nibbling around the edges to distract you from core progress on 3.2.

And thank you for your continuing patience.

Regards,
Kent

Hi Kent,

True. The sql table comes in handy for the case where same logo is used for low and high bitrate versions of a station.

-Tim
 
This is a bit of a puzzle. The Spotify Connect Server reveives the volume change signals and reports them correctly. But, either the Moode fix volume takes precedence, or the control is not working, because it has no effect.

I was assuming this was due to the volume being set as fixed, I'll try changing the setting and see if it affects the volume for a final answer.

Good catch.
Rafa.

Hi Rafa,

Maybe need to specify mixer name?

-m PCM for usb audio device
-m Digital for i2s audio device

--playback_device PLAYBACK_DEVICE, -o PLAYBACK_DEVICE
alsa output device (get name from aplay -L)
--mixer_device_index MIXER_DEVICE_INDEX
alsa card index of the mixer device
--mixer MIXER, -m MIXER
alsa mixer name for volume control
--dbrange DBRANGE, -r DBRANGE
alsa mixer volume range in Db

-Tim
 
Hi Rafa,

Maybe need to specify mixer name?...

Yep, that's it, but I had to specify the mixer device index as well... I have no idea where you could get this values? I dind't find them in the AirPlay implementation, but perhaps they are somewhere else?

At any rate, this extra parameters worked:
-m PCM --mixer_device_index 1

Thanks,
Rafa.
 
Hi all, hi Tim.

First of all many thanks for this great piece of software.
I have a RPI 3, IQ Audio Digi-Amp+ with rotary encoder and I2C 16x2 LCD.
I downloaded the image and proceeded with the configuration.
All went fine. I'm able to stream radio stations and airplay as well, except that I have 3 questions:

1. Neither UI volume nor rotary encoder control Airplay volume even if we change Configure, Network audio, Airplay volume to Software instead of Auto. Is this a bug or a feature ;-) ?
2. When streaming via Airplay, metadata (artist, title, cover art) is not displayed in UI even if Configure, Audio, Airplay metadata is enabled. It has worked only once and never again. Am I missing some configuration here?
3. File /var/www/currentsong.txt is not updated when streaming via Airplay even if Configure, System, LocalServices, Metadata file is enabled. Am I missing some configuration here?
4. Does someone has created a python script that reads /var/www/currentsong.txt for metadata from radio and airplay and update accordingly an 16x2 LCD or equivalent? Even if it's not the same LCD if someone can share its script I could hack it to make it work with my LCD.

Thanks
 
...2. When streaming via Airplay, metadata (artist, title, cover art) is not displayed in UI even if Configure, Audio, Airplay metadata is enabled. It has worked only once and never again. Am I missing some configuration here?...
Hi Perezsy,

This happened to me as well with Spotify. Google Play, on the other hand, sends the metadata via AirPlay perfectly. Which audio app are you using to test this?

Regards,
Rafa.
 
Friends,

Expanded instructions on the Spotify Connect how-to:

I have added instructions to have volume control from within your phone or tablet to the Spotify Connect client thanks to Tim's advice.

I have also added instructions to configure as a startup service until that point in which it is integrated to the main Moode player.

Here's the link again:
https://github.com/RafaPolit/moode-spotify-connect-web

Let me know if there is something not clear.

Best regards,
Rafa.
 
Hi all, hi Tim.

First of all many thanks for this great piece of software.
I have a RPI 3, IQ Audio Digi-Amp+ with rotary encoder and I2C 16x2 LCD.
I downloaded the image and proceeded with the configuration.
All went fine. I'm able to stream radio stations and airplay as well, except that I have 3 questions:

1. Neither UI volume nor rotary encoder control Airplay volume even if we change Configure, Network audio, Airplay volume to Software instead of Auto. Is this a bug or a feature ;-) ?
2. When streaming via Airplay, metadata (artist, title, cover art) is not displayed in UI even if Configure, Audio, Airplay metadata is enabled. It has worked only once and never again. Am I missing some configuration here?
3. File /var/www/currentsong.txt is not updated when streaming via Airplay even if Configure, System, LocalServices, Metadata file is enabled. Am I missing some configuration here?
4. Does someone has created a python script that reads /var/www/currentsong.txt for metadata from radio and airplay and update accordingly an 16x2 LCD or equivalent? Even if it's not the same LCD if someone can share its script I could hack it to make it work with my LCD.

Thanks

Hi,

- Airplay renderer (shairport-sync) is a completely separate playback application from MPD. In the Airplay framework, volume is always controlled by the client (iTunes, etc). Currentsong.txt contains only metadata from MPD.

- Airplay metadata is best effort. Its sent by the client (iTunes, etc) and when received by shairport-sync is placed on a named pipe which is then read by Moode. Sometimes all the metadata pieces aren't present on the pipe or the pipe become "out of sync" with the reader engine.

Some things to try that may get the pipe working include turning off/on Airplay receiver, using next/previous track buttons in client.

-Tim
 
Friends,

Expanded instructions on the Spotify Connect how-to:

I have added instructions to have volume control from within your phone or tablet to the Spotify Connect client thanks to Tim's advice.

I have also added instructions to configure as a startup service until that point in which it is integrated to the main Moode player.

Here's the link again:
https://github.com/RafaPolit/moode-spotify-connect-web

Let me know if there is something not clear.

Best regards,
Rafa.

Hi Rafa,

For the particular audio device that you are using, please email me the output from cmds below. I'm trying to understand a bit more about how the Connect app handles volume.

aplay -l
amixer controls
cat /etc/mpd.conf

-Tim
 
Last edited:
Autoplay failure

Autoplay has suddenly stopped working for me, although it used to work fine. Apologies if this is a known issue, but I couldn't find any related info when searching the forum.

What actually happens is that when I power up my moode system, I do get audio for about 15 seconds- then audio stops. When I look at my moode system via a web browser, time is clicking away and moode appears to think it's playing. If I click pause then play, or click in the 'time circle', audio playback resumes and moode plays fine until the next power cycle.

I'm running Release: 3.1 2016-12-05 on a RPI model 1B with a "PiFi" DAC using the "HIFI" DAC driver.

Please let me know how I can diagnose this further.

 
Hi Rafa,

For the particular audio device that you are using, please email me the output from cmds below. I'm trying to understand a bit more about how the Connect app handles volume.

aplay -l
amixer controls
cat /etc/mpd.conf

-Tim

Sure!

$ aplay -l (lower case!)
Code:
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [NuForce USB Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [NuForce USB Audio], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

$ aplay -L (capital letter)
Code:
pi@moode:~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
crossfeed
ladspa
default:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
default:CARD=Audio
    NuForce USB Audio, USB Audio
    Default Audio Device
sysdefault:CARD=Audio
    NuForce USB Audio, USB Audio
    Default Audio Device
front:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    Front speakers
surround21:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    Direct sample mixing device
dmix:CARD=Audio,DEV=1
    NuForce USB Audio, USB Audio #1
    Direct sample mixing device
dsnoop:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    Direct sample snooping device
dsnoop:CARD=Audio,DEV=1
    NuForce USB Audio, USB Audio #1
    Direct sample snooping device
hw:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    Direct hardware device without any conversions
hw:CARD=Audio,DEV=1
    NuForce USB Audio, USB Audio #1
    Direct hardware device without any conversions
plughw:CARD=Audio,DEV=0
    NuForce USB Audio, USB Audio
    Hardware device with all software conversions
plughw:CARD=Audio,DEV=1
    NuForce USB Audio, USB Audio #1
    Hardware device with all software conversions

$ amixer controls
Code:
numid=3,iface=MIXER,name='PCM Playback Route'
numid=2,iface=MIXER,name='PCM Playback Switch'
numid=1,iface=MIXER,name='PCM Playback Volume'
numid=5,iface=PCM,name='IEC958 Playback Con Mask'
numid=4,iface=PCM,name='IEC958 Playback Default'

$ cat /etc/mpd.conf
Code:
#########################################
# This file is automatically generated by
# the player MPD configuration page.     
#########################################

follow_outside_symlinks "yes"
follow_inside_symlinks "yes"
db_file "/var/lib/mpd/tag_cache"
sticker_file "/var/lib/mpd/sticker.sql"
log_file "/var/log/mpd/mpd.log"
pid_file "/var/run/mpd/pid"
music_directory "/var/lib/mpd/music"
playlist_directory "/var/lib/mpd/playlists"
state_file "/var/lib/mpd/state"
user "mpd"
group "audio"
bind_to_address "any"
port "6600"
log_level "default"
zeroconf_enabled "yes"
zeroconf_name "moode"
samplerate_converter "soxr very high"
volume_normalization "no"
audio_buffer_size "4096"
buffer_before_play "10%"
filesystem_charset "UTF-8"
id3v1_encoding "UTF-8"
gapless_mp3_playback "yes"
auto_update "no"
mixer_type "disabled"
max_output_buffer_size "81920"
restore_paused "yes"
replaygain "off"
max_connections "20"

decoder {
plugin "ffmpeg"
enabled "yes"
}

input {
plugin "curl"
}

audio_output {
type "alsa"
name "ALSA default"
device "hw:1,0"
dsd_usb "yes"
}

audio_output {
type "alsa"
name "ALSA crossfeed"
device "crossfeed"
dsd_usb "yes"
}
 
As far as I can tell, it's directly controlling the ALSA mixer for the USB Audio device. If go in alsamixer, switch with F6 to the device and change the volume on my phone, the mixer shows the changes in volume in real time. There is a linear mapping from 0-100 mapped to the 50-100 to the ALSA in integers, so a jump from 100 to 93 (one click on the phone) decreases in 4.0 the ALSA value.

Not sure this helps, if you need me to test anything, I'll be more than glad to help!

Rafa.
Ps. I just found an ssh client app for iOS, and did all the commands from the iPad, great thing really not to have to use the computer for smaller tasks! LOL!
 
Last edited:
As far as I can tell, it's directly controlling the ALSA mixer for the USB Audio device. If go in alsamixer, switch with F6 to the device and change the volume on my phone, the mixer shows the changes in volume in real time. There is a linear mapping from 0-100 mapped to the 50-100 to the ALSA in integers, so a jump from 100 to 93 (one click on the phone) decreases in 4.0 the ALSA value.

Not sure this helps, if you need me to test anything, I'll be more than glad to help!

Rafa.

Hi Rafa,

Change to Hardware volume in MPD, verify playback and then post just the ALSA default output block. Thx.

audio_output {
type "alsa"
name "ALSA default"
device "hw:1,0"
dsd_usb "yes"
}

-Tim