Pirate Radio and loud click when change station on the VLC

Yeah, I ended up deleting it as I’ve got OpenVPN and pihole running on there (and some other automating things too) so no point in wasting CPU just to avoid popping… shame really.

I’m still holding out hope that there’s a lower level way to run the i2s clock- since that’s all “playing silence” really does, because if the data line does nothing then it’s clocking out a constant stream of zeros- ie: mid level silence on the speaker.

If I can get control of the i2s clock away from the audio stack, since it’s a bit of self-contained hardware on the BCM chip, then it should be able to run, non-stop, without using any system resources whatsoever.

1 Like

Followed everything here, https://gist.github.com/Gadgetoid/3301cec3e47495e75b31d3120d8f17d9 must have made a typo someplace, if anything its worse. Many many loud pops on startup now. There was only the one before. And it still pops when changing channels/stations. Has any of this been rolled into the one time installer? I ask because I’m about to start all over from scratch with Raspbian Jessie.

Yes, you can reset your pulse audio configuration by running:

sudo apt purge pulseaudio
sudo rm /etc/pulse/client.conf
sudo systemctl disable pulseaudio
sudo rm /etc/systemd/system/pulseaudio.service

Then run: curl get.pimoroni.com/pulseaudio | bash

I’ve just finished this OLI, so it’s a little experimental, but wont do anything untoward.

Your the man, thanks for that. Will give it a go latter on today. =)

I’m getting a cannot remove /etc/systemd/system/pulseaudio.service no such file or directory?

I also cannot find the pipe | symbol on my keyboard when booting to command line. I have to startx and open a terminal window. Once I do that all my keys match the physical keys on the keyboard. At the command line a lot of them are out of position.

Hi gadgetoid,
can you please explain what this script “curl get.pimoroni.com/pulseaudio | bash” is actually doing ? Installing pulseaudio ? It is a very complex script, why do you need to use so many instructions to install pulseaudio? I would like to understand the details of what it is doing. Does t work with Raspbian Stretch? Please advise.
Thanks

The size is due to the fact it’s built with tooling that handles many different scenarios, edge cases, errors, etc. It’s a lot of boilerplate.

It basically just does this: https://gist.github.com/Gadgetoid/3301cec3e47495e75b31d3120d8f17d9

Hi,
I’d like to share my recent experience with the great Pir8Radio! (That’s its DNS name in my WiFi at home!).
Now I have an almost hi-fi internet radio, here’s what I did:

  1. Replaced the 5W speaker with a 10W one, mechanically and electronically identical (still 4ohms)

  2. After running the “vlcradio” script, I’ve reverted the PulseAudio configuration to its default one: per-user daemon, auto-started as needed. One change still needed is the “load-module module-alsa-sink device=pivumeter” in /etc/pulse/default.pa.

  3. The /etc/asound.conf ALSA config script is untouched after “vlcradio” install.

  4. In /usr/bin/vlcd, I’ve removed all audio filters (gain and normalize) and their parameters.

  5. Another update to PulseAudio config: in /etc/pulse/daemon.conf, add “resample-method = trivial”

Former “vlcradio” script versions didn’t install PulseAudio at all, hence the loud clicks at station change. Nowadays, “vlcradio” also installs PulseAudio but, as a matter of fact, under Jessie you get PulseAudio 5.0, while they’re at 11.1 version nowadays!
But while this version of PA is actually able to remove the load clicks at station/track change, it complains about the “system” behavior not being properly configured, then it sucks too much CPU (24-30%) and, finally, its audio quality also… sucks! It just reminds me of those crappy audio cassettes, back in the '80s! So it has to be with some sort of audio band limitation, hence the “trivial” audio resample method, and the return to PulseAudio’s default, per-user behavior.
Now my Pirate Radio runs 65% idle (25% VLC, 8% PA) while streaming music in nice to hear audio quality!
Now I’ve built a clock for it, with a cheap little (128x32) OLED monochromatic display attached via I2C to the same pins on the PHAT BEAT; my little easy digital_clock.py software sits on top of the great luma library!
Then I would like to add some back covering, maybe with wood, to further enhance its audio quality; but a new, superb, HiFi 3" 15W 4ohms speaker is already on its way, so I’ll post again after I’ve tried that also!
I would also add the capability to show track/station name on another little OLED display, but here, as it seems to me, VLC is lacking some parsing functionality, as in the “status” message, the station name never gets passed back, you only get the URL…

1 Like

Ah, sorry as I’ve forgot to mention another software update I always do on the vlcradio, as I don’t happen to like at all the idea of a full shutdown with the touch of a button, since then you need to detach the power cable and put it back in, as there’s no “on-off” switch on the PI nor on PhatB.
So in /usr/bin/phatbeatd, almost towards the end, where key functions are defined, I just make the “PowerOff” identical to the “Play/Pause” switch.
This way, I get an always-on, always-ready-to-play Pirate Radio, with one big disadvantage: at some point, the VU meter just shuts completely off, and a reboot is needed to get it up going again.
But both the shutdown/power-on and reboot routes always pass through that one loud click still remaining, when PulseAudio starts!

And, while speaking of he “VU meter”, I’m also a big fan of real VU Meters, which meter the INPUT, not the OUTPUT of the amplifier! pivumeter, on the other hand, happen to go up with amplifier volume, so when listening at quiet volume you get a small green and almost static visualization!
To make it more dynamic, I put “decay_ms 50” and “peak_ms 100” in the pcm_scope.pivumeter section, in lieu of the much higher default values.
But the root cause stays untouched at all: pivumeter has to measure the INPUT signal!

Hi gadgetoid,
I’ve been able to download and compile PulseAudio 10.0 on Jessie, from sources. Then only tricky part was the need to also download, build and install libsndfile before you can proceed compiling PA!
I’ve chosen the 10.0 version because it’s been released while Raspbian was in Jessie, while 11.0 and 11.1 have been released when Raspbian released Stretch, so I didn’t experiment at all with these.
At first, I thought that the advantages in sound quality and CPU usage were attributable to the 10.0 version but then I’ve discovered that I was still running 5.0 version of PA! (the one you compile gets installed in /usr/local/bin, by default, instead of /usr/bin).
So, after all, I don’t recommend upgrading PulseAudio, as it turns out: the 5.0 sounds good, with the config changes I’ve explained above.

This morning, I’ve just discovered another couple of bugs on my setup: at reboot or power-on, you get VLC at 100% volume with… PhatBeat buttons disabled!!! So rush to the PC and grab the VLC URL and put it down again!
It turned out to be rc.d-related: both phatbeatd and vlcd are started at runlevel 2, so you get S02phatbeatd BEFORE S02vlcd in /etc/rc3.d (and /etc/rc5.d) alphabetically!
I’ve amended phatbeatd to only start at level 3, but the real fix which worked for me was increasing the sleep(1) to sleep(3) in the start function of /usr/bin/phatbeatd, so phatbeatd is really sure it’s going to find a vlcd daemon running when it tries to connect.
Anyway, my boot process takes 30 seconds as a whole, so 3 seconds * 10 tries in phatbeatd sound OK to me (I only boot in text-console auto-login mode).
Now I’m a bit puzzled on why /usr/bin/vlcd seems to have a mechanism to recover a “preferred” ALSA gain, but I happen to never get the same volume I had prior to reboot!

This is some really good feedback- thanks! I will look at incorporating some of these changes- specially regarding Pulse Audio audio quality and CPU usage- into my ready-to-roll PirateRadio version of PiratePython. I’ve been meaning to bolt PulseAudio onto it (it’s tricky, and actually building it from source isn’t going to make it any trickier so I might as well build the latest and greatest if it’ll work).

Pi VU Meter is a tricky one- since it’s a plugin to the ALSA stack, and ALSA is the audio sink, there’s no opportunity to access the unamplified audio. I’ve been meaning to add some method of correcting for higher volume, or perhaps a moving average ceiling so that the VU meter is always responsive across its full range, irrespective of volume.

More perplexingly, even if the volume is adjusted within the ALSA stack, and even if the softvol plugin is placed after Pi VU Meter in the chain as detailed in asound.conf the volume will affect the VU Meter. The way it works is- odd!

I wonder if - for the purpose of Pirate Radio - I could write a VLC Plugin to drive the VU Meter? It seems VLC is built mostly out of plugins anyway. It’s something to investigate.