Moode Audio Player for Raspberry Pi

Hi, Remy.

Don't you hate when something doesn't click until after you press "send"?

My code can be greatly simplified with a simple change. Instead of defining 10 variables P1 - P10, define just one, let's say "CHANNEL". When testing the state of the buttons, set CHANNEL to zero or null at the start, then set it equal to the number of the button pressed, P1=1, P2=2, etc., if one is found.

Then my long if/elif chain collapses to just
Code:
if CHANNEL: 
	subprocess.call(['mpc','clear'])
	subprocess.call(['mpc','load','FavoriteStations'])
	subprocess.call(['mpc','play',str(CHANNEL)])

This is invariant with respect to the number channels:)
Regards,
Kent
 
Last edited:
Kent, thanks for this information.

I decided to try this with my RPi 2B - I used a 1Gb SD Card from an old mobile phone and copied the "bootcode.bin" file to it. Then I imaged my Moode 3.8.3 SD Card to a file, then burned that file to a cheap Emtec 8G USB Flash drive. And it worked!

However my impression was that SQ suffered. I am not surprised by this, as I understand that in the RPi, the USB buss and the Ethernet buss are shared.
So I will continue to boot from the SD Card. I would rather enjoy better SQ, and replace the SD Card if it ever fails.

Rob

Hi, Rob.

I'm not surprised either.

There are other SBCs which don't have this issue, and I've used a number of them in other projects, but they aren't nearly as well supported as the RPi, both with software and with hardware hats/capes/etc. Volumio 2 has been ported to some of them but, even with a much larger software-support team, most of their ports are behind the curve because of the work involved. I'm happy to live with the relatively few limitations of the RPi in order to use moOde Player :up:.

Regards,
Kent
 
The welcome message will appear when everything correct in your LCDd.conf

Change to anything you like.

All installed as per your instructions, thanks!

The display is on and reads "Welcome to your media centre"

Which is all well and good only I don't have any tracks called 'Welcome to your media centre' in my collection...;)

There must be some more steps to integrate it into Moode and have it display the currently playing track and artist.....:confused:

Anyone ?
 
Hi Bob,

In System config turn ON Metadata file (/var/local/www/currentsong.txt) and LCD update engine.

Look in the home directory and you will see a file named lcd.txt. This file gets created by default by the LCD update engine if nothing is specified for the path to Python script. It gets updated whenever song metadata or volume changes. This is to demonstrate what the LCD update engine provides which is an event loop that runs a command or script when song metadata or volume changes. By default it simply copies /var/local/www/currentsong.txt to /home/pi/lcd.txt

pi@rp3:~ $ cat ./lcd.txt
file=http://aac-64.streamthejazzgroove.com:80/stream
artist=Radio station
album=The Jazz Groove
title=Gene Ammons - Skylark
coverurl=images/radio-logos/The Jazz Groove.png
track=
date=
composer=
encoded=VBR
bitrate=64 kbps
volume=20
mute=0
state=play
pi@rp3:~ $

To use LCD update engine, write a Python script that parses /var/local/www/currentsong.txt file and then writes the desired data to the LCD. Specify the path to the Python script in System config, LCD update engine.

-Tim
 
Last edited:
To use LCD update engine, write a Python script that parses /var/local/www/currentsong.txt file and then writes the desired data to the LCD.

Tim, I'm ok following instructions but a complete coding illiterate...:D
I understand the concept you outlined, I've got the hardware running, everything switched on in Moode but writing a script...wouldn't know where to start..:eek:

Hopefully some kind soul can post theirs for a 16x2 lcd display for me to try.

Once I have the display working (and having now got a remote working...thanks!) I can build the household a simple 'turn it on select a station' radio for those even less tech literate than I to use..:)
 
Hi Bob,

Heres a script that a user sent me a while back. It could be useful as a template.

Code:
#!/usr/bin/python
#--------------------------------------
#    ___  ___  _ ____
#   / _ \/ _ \(_) __/__  __ __
#  / , _/ ___/ /\ \/ _ \/ // /
# /_/|_/_/  /_/___/ .__/\_, /
#                /_/   /___/
#
#  lcd_i2c.py
#  LCD test script using I2C backpack.
#  Supports 16x2 and 20x4 screens.
#
# Author : Matt Hawkins
# Date   : 20/09/2015
#
# [url=http://www.raspberrypi-spy.co.uk/]Raspberry Pi Spy — Unofficial Raspberry Pi tutorials, guides, scripts, help and news[/url]
#
# Copyright 2015 Matt Hawkins
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#--------------------------------------
import smbus
import time

# Define some device parameters
I2C_ADDR  = 0x27 # I2C device address
LCD_WIDTH = 16   # Maximum characters per line

# Define some device constants
LCD_CHR = 1 # Mode - Sending data
LCD_CMD = 0 # Mode - Sending command

LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line
LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line

LCD_BACKLIGHT  = 0x08  # On
#LCD_BACKLIGHT = 0x00  # Off

ENABLE = 0b00000100 # Enable bit

# Timing constants
E_PULSE = 0.0005
E_DELAY = 0.0005

#Open I2C interface
#bus = smbus.SMBus(0)  # Rev 1 Pi uses 0
bus = smbus.SMBus(1) # Rev 2 Pi uses 1

def lcd_init():
  # Initialise display
  lcd_byte(0x33,LCD_CMD) # 110011 Initialise
  lcd_byte(0x32,LCD_CMD) # 110010 Initialise
  lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction
  lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off 
  lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size
  lcd_byte(0x01,LCD_CMD) # 000001 Clear display
  time.sleep(E_DELAY)

def lcd_byte(bits, mode):
  # Send byte to data pins
  # bits = the data
  # mode = 1 for data
  #        0 for command

  bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT
  bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT

  # High bits
  bus.write_byte(I2C_ADDR, bits_high)
  lcd_toggle_enable(bits_high)

  # Low bits
  bus.write_byte(I2C_ADDR, bits_low)
  lcd_toggle_enable(bits_low)

def lcd_toggle_enable(bits):
  # Toggle enable
  time.sleep(E_DELAY)
  bus.write_byte(I2C_ADDR, (bits | ENABLE))
  time.sleep(E_PULSE)
  bus.write_byte(I2C_ADDR,(bits & ~ENABLE))
  time.sleep(E_DELAY)

def lcd_string(message,line):
  # Send string to display

  message = message.ljust(LCD_WIDTH," ")

  lcd_byte(line, LCD_CMD)

  for i in range(LCD_WIDTH):
    lcd_byte(ord(message[i]),LCD_CHR)

def main():
  # Main program block

  # Initialise display
  lcd_init()

lines = [] # Didiet
with open('/var/www/currentsong.txt') as in_file: # Didiet
for line in in_file: # Didiet
lines.append(line) # Didiet
# Send some test
#lcd_string("RPiSpy         <",LCD_LINE_1)
#lcd_string("I2C LCD        <",LCD_LINE_2)
lines[1]=lines[1].replace("artist=","") 
lines[2]=lines[2].replace("album=","")  
lines[3]=lines[3].replace("title=","")  

lcd_string(lines[1] ,LCD_LINE_1)
lcd_string(lines[3],LCD_LINE_2)
time.sleep(3)
  
# Send some more text

lcd_string(lines[1],LCD_LINE_1)
lcd_string(lines[2],LCD_LINE_2)
time.sleep(3)

#if __name__ == '__main__':

#  try:
#    main()
#  except KeyboardInterrupt:
#    pass
#  finally:
#    lcd_byte(0x01, LCD_CMD)

-Tim
 
Hi, Remy.

Don't you hate when something doesn't click until after you press "send"?

My code can be greatly simplified with a simple change. Instead of defining 10 variables P1 - P10, define just one, let's say "CHANNEL". When testing the state of the buttons, set CHANNEL to zero or null at the start, then set it equal to the number of the button pressed, P1=1, P2=2, etc., if one is found.

Then my long if/elif chain collapses to just
Code:
if CHANNEL: 
	subprocess.call(['mpc','clear'])
	subprocess.call(['mpc','load','FavoriteStations'])
	subprocess.call(['mpc','play',str(CHANNEL)])

This is invariant with respect to the number channels:)
Regards,
Kent

Thanks Kent. I am planning to use 10 buttons to store radio stations and music playlists. I now have a better understanding how the subprocess syntax works. I will try this tomorrow after work and will give you a feed back. Thanks a lot.

Remy
 
Hi, Rob.

I'm not surprised either.

There are other SBCs which don't have this issue, and I've used a number of them in other projects, but they aren't nearly as well supported as the RPi, both with software and with hardware hats/capes/etc. Volumio 2 has been ported to some of them but, even with a much larger software-support team, most of their ports are behind the curve because of the work involved. I'm happy to live with the relatively few limitations of the RPi in order to use moOde Player :up:.

Regards,
Kent

Kent,

I have also found that sourcing music files from a USB Flash drive results in hit to SQ. So I tried sourcing my files from a NAS, as was pleasantly surprised by the improved SQ - I assume for the same reasons as I previously stated - a shared USB and Ethernet buss. So I try to avoid USB.

Given that the humble RPi was designed for educational use, I am very pleased with the SQ achieved. My setup uses an IQAudio PiDAC Pro, Moode 3.8.3, the RT Kernel, Performance, RR, SoX: 32/384, Very High Quality - and powered by an Uptone LPS-1. For me this setup narrows the gap with HQPlayer streaming to the uRendu (NAA). And when I hear about the IsolatorPI board and other projects by IanCanada, there is more to be had from the humble RPi.

Rob
 
@ mhouston yes xmos works fine here..:)

for no output go...Moode>configure>Audio>MPD options>Audio output and select USB audio device. >APPLY

If you have output but glitching then Moode>configure>System and toggle the Uac2 fix to on. >SET

Reboot in each case.
 
Last edited:
I ordered Kali reclocker and i would like to use it with Pi3 and Buffalo II DAC.

Pi3-Kali-i2s-Buffalo II DAC with ifi power supply for PI3 and super teddy reg based power supply for Kali.

What I2s device should i choose in Moode 3.83 ?

Do i need some special settings, when i want to connect Buffalo II to Kali ? "simple-bclk-64fs" ?
 
Not sure what happened there..but @Tim.

I noticed that on the 7th August in another forum Allo stated that they had submitted an updated Digi One driver to Raspbian. Are you in contact with Allo, I am sure that it would be in their interest that you are, can you find out if the latest driver is in Moode 3.8?

I don't want to join the other forum.

FYI The reason I am asking is that I am seeing occasional brief dropouts in playback. While I haven't yet ruled out the network yet, it its the same WIRED network I have been using for the last year with a HiFiberry Digi + with no issues (so no network troubleshooting tips please guys). Google finds some comments about this behaviour with Max2play and I think Volumio, or at least some reference to dac syncs.

I have tried all three kernels with Real Time being the best for stable play.

I will try some local playback files to rule out the network but I am interested to know what driver version I have.


Should have posted earlier but the newer driver for the Allo seemed to have fixed my issues, now running LL with TS with no problems.

Not played with the other settings yet, thought I might just actually listen to music for a bit, not sure about Qobuz's definition of a good cover in their covers playlist though. :)
 
I ordered Kali reclocker and i would like to use it with Pi3 and Buffalo II DAC.

Pi3-Kali-i2s-Buffalo II DAC with ifi power supply for PI3 and super teddy reg based power supply for Kali.

What I2s device should i choose in Moode 3.83 ?

Do i need some special settings, when i want to connect Buffalo II to Kali ? "simple-bclk-64fs" ?

Hi,

First I would try the Buffalo II/IIIse selection in the I2S driver list. If that does not work then try one of the Generic I2S drivers.

Btw, if you use standard wires instead of U.FL shielded micro-coax cables for the I2S interconnect there is 99% chance that the wires will pick up EMI and the result will be audio glitches.

-Tim