Moode Audio Player for Raspberry Pi

Thanks to the aforementioned father, I had to cram a lot of Bluetooth design info (I worked alongside, but not with the Bluetooth team at Intel in Sweden but absorbed only endpoint stuff).

What needs to be understood is that Bluetooth ain't Bluetooth - there are many hardware flavours, just as there are with 802.x, and then each spec of hardware can support various software iterations from simple car control to ultra-HD multichannel audio.

With the right gear, you can get lossless Bluetooth audio at high rates, in multi-channel (5.2) but your average little $20 Chinese BT speaker or headphones aren't running that level of kit. And, as with any network device, both ends need to match to get the best rate. A cheap android phone connected to a B&W Zeppelin won't be able to give it a signal at the best rate the Zep can handle.

As well as having compatible hardware, they also need to have the right codec - and for HD audio that means aptX and CSR - the Pi is equipped with a Broadcom BCM43438... not Cambridge Silicon.

I haven't given any thought to the Pi, mostly because I don't use BT for anything other than casting files from one apple device to another but I will dive in, now I'm a man of leisure.

What I do know is that the aptX codec required for HD and lossless is proprietary and so, just as we used to register those video codecs with the Pi1 & 2, to get high quality audio over BT will need some negotiation, as well as coding, that's if you can even integrate aptX with a Broadcom chip.

You never know, it might be a doddle :)

Yeah, Mike, I purposely chose not to walk anyone through the details. Only time will tell if a basic implementation using the only codec (low-complexity subband codec), aka SBC) will satisfy those who try it.

Frankly, I doubt the audio enthusiasts in the RPi community can generate sufficient market force to get vendors to make their proprietary codecs available to the Raspbian effort, licensed or otherwise. But hey, it wouldn't be the first time I've been wrong.

Regards,
Kent
 
CQ? Can you hear me? :)

My dad was a radio guy - built stations all over the Middle East and Asia, and dragged us with him. I grew up with 'here Mike, hold this' followed by a mega-load of volts - he never tired of shocking me and I never gave up trusting him...

The new ham is incredibly exciting - digital satellite, p2p mesh networks, high-altitude tracking, community radio, etc.

My dad, now in his eighties, is coding like a champ, designing all manner of digital devices - his new loves are the STM32, ESP32 and the uBlox8 which he drags me, kicking and screaming, into his nefarious plans. Picture a cross between Father Christmas and Dr.Evil :)

Mike, that's great. My dad was an electronic engineer by trade but a photography nut by avocation. I had to learn electronics on my own---doing my best to electrocute myself---but he used me as his key grip. "Kent, what's the light level...ok, hand me the Leica...umm, no, better give me the Rolleiflex...."

Oddly, it was only after I got my general-class ticket in my teens and fitted out my radio shack that he got interested in amateur radio. I moved on (ending up in physics, go figure) while he remained an active ham until Parkinson's Disease left him incapable of clear speech or of brass-pounding. For a while I kept him going with PC-based RTTY which morphed into Internet email, but soon enough even that was too difficult.

I keep up with the evolution of amateur radio but other than playing with SDR I haven't dipped my toes back in the water.

From your description, I'm sure your dad and I would get along like gangbusters. I'm only ten laps of the sun behind him and we'd have lots to talk about.

Regards,
Kent
 
After unsuccessfully searching for any mention of library size limitations using moode, I decided to just "go for it" and see what happens. Running Raspberry Pi 3 with an IQAudio Pi-DAC PRO, I have successfully catalogued and am efficiently accessing a library of over 136,000 files. I am using a 2TB Western EasyStore USB 3 drive plugged directly into the USB port on the Raspberry for its power. The system is flawless from both an iFi power supply and my Anker battery with a 2.5A USB output port both to my Macintosh/Velodyne/Kef system and my Sennheiser HD 800's.

This should be considered a recipe for an effortless build with no hitches for those who just want to create a low cost DAC with preamp out and a high quality headphone amp.
 
From a post by Tim when I enquired about lcd screens...
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 Tim, I bought an lcd with i2c backpack to try this script.
Unfortunately it does not work and throws these errors...

Code:
 python lcd.py
Traceback (most recent call last):
  File "lcd.py", line 115, in <module>
    with open('/var/www/currentsong.txt') as in_file: # Didiet
IOError: [Errno 2] No such file or directory: '/var/www/currentsong.txt'

seems strange....but try as I might I can't find what the fix is....
Anyone care to take a look ?

Thanks,

EDIT found the problem...it's /var/local/www/currentsong.txt not /var/www/currentsong.txt
edited the script and it runs...


EDIT 2 ....but doesn't update any info.....:-(

Bob
 
Last edited:
Thank you for your replies.
I understand the audio quality of the BT protocol, I use AirPlay streaming from every device to play music from mobiles and pc, but there are some issue when there's some WiFi congestion. It is also difficult to have Android phone with AirPlay support if not rooted.
What I want to say is that this feature will not be for audiophile, but could be useful to stream something easily from our devices to the RPi/Moode player...
Anyway thank you for your effort on this topic.
 
Thank you for your replies.
...
What I want to say is that this feature will not be for audiophile, but could be useful to stream something easily from our devices to the RPi/Moode player...
Anyway thank you for your effort on this topic.

@badbat75

At least now we have the possibility of seeing a working basic implementation in moOde so folks can decide for themselves if it's useful in their situations.

I've heard there are some driver-free USB-Bluetooth dongles out there which support the aptx codec that @Zootalaws was talking about. They might get us closer to audiophile quality with appropriate speakers/headsets. AFAIK, they are only transmitters, not receivers.

Regards,
Kent
 
After unsuccessfully searching for any mention of library size limitations using moode, I decided to just "go for it" and see what happens. Running Raspberry Pi 3 with an IQAudio Pi-DAC PRO, I have successfully catalogued and am efficiently accessing a library of over 136,000 files. I am using a 2TB Western EasyStore USB 3 drive plugged directly into the USB port on the Raspberry for its power. The system is flawless from both an iFi power supply and my Anker battery with a 2.5A USB output port both to my Macintosh/Velodyne/Kef system and my Sennheiser HD 800's.

This should be considered a recipe for an effortless build with no hitches for those who just want to create a low cost DAC with preamp out and a high quality headphone amp.

Hi,

That might be a record number of tracks. Just remember to use Auto-shuffle for random play instead of trying to add 136K tracks to the Playlist.

Can't go wrong with Macintosh/Velodyne/Kef equipment. One of my favorite speaker systems is a set of vintage KEF Q-60's paired with a good Subwoofer :)

-Tim
 
Consume mode - ?issue.

I turned on the auto-shuffle feature which worked when I get to the end of my play list however I cannot turn it off (specifically the consume feature). If I click the consume arrow to turn it off it comes back on when the song changes even when I add new songs it still goes into consume. It keeps toggling back on. I have done a restart and it is still happening.

Not sure if it is me and my understanding of the function - is this a bug or just the way I have been using it? Easiest fix is probably just to turn it off for now.
 
Hi Jon,

I use Sandisk Ultra Class 10 cards. Only one failure in over three years and my cards get written to constantly every day during development and testing.
Amazon.com: Sandisk Ultra - Flash Memory Card - 32 GB - MicroSDHC UHS-I (SDSQUNC-032G-AN6IA): Computers & Accessories

-Tim

Hi Ken
Unfortunately after installing version 3.8.4 on a new SD card with default kernel works perfectly, but if I insert any of the two special kernels I do not get audio output and the Playback page looks like the attached image, pretty much blocked . While with the same configurations version 3.7 works perfectly with special kernels.
I attach the System Information of the two versions, where the only noticeable difference seems to me: Audio Parameters, Hdwr volume is read in version 3.7 "none" and in version 3.8.4 "Invalid card number".
I would not give up new versions running with Kernel RT and FIFO, which for me represents the highest quality.
Thank you for your time.
Greetings
Jon
 

Attachments

  • Playback.PNG
    Playback.PNG
    27.1 KB · Views: 328
  • S Y S T E M Info 3-7.txt
    5.3 KB · Views: 53
  • S Y S T E M Info 3-8-4.txt
    6.7 KB · Views: 40
Hi Ken
Unfortunately after installing version 3.8.4 on a new SD card with default kernel works perfectly, but if I insert any of the two special kernels I do not get audio output and the Playback page looks like the attached image, pretty much blocked . While with the same configurations version 3.7 works perfectly with special kernels.
I attach the System Information of the two versions, where the only noticeable difference seems to me: Audio Parameters, Hdwr volume is read in version 3.7 "none" and in version 3.8.4 "Invalid card number".
I would not give up new versions running with Kernel RT and FIFO, which for me represents the highest quality.
Thank you for your time.
Greetings
Jon

Hi Jon,

Looks like the "simple-es9023-audio,384k" driver is not present in the 4.9.41 Adv kernels used in moOde 3.8 series. Thats the driver that would be loaded when running Adv kernels and selecting DDDAC1794 NOS for I2S audio device. It was developed by Clive Messer, one of the Linux kernel audio devs who is now since retired. Its possible that the driver no longer works in 4.9.y and thus was left out. I'll have to investigate.

In the mean time, try using the Generic-2 I2S (rpi-dac) selection.

-Tim