Moode Audio Player for Raspberry Pi

Yeah a remote is essential IMHO, it made the experience so much better.
I used the remote from my old A/V receiver, so it has a lot of buttons (fm tuner, cd,dvd aux etc).
I also mapped the tuner numeric keys to stations like this:
Code:
begin
    prog = irexec
    button = KEY_8
    config = mpc clear; mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p; mpc play
    repeat = 0
end
so I just hit the number and it loads the station, just like the old hi-fi I had.
User experience with the remote is very similar as before but sound quality and features are way improved.


To have lirc running I really hadn't a lot to do.

- Wire the TSOP, note the gpio pin.

- add this to your boot/config.txt
Code:
dtoverlay=lirc-rpi,gpio_in_pin=25
change 25 to your gpio number. Note it's gpio number, not pin number.

Then it's just a matter of following the usual instructions of
- installing lirc
- using irrecord to record the remote and generate a config file
- copy that config file to /etc/lirc/lircd.conf.
- create a /etc/lirc/lircrc which will store the irexec mpc binds
- sudo /etc/init.d/lirc start
you then can use irw command to see if your binds are getting received

I'm pretty sure I've seen quite a few detailed guides on volumio forum, showing all the commands.
If you don't add that line to boot/config.txt it will never work.

------
the only problem is that on the same moode partition I also have kodi running on another remote and other tools. Add all that custom configuration and the moode upgrades are becoming a little troublesome to update by hand.
Is there a plan to make it upgrade in a way we don't lose all the tweaked things and files?
Maybe starting with a stripped raspbian and then adding moode as a combination of packages from a repo and git cloning?
This way one would just upgrade the packages without starting from scratch every time?

otherwise I have to find a way to apply all my modded files and conf automatically every time I update... diff and patch maybe?
 
About the knob.sh script and remotes (lirc)...
I remember the UI updated in realtime time ago, now I've just read it's handled by the knob.sh script.

Well.. long story short: the webUI volume wasn't updating with remote presses... it adjusted the alsa volume but not the ui. (because I was using mpc commands)

Also using alsa commands or using alsamixer doesn't update the webUI. But I don't care about that now.

Premise: I'm not a coder nor programmer, first time with bash done with 10 mins of googling and some trial and error, so don't trust this if you don't know what you're doing.
Your raspberry, your ears or your window glasses could explode :D

I wanted that hitting volume buttons in the remote would update the webUI too in realtime, not only the alsa volume.

I tried the usual way (binding mpc or alsa commands) but the webUi wasn't updating in real time... a manual refresh was needed.

So I had to add a bit of code to knob.sh.
This allows me to bind easy commands in lircrc AND the knob updates in realtime.
The original script worked by feeding it a volume number to set e.g.: "./knob.sh 35"
I modded it to have also "./knob.sh volup" (or voldown / mute).

To give you an idea (using steps of 3 in this example):
Code:
if [ "$1" = "volup" ]; then 
        actual=$(sed -n -e 's/^.*volume_knob_setting: //p' /var/www/tcmods.conf)
        newvol=$(echo $((actual+3)))

        # update knob setting
        sed -i '/volume_knob_setting:/c\volume_knob_setting: '$newvol /var/www/tcmods.conf

        # update ALSA volume
        if [ "$VOLTYPE" = "volume_curve_logarithmic: Yes" ]; then
                amixer set Digital -M $newvol% > /dev/null
        else
                amixer set Digital $newvol% > /dev/null
        fi

        exit
fi

if [ "$1" = "voldown" ]; then 
        actual=$(sed -n -e 's/^.*volume_knob_setting: //p' /var/www/tcmods.conf)
        newvol=$(echo $((actual-3)))

        # update knob setting
        sed -i '/volume_knob_setting:/c\volume_knob_setting: '$newvol /var/www/tcmods.conf

        # update ALSA volume
        if [ "$VOLTYPE" = "volume_curve_logarithmic: Yes" ]; then
                amixer set Digital -M $newvol% > /dev/null
        else
                amixer set Digital $newvol% > /dev/null
        fi

        exit
fi

if [ "$1" = "mute" ]; then 
        # update knob setting
        sed -i '/volume_knob_setting:/c\volume_knob_setting: '0 /var/www/tcmods.conf

        # update ALSA volume
        if [ "$VOLTYPE" = "volume_curve_logarithmic: Yes" ]; then
                amixer set Digital -M 0% > /dev/null
        else
                amixer set Digital 0% > /dev/null
        fi

        exit
fi
e.g. in lircrc now I just use the new commands:
Code:
begin
    prog = irexec
    button = KEY_VOLUMEUP
    config = /var/www/knob.sh volup
    repeat = 4
end
begin
    prog = irexec
    button = KEY_VOLUMEDOWN
    config = /var/www/knob.sh voldown
    repeat = 4
end
begin
    prog = irexec
    button = KEY_MUTE
    config = /var/www/knob.sh mute
    repeat = 4
end
It works. I'll have to fix the mute to effectively mute and unmute instead of setting the volume to 0, but I was in a hurry and tired when I did this.

Now the problem is...
Is this the best way to do it?
Or it's already implemented (to update the volume knob in realtime when using IR remotes) and I didn't notice it?




setup is raspy B+, IQaudio pidac+, moode r2.2, set to hw audio etc.

PS: also having fun with text to speech, hit a button on remote and a sweet lady voice tells me which station I'm listening to, or the song/album/artist or the volume level (dirty fix until I get a LCD :D )

Can I suggest a slight tweak to the knob.sh modifications to allow support for different mixer types:

In the volup and voldown code blocks, instead of:
Code:
if [ "$VOLTYPE" = "volume_curve_logarithmic: Yes" ]; then
                amixer set Digital -M $newvol% > /dev/null
else
                amixer set Digital $newvol% > /dev/null
fi
This should instead be:

Code:
if [ "$VOLTYPE" = "volume_curve_logarithmic: Yes" ]; then
                amixer set $MIXERNAME -M $newvol% > /dev/null
else
                amixer set $MIXERNAME $newvol% > /dev/null
fi

Cheers
 
Hi,

Thank you, Tim, for implementing knob.sh.

I installed lirc on Moode 2.3 and the volume control works well.
I wrote short scripts vol5up.sh and vol5dn.sh, and irexec calls these scripts for volume up/down.

vol5up.sh
Code:
#!/bin/sh
level=`mpc volume | awk -F":" '{print substr($2, 1, index($2, "%")-1)+5}'`
if [ $level -gt 100 ] ; then
  level=100
fi
mpc volume $level > /dev/null
/var/www/knob.sh $level > /dev/null
exit 0

vol5dn.sh
Code:
#!/bin/sh
level=`mpc volume | awk -F":" '{print substr($2, 1, index($2, "%")-1)-5}'`
if [ $level -lt 0 ] ; then
  level=0
fi
mpc volume $level > /dev/null
/var/www/knob.sh $level > /dev/null
exit 0

See here.

Regards,
yjo
 
Hi,

Thank you, Tim, for implementing knob.sh.

I installed lirc on Moode 2.3 and the volume control works well.
I wrote short scripts vol5up.sh and vol5dn.sh, and irexec calls these scripts for volume up/down.

vol5up.sh
Code:
#!/bin/sh
level=`mpc volume | awk -F":" '{print substr($2, 1, index($2, "%")-1)+5}'`
if [ $level -gt 100 ] ; then
  level=100
fi
mpc volume $level > /dev/null
/var/www/knob.sh $level > /dev/null
exit 0

vol5dn.sh
Code:
#!/bin/sh
level=`mpc volume | awk -F":" '{print substr($2, 1, index($2, "%")-1)-5}'`
if [ $level -lt 0 ] ; then
  level=0
fi
mpc volume $level > /dev/null
/var/www/knob.sh $level > /dev/null
exit 0

See here.

Regards,
yjo

Hi,

I remember that u had originally proposed an interface to the volume knob somewhere back in one of the late 1.x releases as part of your IR project so thank you for the nice idea :)

I see u are using "mpc volume" calls so u must be using MPD Software volume control correct?

Also, thinking a bit, since mute state is similar to volume level in that both are decoupled from MPD in Moode, I should be able to add a mute interface to knob.sh.

Regards,
Tim
 
Tim,
Thank you again for implementing my proposal :)

I see u are using "mpc volume" calls so u must be using MPD Software volume control correct?

Right, I'm using a USB-DAC, and I didn't confirm whether it works with hardware volume control or not.

Also, thinking a bit, since mute state is similar to volume level in that both are decoupled from MPD in Moode, I should be able to add a mute interface to knob.sh.

Yes, but I scarcely use mute function, and the priority of this issue is relatively low to me :)

Regards,
yjo
 
USB audio glitch while browsing library on NAS

Hi,

When I play a file to an USB device (nothing heavy 44.1k/16) and I browse a library which is mostly located on a NAS, every time I click an album, the system tries to get the artwork thumbnail. During that process, there is a short but very noticeable audio glitch, which lasts longer if the system cannot find any artwork for that album.

It doesn't matter if the file that is actually playing is from USB, SDCARD or NAS. The glitch is with a Raspberry B+ and with the Raspberry 2B.

As loading the library (going to the lib page) doesn't cause any glitch, possible the CPU priority of the thumbnail reading process was set a bit too high?

I use UAC2 device with USB audio fix present. Issue is both on XMOS and CM6631A devices.

Anything I can try to help isolate this?
 
Last edited:
Hi folks

I just got a Sense Hat and I was planning to use the lcd display to scroll the name of the song and artist (using a USB DAC, more precisely a FiiO E17). Could anybody give me some hints on how to get in python the name of the song and artist from MPD?

Another thing that I was considering was to also use the 8X8 led matrix to create a low res art image of the album art just for fun, but I guess that would be even more complicated and I don't know if feasible at all.

And the last thing I was thinking to do, if I have some time, is to use the Sense Hat Joystick to control the reproduction.

BR / Fernando
 
Hi

IQAudio DAC+ arrived! So clear it's like the fog has lifted! Thanks for the suggestion Tim.

I've just upgraded to 2.3 and also added a NAS. A couple of thoughts:

1) When updating MPD DB, it is getting stuck on an MP3 and not completing. Removing the file and re-running the update makes it get further until is gets stuck again. I know I must have some bad files, but if this is happening to other people then I wonder if you could make it more robust so it reports the files it skipped rather than getting stuck as it takes ages to find the bad files and rescan.

2) A small idea: when it's doing the MPD Update and scanning the NAS could you make it so if it finds a .pls file it adds it to the Webradio list? Then we can save the stations centrally.

Kind regards
Miles
 
I just got a Sense Hat and I was planning to use the lcd display to scroll the name of the song and artist (using a USB DAC, more precisely a FiiO E17). Could anybody give me some hints on how to get in python the name of the song and artist from MPD?

Hi,

Mr. Takazine developed a python script for displaying mpd music info on an I2C-connected LCD/OLED display.
RaspberryPi + Volumio LCD ???????: new_western_elec

The above article is written in Japanese, but you have translate.google.com or so.

The most essential program is lcd_ctrl.py, which runs as daemon.
This will help you, won't it?

Regards,
yjo
 
Hi,

When I play a file to an USB device (nothing heavy 44.1k/16) and I browse a library which is mostly located on a NAS, every time I click an album, the system tries to get the artwork thumbnail. During that process, there is a short but very noticeable audio glitch, which lasts longer if the system cannot find any artwork for that album.

It doesn't matter if the file that is actually playing is from USB, SDCARD or NAS. The glitch is with a Raspberry B+ and with the Raspberry 2B.

As loading the library (going to the lib page) doesn't cause any glitch, possible the CPU priority of the thumbnail reading process was set a bit too high?

I use UAC2 device with USB audio fix present. Issue is both on XMOS and CM6631A devices.

Anything I can try to help isolate this?

Hi,

Very odd. I don't think CPU is issue.

I ran some stress tests using old Pi-1B and did not get any audio glitches when clicking albums on the Library panel, even when the album art took a bit to display.

Tonight I rerun stress tests using Pi-2B just in case :)

Screen shot shows cpu at 65% utilization w/resampling enabled, no issues.

Test config:

Pi-1B 700 Mhz, 512MB Ram
USB DAC (JDS Labs ODAC)
USB attached HDD
18K tracks in mixed formats
With and without resampling enabled
16/44, 24/96 and radio stations

Regards,
Tim
 

Attachments

  • moode-glitch-test.png
    moode-glitch-test.png
    251.8 KB · Views: 254
Last edited:
Hi

IQAudio DAC+ arrived! So clear it's like the fog has lifted! Thanks for the suggestion Tim.

I've just upgraded to 2.3 and also added a NAS. A couple of thoughts:

1) When updating MPD DB, it is getting stuck on an MP3 and not completing. Removing the file and re-running the update makes it get further until is gets stuck again. I know I must have some bad files, but if this is happening to other people then I wonder if you could make it more robust so it reports the files it skipped rather than getting stuck as it takes ages to find the bad files and rescan.

2) A small idea: when it's doing the MPD Update and scanning the NAS could you make it so if it finds a .pls file it adds it to the Webradio list? Then we can save the stations centrally.

Kind regards
Miles

Hi Miles,

Issue (1)
Zip up a few of the MP3 files and email me a download link. I'll analyze them.

Suggestion (2)
I don't know of a way to configure MPD Database Update to do something with .pls files. The DB Update just runs in the background doing its thing to generate the tag_cache :)

Regards,
Tim
 

Hi,

Thanks for the reference links :)

This is from memory so I might be mistaken but as I recall when I looked at CUE some time ago the challenge was how to make Playlist entries out of the CUE for each of the tracks since MPD did not do this.

I though MPD just made a single Playlist entry for the whole file.

Regards,
Tim
 
Hi,

Thanks for the reference links :)

This is from memory so I might be mistaken but as I recall when I looked at CUE some time ago the challenge was how to make Playlist entries out of the CUE for each of the tracks since MPD did not do this.

I though MPD just made a single Playlist entry for the whole file.

Regards,
Tim

My pleasure.

I'm not sure exactly how MPD handles cue files, but the Cantata app handles them fine. I don't know if you could inspect their code to see how they do it. MPDroid also works well.

The only thing I would improve in their implementations would be to hide the music file and only show the cue file in the folder/file view to make it a bit tidier. If you want to add a whole folder to the playlist it adds the album twice - once from the cue list and once from the audio file.

NB: If I add a cue sheet using Cantata or MPDroid, when I view the playlist in the Moode web view, it shows up perfectly as a list of tracks in that cue sheet!
 
My pleasure.

I'm not sure exactly how MPD handles cue files, but the Cantata app handles them fine. I don't know if you could inspect their code to see how they do it. MPDroid also works well.

The only thing I would improve in their implementations would be to hide the music file and only show the cue file in the folder/file view to make it a bit tidier. If you want to add a whole folder to the playlist it adds the album twice - once from the cue list and once from the audio file.

NB: If I add a cue sheet using Cantata or MPDroid, when I view the playlist in the Moode web view, it shows up perfectly as a list of tracks in that cue sheet!

Hi,

I'm a bit confused How did u get the playlist into Moode?

If u zip up a couple CUE+FLAC's and send me a download link I'll play with them this weekend.

Regards,
Tim
 
Hi,

I'm a bit confused How did u get the playlist into Moode?

If I'm browsing my audio files using Cantata or MPDroid using the Files (MPDroid) or Folder (Cantata) view, I can see a large audio file and a cue sheet file. If I add just the cue sheet it will play fine. If I now view the Playback tab in the Moode web browser, all the tracks on that album will be shown in the playlist.

Does that make better sense?

I'll PM you a link to some test files.
 
If I'm browsing my audio files using Cantata or MPDroid using the Files (MPDroid) or Folder (Cantata) view, I can see a large audio file and a cue sheet file. If I add just the cue sheet it will play fine. If I now view the Playback tab in the Moode web browser, all the tracks on that album will be shown in the playlist.

Does that make better sense?

I'll PM you a link to some test files.

Hi,

Makes sense.

Do the CUE sheets show up at all in the Moode Browse panel?

Tim