Pi Zero W, Pirate Radio and the PhatBeat

Is there anyway to change the gain (hope thats the correct audio term!) of the vu meters, so I can have great looking vu meters on a low volume ?

1 Like

Right now, no, but I believe @gadgetoid is planning to add a parameter that can be specified in the asound to scale the VU in different ways.

That would be great - the Pirate Radio needs this, shame to waste the Phat Beat on low volume with no visuals !

Not sure if this is useful to anyone, but I made this script for running with Mopidy. Or presumably any mpd?

Basically binds the controls on start up, and loads a default playlist which can be cycled through.

Theres the beginnings of an abstraction for animating the VU meter, but the concerns are a bit mixed up at the moment.

VU doesn’t work for playback, but I assume this has something to do with the fact that I’m streaming? Certainly unrelated to this script.

1 Like

Keep an eye out on Twitter in the next few days… I believe @sandyjmacdonald is brewing a tutorial for the Spotidy (Mopidy with Iris front-end) script we promised a little while ago!

… as for your issue, have you added the mopidy user (or mpd user?) to the gpio group, @wwqrd ?

Go Look here - I think I got the solution for mpd/c ?
http://forums.pimoroni.com/t/phat-dac-scroll-phat-pivumeter/4257/7

right… but it is worth noting that while Scoll pHAT (and Speaker pHAT) is being driven over I2C, pHAT Beat is driven over a SPI-like interfacing, so the relevant group is gpio, not i2c.

… still the principle is correct, any particular service running under a dedicated user would need ad hoc permissions to take control of the interface used to drive the chip.

I added the mopidy user to the gpio group to no avail.

When I play a sound with aplay the vu meter works fine, and I’ve set up mopidy to use alsa, so a mystery?

without looking at your project in detail it is hard to tell what could be wrong - but if aplay works fine it is almost certain to have to do with the user context.

Note that above post specifically was resolved by adding user mpd to group gpio, not user mopidy. Whichever is right (including, possibly another suspect) will depend on your use case.

Hi again,

I tried mopidy as suggested above by @gadgetoid (following the tutorial by @sandyjmacdonald on mopidy + spotify, i.e. spotipy script). I have managed to get mpd running and configured on a zero before (with phat dac), but am not able to get mopidy going… it seems.

None of my mpd clients (MPdroid on Android, Ario on Linux nor MPoD on iOS) recognise the mopidy mpd extension. I can find no other way to start mopidy and load my playlist. The playlist only contains internet radio streams so it is relatively short. I plan to use the zero (non-W) + phat beat to stream internet radio in the garage, no local music access (nor spotify) is needed.

Mopidy conf output below:

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
max_tracklist_length = 10000
restore_state = false

[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
debug_file = /var/log/mopidy/mopidy-debug.log
config_file = /etc/mopidy/logging.conf

[audio]
mixer = software
mixer_volume = 35
output = autoaudiosink
buffer_time = 

[proxy]
scheme = 
hostname = 
port = 
username = 
password = 

[iris]
enabled = true
pusherport = 6681
country = NZ
locale = en_NZ

[local-images]
enabled = true
library = json
base_uri = /images/
image_dir = 
album_art_files = 
  *.jpg
  *.jpeg
  *.png

[ttsgpio]
enabled = true
debug_gpio_simulate = false
pin_button_main = 6
pin_button_next = 5
pin_button_previous = 13
pin_button_vol_up = 16
pin_button_vol_down = 26
pin_play_led = 20
tts_default_volume = 2

[local-sqlite]
enabled = true
directories = 
  Albums                  local:directory?type=album
  Artists                 local:directory?type=artist
  Composers               local:directory?type=artist&role=composer
  Genres                  local:directory?type=genre
  Performers              local:directory?type=artist&role=performer
  Release Years           local:directory?type=date&format=%25Y
  Tracks                  local:directory?type=track
  Last Week's Updates     local:directory?max-age=604800
  Last Month's Updates    local:directory?max-age=2592000
timeout = 10
use_album_mbid_uri = true
use_artist_mbid_uri = false
use_artist_sortname = false

[mpd]
enabled = true
hostname = 127.0.0.1
port = 6600
password = 
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist = 
  listall
  listallinfo
default_playlist_scheme = m3u

[http]
enabled = true
hostname = ::
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname

[stream]
enabled = true
protocols = 
  http
  https
  mms
  rtmp
  rtmps
  rtsp
metadata_blacklist = 
timeout = 5000

[m3u]
enabled = true
base_dir =
default_encoding = latin-1
default_extension = .m3u8
playlists_dir = /var/lib/mopidy/playlists

[softwaremixer]
enabled = true

[file]
enabled = true
media_dirs = 
  $XDG_MUSIC_DIR|Music
  ~/|Home
excluded_file_extensions = 
  .jpg
  .jpeg
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000

[local]
enabled = true
library = json
media_dir = /var/lib/mopidy/media
scan_timeout = 1000
scan_flush_threshold = 100
scan_follow_symlinks = false
excluded_file_extensions = 
  .directory
  .html
  .jpeg
  .jpg
  .log
  .nfo
  .png
  .txt

[alsamixer]
enabled = true
card = 0
control = PCM

[spotify]
enabled = true
username = martin@nidingen.com
password = ********
bitrate = 160
volume_normalization = true
private_session = false
timeout = 10
allow_cache = true
allow_network = true
allow_playlists = true
search_album_count = 20
search_artist_count = 10
search_track_count = 50
toplist_countries =

As far as I can tell, my /etc/mopidy/mopidy.conf and local conf file are the same (although the local one was not configured properly using the install script).

In fact, I cannot get Iris to connect either… which is strange, mopidy is running, which “top” also verifies (it really should it starts on reboot, enabled via systemctl).

Any tips?

Edit: realised there is a test.sh for the phat beat. The output is here:

testing audio

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
ALSA lib pcm_direct.c:1539:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
Playback open error: -2,Filen eller katalogen finns inte

testing basic wav playback

ALSA lib pcm_direct.c:1539:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
aplay: main:722: audio open error: Filen eller katalogen finns inte

testing gpio control...
press all buttons along the side of the pHAT...
press the power button on the pHAT to exit...

testing VU meter

Seems there is something wrong, but can’t figure out what (I did not go the vlc route, but the spotipy installer ran through w/o errors). The VU meter seems to work fine, half of the leds are green, other half red (until I terminated script).

if the modipy server is running then the (audio) test cannot run. You must disable it using sudo systemctl disable mopidy (just stopping the service is not enough, IIRC). This will only tell you whether your soldering job is good though.

I see at least one error in your config:

hostname = 127.0.0.1

… try hostname = :: instead

if you cannot get Iris to log you into the spotify frontend though there is probably something else going on.

One point though, you say that the ‘local config file’ is the same… if you are talking about what is generated by mopidy config then no, it wouldn’t be, but it has zero relevance in a server context, which is why it does not exist out of the box after running our installer (which provides an ‘always on’ server).

So if you generated one, by running the command above, then know that editing it will never have any effect (unless you disable the mopidy service as per command in my opening paragraph, and start mopidy manually - which will then be ran as pi, or whatever user you are logged as).

I hope that clarifies how things work (or at least my understanding, from hours of fiddling around with it, as well as reading the doc).

one way to debug your problem btw, is to ssh into the box and check the output of:

sudo service mopidy status
… it usually logs any important issues inline.

If that does not reveal anything bizarre then check the log at /var/log/mopidy/mopidy-debug.log which should hopefully have more details that may help you figure out why you are not able to connect the way you expect (using Iris on port 6680, or a mpd client on port 6600 presumably)

About the ip adress in config, I consulted the Mopidy docs before leaving it at the default value:

mpd/hostname
Which address the MPD server should bind to.

127.0.0.1
Listens only on the IPv4 loopback interface

I understood that leaving the adress at 127.0.0.1 would leav all IPv4 adresses open. I might have misunderstood, will definitely try ::.

Regarding “mopidy conf” I understood at first it was a config editing utility. Turned out it was not… but I never realized it created the local config files, although I did wonder why they would be there in the first place.

I did run the status check and this came out:

sudo service mopidy status
● mopidy.service - Mopidy music server
   Loaded: loaded (/lib/systemd/system/mopidy.service; enabled)
   Active: active (running) since ons 2017-03-29 14:39:21 UTC; 2h 25min ago
 Main PID: 949 (mopidy)
   CGroup: /system.slice/mopidy.service
           └─949 /usr/bin/python /usr/bin/mopidy --config /usr/share/mopidy/c...

mar 29 14:39:58 guderian mopidy[949]: INFO     Loaded 0 local tracks using json
mar 29 14:39:59 guderian mopidy[949]: INFO     Starting Mopidy core
mar 29 14:40:00 guderian mopidy[949]: INFO     Logged in to Spotify in offl...de
mar 29 14:40:03 guderian mopidy[949]: INFO     Logged in to Spotify in onli...de
mar 29 14:40:31 guderian mopidy[949]: INFO     Starting Mopidy frontends: I...nd
mar 29 14:40:31 guderian mopidy[949]: INFO     Starting Iris 2.13.7
mar 29 14:40:36 guderian mopidy[949]: INFO     MPD server running at [::fff...00
mar 29 14:40:36 guderian mopidy[949]: INFO     Starting GLib mainloop
mar 29 14:40:36 guderian mopidy[949]: INFO     HTTP server running at [::]:6680
mar 29 15:07:24 guderian mopidy[949]: sh: 1: festival: not found
Hint: Some lines were ellipsized, use -l to show in full.

i’ll check the debug log as well.

As always, super thanks for all help!

Edit:

Updating to :: (from 127.0.0.1) AND uncommenting a few things in mopdiy.conf solved part of the trick. Iris not connects. And Ario seems too (MPoD might be, but is not very communicative so hard to know given the stuff I describe below).

But, my playlists in /var/lib/mopidy/playslists/ do not show up in any client… so although I can now connect to mopidy I cannot play my radio station list, rendering that success pretty much useless (for the time being).

Thanks again.

A post was split to a new topic: Pirate radio crashing after 2 minutes

So, question: I’ve run the airdac installer but buttons on phatbeat aren’t working


I’ve run test.sh and buttons are recognised, but there’s no phatbeatd service running and sudo service phatbeatd start throws up a ‘Failed to start / No such file’ error … help?

you are confusing 2 different scripts, airdac is a shairport-sync airplay daemon, it has no vocation to provide button support since you will be controlling playback from your phone or tablet.

phatbeatd is a custom daemon specifically for the vlcradio project found in the phat-beat github repo, see instructions there.

… technically both daemons could coexist though, so in theory it should be posssible to have both running at the same time, doing their job. Still they don’t aim to provide the same functionality.

OK, thanks - so I could write my own script to look out for the power button being pressed (only interested in being able to cause a safe shutdown)?

what are you trying to do? if you only want soft shutdown try:

curl get.pimoroni.com/cleanshutdown | bash

the pin to use is bcm12 so when prompted, type ‘12’.

1 Like

Exactly what I was after, thanks!

Hello! I’ve got my pirate radio up and running with VLC, but I can’t seem to add my own radio stations.

I tried creating the playlist.m3u file in /home/pi/.config/vlc/, and the new station showed up for a moment (on the web interface) and then disappeared when I tried to play it.

Then I tried adding my station to the default.m3u file, and it didn’t show up. I also tried copying the default stations to my playlist.m3u file and adding my new one. The new one showed up but then disappeared when I tried to play it. The default ones work just fine.

What should I try next? Any ideas would be appreciated.