Phat Dac | Scroll Phat | pivumeter


#1

My Phat Dac works perfectly, my Scroll Phat also works fine all on the same Pi Zero. I can stream a radio station with mpc and run the examples in the Scroll Phat folder. I’ve tried to get pivumeter to work today and failed miserably - Started with a fresh build and run the scripts for both Phat Dac, Scroll Phat and pivumeter. My sound.conf looks like this post pivumeter install:

pcm.!default {
type plug
slave.pcm {
type meter
slave.pcm "softvol"
scopes.0 pivumeter
}
}

ctl.!default {
type hw
card 0
}

pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave.pcm 'hw:0,0’
slave {
period_time 0
period_size 1024
buffer_size 8192
}
bindings {
0 0
1 1
}
}

ctl.dmixer {
type hw
card 0
}

pcm.softvol {
type softvol
slave.pcm "dmixer"
control {
name "PCM"
card 0
}
}

pcm_scope.pivumeter {
type pivumeter
decay_ms 500
peak_ms 400
brightness 128
output_device scroll-phat
}

pcm_scope_type.pivumeter {
lib /usr/local/lib/libpivumeter.so
}

pcm.pivumeter {
type meter
slave.pcm 'hw:0,0’
scopes.0 pivumeter
}

pcm.dsp0 pivumeter

anyone got any thoughts or pointers ?


#2

I’m not sure if you have tried this, but I got it working by setting the sound output for my software to be the pivumeter. Note, though, that this was using a phat beat - I don’t know if it is the right method to use in your case. Worth a try, though.


#3

try adding the following file directly inside your home folder, as .asoundrc:

pcm.!default {
        type plug
        slave.pcm "pivumeter"
}

ctl.!default {
        type hw
        card 0
}

this does more or less what @MarcJennings said, and is something we’ve put together for pulseaudio, which may help.

Note that you need both the regular asound.conf in /etc and this file in your home folder, neither will work independently from one another.


#4

I’ve added the file above and it works playing a sample wav file but not MPD. So this is down to the MPD config file. The following doesn’t work at all so no audio and no scroll phat:

audio_output {
type "alsa"
name "My ALSA Device"
device “pivumeter” # optional
mixer_type “software” # optional
}

If I change it to:

audio_output {
type "alsa"
name "My ALSA Device"
device “hw:0,0” # optional
mixer_type “software” # optional
}

I get working a working MPD but no Scroll Phat. This is a copy of my asound.conf that I have ‘working’:
pcm.!default {
type plug
slave.pcm {
type meter
slave.pcm "softvol"
scopes.0 pivumeter
}
}

ctl.!default {
type hw
card 0
}

pcm_scope.pivumeter {
type pivumeter
decay_ms 500
peak_ms 400
brightness 128
output_device scroll-phat
}

pcm_scope_type.pivumeter {
lib /usr/local/lib/libpivumeter.so
}

pcm.pivumeter {
type meter
slave.pcm 'hw:0,0’
scopes.0 pivumeter
}
pcm.dsp0 pivumeter

Any Thoughts ?


#5

try

sudo usermod -a -G audio mpd

I had a similar issue with mopidy, the service user had to be a member of the audio group for pivumeter to work.


#6

are you sure you mean the audio group? but yes, that is a good point, any service user has to be added to the i2c group, otherwise the VU will not work.


#7

Thanks for this, so All sorted and for future readers/searchers:

I added mpd into the i2c group:

sudo usermod -a -G i2c mpd

/mpd.conf audio output looks like this:

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "pivumeter"     # optional
        mixer_type      "software"      # optional
}

I created the following .asoundrc :

pcm.!default {
        type plug
        slave.pcm "pivumeter"
}

ctl.!default {
        type hw
        card 0
}

And my /etc/asound.conf looks like this:

pcm.!default {
type plug
slave.pcm {
type meter
slave.pcm "softvol"
scopes.0 pivumeter
}
}

ctl.!default {
type hw
card 0
}

pcm_scope.pivumeter {
type pivumeter
decay_ms 500
peak_ms 400
brightness 128
output_device scroll-phat
}

pcm_scope_type.pivumeter {
lib /usr/local/lib/libpivumeter.so
}

pcm.pivumeter {
type meter
slave.pcm 'hw:0,0'
scopes.0 pivumeter
}

pcm.dsp0 pivumeter

The volume has to be near 80% before it registers so I need to see how to tweak that now!


Pimusicbox on pirate radio
Pi Zero W, Pirate Radio and the PhatBeat
#8

No, you are right, I meant i2c, too many hours spent messing around trying everything under the sun to get it working, i was too impatient to wait for the completed how to articles :)


#9

Hi guys,

I’ve followed all the steps above for my Pirate Radio. I’ve finally got Mopidy working, so I get sound, but pivumeters aren’t working. I’ve checked the above, /etc/asound.conf, groups for mopidy (audio and i2c) but I suspect the root cause is that ALSA doesn’t work with Pulseaudio which is default in Raspbian?


#10

the relevant group for phat BEAT, which is part of the Pirate Radio, is gpio, not i2c. Anyhow the installer should have added the relevant user to the relevant group, but I guess it can’t hurt to check.

… note that pulseaudio is not running by default on Raspbian, it will only be started if a process specifically calls it, which, AFAIK, on a clean install, means if you pair bluetooth audio devices with your Pi.

It is possible to make pivumeter work with pulse though, but if it is running on your system the reason why it is so could prevent us talking you through the required tweaks without knowing more details.

So, first of all, you should check pulse is actually running - it shouldn’t be (unless you added software that fires it up on boot).


#11

Hi all, I would like to add my experience with the pirate radio, bluetooth and pulseaudio. I hope this will help anyone who has similar problems.

I installed bluetooth after having setup the pirate radio with the spotipy tutorial. But I had forgotten that pulseaudio is a dependency of just about every bluetooth stack. So after the next reboot the pivumeter stopped working.

This was caused by the pulse client autospawning a pulseaudio process to handle audio! Which means that the alsa setup for pivumeter won’t work. I thought simply configuring the pulse audio client to not autospawn would solve the problem. But it did not. So I simply reinstalled mopidy/spotipy using the pimaroni spotipy script.

Telling pulse to not autospawn:

vim /etc/pulse/client.conf
#uncomment this line and change yes to no.
autospawn = no

Before reinstalling spotipy make a copy of /etc/mopidy/mopidy.conf so that the original mopidy config exists and can be used to reset settings after reinstalling mopidy.

cp /etc/mopidy/mopidy.conf /etc/mopidy/mopidy.conf.bak

PS: Sorry for resurrecting an old thread, but this thread actually helped me resolve my problem.