How to play audio in docker container on raspberry pi? - linux

I would like to play audio on my raspberry pi, the audio player (console application) should in a docker container. I have seen multiple articles on the web, they commonly suggest to add the --device /dev/snd to the docker run. I just can't seem to get the audio through. Audio should be played on the device that's attached via HDMI cable. I tried sox player, I took ubuntu 18.04 as base image and also this sample solution. I'm flexible with with what the media player application is as this is a hobby project (would be nice that I can "pipe" an mp3 file to the program via bash while it is being streamed from somewhere). On the host I recently installed "Raspberry Pi OS with desktop and recommended software". (Release date is October 30th 2021, Kernel version: 5.10, whatever came with it). Pi 2 model B 1.1 (2014).
UPDATE: Audio does play on 3.5mm jack
It seems that by using the --device /dev/snd option, audio does play on the 3.5mm jack. I don't know though how to make this work on the HDMI.

Related

Pulseeffects unable to see audio source

I am having issues with Pulseeffects on Pi OS Debian Buster. I am using custom distribution called "Volumio" which is special kind of buster that focus on music and listening to music from more sources (bluetooth, airplay, network drives, local music etc.) I also have GPIO sound card connected in there "HiFiBerry DAC2 Pro"
This Volumio OS has its custom alsa configuration which looks like this:
pcm.!default {
type copy
slave.pcm "volumio"
}
pcm.volumio {
type copy
slave.pcm "volumioOutput"
}
# There is always a plug before the hardware to be safe
pcm.volumioOutput {
type plug
slave.pcm "volumioHw"
}
pcm.volumioHw {
type hw
card "sndrpihifiberry"
}
And here my issue starts. When i launch pulseeffects and i play any music from any source, equalization is not working. In pulseeffects there is something called "apps.monitor" which should monitor which apps are playing something and then automatically start sourcing music from there but it doesnt work. In pulseeffects there are also monitors of outputs like jack or HDMI but those are IDLE, not muted, they just dont "see" the music iam playing. Iam so frustrated from this its been several weeks and iam still trying to solve it or get some help but unsuccessfully.
There is one scenario in which music is being equalized and played how it should be, actually two, but its more like bypassing actual problem. In Shairport-sync (package to have airplay playback from apple devices) you can set in its config file that it should send all audio to PA backed (pulseaudio) and if i do that, then its properly sent to pulseeffects, equalized and played.
Another scenario in which iam able to equalize and play music is when i play locally saved files and i edit MPD.conf to send audio locally (127.0.0.1) over RTP stream and i enable RTP listening in pulseeffects, then it gets there, gets equalized and played.
But these two ways are not how it should work normally. It should either recognize any app (shairport, MPD or others) as an APP which plays music and then source that music from it. And if not then at least monitor of standard 3.5 mm jack should work, i could then set Volumio to play everything through 3.5 Jack, in pulseeffects set input to 3.5 Jack monitor and output to my Hifiberry and it would work but both app.monitor and 3.5 jack monitor are acting like iam not playing anything even though i am playing music.
So what am i doing wrong?

camera capture looks different on windows and linux

hey im trying to use a raspberry pi with opencv to prosses some images but while i am capturing the images from the webcam using the same values using windows on my pc and Ubuntu mate on the pi they look very different
linux capture
windows capture
does anyone know why there any difference
It looks like your usb webcam probably has a compatibility problem with the pi (or its drivers in Ubuntu mate).
Try googling the camera model and linux compatibility to see if there are any known tricks to do.
Googling "raspberry pi usb camera compatibility" gives you various lists of known compatible cameras.
In terms of performance (e.g. frame rate) a usb webcam is always worse than the raspberry pi camera attached to the camera serial interface.
To get that working in opencv, you can use this library:
RaspiCam: C++ API for using Raspberry camera with/without OpenCv
www.uco.es/investiga/grupos/ava/node/40

Is a sound device necessary for an audio streaming server?

My project is to stream audio online with my PC as the server.
I have a HP Proliant ML110 G7 server PC, which does not have any integrated sound device in motherboard, nor any kind of sound device.
I am currently using ubuntu 16.04 in my PC, and I cannot configure IceCast and Ices2/Darkice properly, but I could do it following the same instructions in another laptop with same os same version, which has an integrated sound device.
Is an integrated sound device needed to make an audio streaming server?
Thank you.
Icecast itself just passes data on through. It requires no sound device at all.
Your source client, such as IceS, can be used to read audio from a sound device or just to read audio from files. If you have no sound device, you'll need to use some other audio source of course.

UVC function config interface

I'm reading Linux Documentation about UVC function. I'm struggling to understand an example that starts here and goes until here. What exactly is this going to do and where exactly do I create these files?
Any help is appreciated.
From your other posts I gather that you are attempting to implement a UVC gadget with a Xilinx device. Nonetheless, as Linux devices share the same opaque kernel documentation, the procedure is just as error-prone on the Raspberry Pi Zero and other OTG-enabled devices.
What exactly is this going to do
The idea of a UVC gadget is to build something that acts like a webcam. Once completed you could potentially connect that device into a Mac or PC and use it as your video for FaceTime or Skype.
Depending on your goals you could stream synthetic images, a recorded video, or passthrough video from an add-on like a MIPI CSI camera.
where exactly do I create these files?
Here's a great intro to ConfigFS: link. Again it's for Raspberry Pi Zero rather than your Xilinx device, but the same concepts apply.
While gadget-testing.txt is inconveniently curt, if you start off by running:
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
then you can proceed with the steps mkdir functions/uvc.usb0/control/header/h ...
Here is a more detailed post covering various caveats on Raspberry Pi Stack Exchange.

DAC pops on Song Start/Stop in Raspbian

This has been a plaguing issue for the Raspberry Pi install of Raspbian (Debian Wheezy) since it was first built. Talking directly to the Raspberry Pi foundation and the Raspbian team has given me no luck.
The issue itself is that the DAC doesn't initialize until it starts playing a song. It then will turn itself off when done, causing another pop. When using this for a pure music player it is infuriating to say the least, especially when the pop is loud.
I have heard this on VLC, MOCP and MPD. This has been covered in the Pi forums, but no answers are found: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=38&t=8783
I turn to you at Stack Overflow to see if there is a way to solve this issue. My idea is to initialize it at start-up so the pop only happens when it boots up, though I don't know how to control the ALSA to do that.
Hopefully a solution can be found.
Thanks!
I've experienced the same crackling and popping noises on the Raspberry Pi's analog output when using mpd. The problem is also discussed here: https://github.com/raspberrypi/linux/issues/128
Your idea of configuring the audio hardware to be initialized only once at boot time is exactly what I did to solve the problem. It's possible to do this using the PulseAudio sound system, which works as a proxy between the audio hardware and programs that want to output sound. For example, audio players like mpd can be configured to use PulseAudio as audio backend.
PulseAudio has a configuration option (module-suspend-on-idle) that configures audio hardware sleep. Disabling audio hardware sleep fixed all crackling and popping noises for me.
I've outlined the necessary steps in closer detail on my blog: http://dbader.org/blog/crackle-free-audio-on-the-raspberry-pi-with-mpd-and-pulseaudio
I have the same problem and resolution is to use either USB audio or HDMI audio output (however converting hdmi audio to analog audio is not easy, converter >40$). It is caused by broadcom firmware. They were saying on rpi forum that it is on the list, but no one knows when it will be really fixed ...
Update: I have tried Creative Play! USB audio, it is the same, however the "click" is not that loud. So it is not 100% solution, we have to wait for the fix.
By using the Aureon Dual USB sound card I got zero popping from my raspi. Before I had popping at every song.
I have read that using the Aureon is impossible without limiting the usb ports to version 1.1, but this was not the case for me. It worked out of the box. One slight problem remains, I cannot insert the sound card when the raspi is on, it will reboot. But that's not a problem for me, I never remove the sound card.
My raspi runs raspbian wheezy and plays music via mpd and an nfs share.

Resources