Archive for the ‘raspberrypi’ Category

No Comments

Debugging Audio problems on a Raspberry Pi

Sunday, February 21st, 2021

A Raspberry Pi is a great small computer that can run 24 hours with no problem, and just consumes a few watts, so it’s a fine candidate for a modern flexible media player.

The default high quality sound output of a Raspberry Pi is HDMI, which is great for video, but not so great for classic stereo systems. The standard analogue out is near CD quality. Fine for system sounds and video calling, but not enough for HiFi. Remember the Pi is designed as a cheap computer for educational purposes.

HiFi audiophiles probably want to add a dedicated USB-DAC (you lose an USB port) or dedicated HAT like HiFiBerry or IQAudio.

ALSA and PulseAudio soundserver

Then we have the software thing. Raspbian always used Advanced Linux Sound Architecture (ALSA) as the driver and skipped the layer of PulseAudio, which is the default sound server that lays on top of ALSA in modern Debian and Ubuntu desktops.

Since the Pi400 was introduced, and marketed as a serious affordable desktop, the now renamed Raspberry Pi OS, started to offer PulseAudio as well in December 2020. The big win of PulseAudio, better support for Bluetooth and more programs can output sound at the same time. With ALSA output would be locked  by one program: you can’t mix.

Well with a caveat. Raspberry Pi OS with desktop is shipped with PulseAudio, but Raspberry Pi OS Lite is not shipped with PulseAudio, because shipping it with PulseAudio would make it a Raspberry Pi OS Medium. ;(

So Raspberry Pi OS Lite uses just ALSA, Raspberry Pi OS with desktop uses also ALSA, but on top of that the PulseAudio layer.

Debug audio on a Raspberry Pi

Check the hardware, it doesn’t matter in this step if you use PulseAudio or not.

Start with listing all audio outputs:

aplay -l

This should output something like:

**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 2: IQaudIODAC [IQaudIODAC], device 0: IQaudIO DAC HiFi pcm512x-hifi-0 [IQaudIO DAC HiFi pcm512x-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 3: DAC [USB AUDIO DAC], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Here you see the four outputs: HDMI output (0), analogue out (1),  IQAudio HAT  (2), and an USB-DAC (3)

To test your hardware, upload a test.wav file to your Pi (aplay can’t play mp3 files), and try the different outputs.

aplay -D plughw:0 test.wav # HDMI
aplay -D plughw:1 test.wav #headphones/audio out
aplay -D plughw:2 test.wav # iqaudio
aplay -D plughw:3 test.wav # USB DAC

Of course you need to have the outputs properly connected to an amplifier, monitor or headphone. Now you know your hardware is working OK.

Check for a faulty power supply

If you have hisses, or distortion, also always check your Raspberry Pi for throttling and a possible power or heating problem:

vcgencmd get_throttled
throttled=0x0

If you see a different output, that suggests you have a faulty power supply. Phone chargers typically are not stable PSU’s. Better use the official Raspberry Pi power supply. Also the quality of the cable really does matter.

If that is also OK, it’s just about configuring the right output in your software.

Configuring the Music Player Daemon

To set the IQAudio HAT as the default ALSA output in /etc/mpd.conf

audio_output {
type "alsa"
name "IQAudio"
device "hw:2" # set hw:3 for DAC out
}

To set PulseAudio as the default output:

audio_output { type "pulse" 
name "pulse audio" 
}

Do not edit boot/config.txt by default

In general there is no need to edit /boot/config.txt. Official HATS will configure automatically and the same goes for USB-DACS. Plug and play. You see older tutorials or manuals instructing you to edit /boot/config.txt for configuration. IMHO that is only needed in special cases. If you don’t know what you’re doing, don’t edit boot/config.txt.

No Comments

Stop your Raspberry Pi from leaking telemetry to Microsoft

Friday, February 19th, 2021

Visual Studio Code is a highly rewarded and much used code-editor from Microsoft.

Microsoft tells you it’s open source, but when you actually install it on your Raspberry Pi 4 or Raspberry Pi 400 as promoted, it suddenly isn’t open source anymore. The installation binaries come packed with some proprietary stuff, like telemetry and tracking.

There is no real reason for that, Microsoft could absolutely disable telemetry by default and offer it 100% open source, but Microsoft doesn’t do that. The company wants to ride on the popular waves of open source without actually practicing it.

Luckily there is a real open source version of VSCode and that is called VSCodium:
https://github.com/VSCodium/vscodium

Somehow Microsoft has managed to get the Raspberry Pi Foundation to add a Microsoft repository with the non-open source version of VSCode.

So when you even do not want to use a Microsoft product, Microsoft is still getting some info about your usage of your Raspberry Pi. In every update your Pi will check with the servers if there is a update.

If you want to stop the spying and tracking, execute this command on your Raspberry Pi:

sudo sed -i 's/^deb/#deb/g' /etc/apt/sources.list.d/vscode.list

Or when you wanna do that remotely:

ssh yourpi "sudo sed -i 's/^deb/#deb/g' /etc/apt/sources.list.d/vscode.list"

This will comment-out the Microsoft repository, and stop checking / leaking usage data to Microsoft.

To install the real VSCode open source version on your Raspberry Pi 4(00):

Install from repository for Debian/Ubuntu/Linux Mint

Recommended way of install. It will update automatically, and now the Gitlab servers will be pinged and not Microsoft’s. 😉

That’s not much of a gain, but you get a version without telemetry and tracking and without proprietary code, and that is of course a real win.

See:

https://github.com/VSCodium/vscodium#install-with-package-manager

Install as Flatpak

Not the best choice, but you can install it aside a repository version; to check and test the speed and functionality of Flatpak builds.

Chances are high, you get a slightly older build this way.

flatpak install flathub com.vscodium.codium

flatpak run com.vscodium.codium
The 100% open source VSCodium running on a Pi 400

The 100% open source VSCodium running on a Pi 400

 

The main ten million dollar question remains, why doesn’t Microsoft offer a 100% open source version of VSCode in the first place?

It’s like wrapping a nice sustainable vegetable up in non-degradable plastic. We won’t save the planet with that attitude.

No Comments

Fixing HifiBerry and Raspberry Pi sound after update

Friday, June 19th, 2020

I updated my Raspberry Pi 4 which I use for playing music with the great, free and open source MPD server.

After reboot it stopped playing music. ;(

The cause was this update in May/June 2020, due to a change in audio configuration. MPD was still working but the sound was now not routed through the HifiBerry soundcard, but through the audio/headphones, simply because a new HW card was defined: headphones/analog audio out.

The solution was easy.

aplay -l shows the Hifiberry the third card instead of the second, the new headphones was now the second.

 $ aplay -l
**** List of PLAYBACK Hardware Devices **** 
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1] 
Subdevices: 4/4 
Subdevice #0: subdevice #0 
Subdevice #1: subdevice #1 
Subdevice #2: subdevice #2 
Subdevice #3: subdevice #3 
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones] 
Subdevices: 4/4 
Subdevice #0: subdevice #0 
Subdevice #1: subdevice #1 
Subdevice #2: subdevice #2 
Subdevice #3: subdevice #3 
card 2: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
Subdevices: 0/1 
Subdevice #0: subdevice #0

All I had to do is to edit /etc/asound.conf and increase 1 to 2:

pcm.!default {
type hw card 2
}
ctl.!default {
type hw card 2
}

Restart MPD and everything was working like before. 😉

sudo systemctl restart mpd

 

No Comments

Filter thread sizes Raspberry Pi 6mm and 16mm lenses

Sunday, June 7th, 2020

The filter thread size for the Raspberry Pi 6mm CS mount lens is 27mm.

Raspberry Pi 6mm lens with step-up-ring

The filter thread size for the Raspberry Pi 16mm C mount lens is 37mm.

Raspberry Pi 16mm lens with step-up-ring

You can use  these lenses as macro lens by to reverse mounting them on the Raspberry Pi HQ camera.  That works surprisingly good. See my earlier posts.

In short: you need a reverse macro ring adapter and some step up rings. I use a Pentax K-mount adapter and ring, because I have some classic Pentax glass, that can be also used with the Raspberry Pi HQ camera.

 

3 Comments

Macro Photography with the Raspberry Pi HQ camera and reversing the lens

Wednesday, June 3rd, 2020

The Raspberry Pi is a small computer, but it is a great machine for experimenting with all sorts of technology. The Raspberry Pi Foundation just introduced a new High Quality camera with changeable lenses, so let’s find out if that new camera board can be used for photographing small objects.

FruitflyRaspberry Pi HQ Camera

Fruitfly

And I’m gone a use a rather surprising but cheap technique: reversing the lens.

(more…)

No Comments

Ubuntu 20.04 is running great (again) on older hardware

Wednesday, May 20th, 2020

When Ubuntu made the move from Unity to Gnome3, with 18.04, my old su4100 laptop from 2010, did not run the new Gnome3 really well. So I tried out Mate, and in the end Kubuntu.

I was surprised that KDE was much smoother experience than Gnome3 on 18.04. At that moment.

Things improved with Gnome3 with 19.10, but now with 20.04 Ubuntu is running nice again on lower spec hardware.

Still a SSD is much needed, but my old su4100 2 core processor, is delivering a nice and smooth feeling with a fresh Ubuntu 20.04 install.

Great.

That’s why I like Linux. Free, open source, and more sustainable than Apple OS or Microsoft Windows.