PeppyMeter

Thanks Phofman ans thanks "rpi"

You can specify two audio output sections in the mpd.conf: one for DAC and one for the peppyalsa.

That's what I have done:

pi@moOde-Sala-Hobby:~/peppyalsa/src $ cat /etc/mpd.conf
#########################################
# This file is automatically generated
# by the MPD configuration page.
#########################################

music_directory "/var/lib/mpd/music"
playlist_directory "/var/lib/mpd/playlists"
db_file "/var/lib/mpd/database"
log_file "/var/log/mpd/log"
pid_file "/var/run/mpd/pid"
state_file "/var/lib/mpd/state"
sticker_file "/var/lib/mpd/sticker.sql"
user "mpd"
group "audio"
bind_to_address "any"
port "6600"
log_level "verbose"
restore_paused "yes"
auto_update "no"
follow_outside_symlinks "yes"
follow_inside_symlinks "yes"
zeroconf_enabled "no"
zeroconf_name "Moode MPD"
filesystem_charset "UTF-8"
metadata_to_use "+comment"
replaygain "off"
replaygain_preamp "0"
volume_normalization "no"
audio_buffer_size "4096"
max_output_buffer_size "131072"
max_playlist_length "16384"
max_connections "128"

decoder {
plugin "ffmpeg"
enabled "yes"
}

input {
plugin "curl"
}

resampler {
plugin "soxr"
quality "high"
threads "1"
}

audio_output {
type "alsa"
name "ALSA default"
device "hw:0,0"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "peppyalsa"
device "peppyalsa"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA crossfeed"
device "crossfeed"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA parametric eq"
device "eqfa12p"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA graphic eq"
device "alsaequal"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA polarity inversion"
device "invpolarity"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA bluetooth"
device "btstream"
mixer_type "software"
}

audio_output {
type "httpd"
name "HTTP stream"
port "8000"
encoder "lame"
bitrate "320"
tags "yes"
always_on "yes"
}

pi@moOde-Sala-Hobby:~/peppyalsa/src $

But I still have problems with "/etc/asound.conf":
If I configure the only available HW, the system returns the BUSY error
If I don't configure anything, it returns me "slave not configured"
If I configure NULL as a slave it seems ok but nothing goes to the FIFO.

Any advice for the slave argument or, better, for the entire asound.conf?

Sincerely and thank you both very much,
Francesco
 
Have you tried keeping just the peppymeter output with the properly configured slave soundcard, removing the direct hw:0 alsa output from your mpd.conf? IMO the peppymeter is clocked by period_elapsed calls of the slave device, these calls are propagated along the alsalib chain from the slave through all the parental plugins all the way up to the player. That way the soundcard at the end times transmission of samples throughout the whole upstream chain. IMO the slave device should be configured and be the real output soundcard device. But I have not tried...
 
Hi Phofman,
Thanks but, unfortunately I dont follow you, but I can try.
I say "try" because the mpd.conf, in moOde, is automatically generated at each reboot. I have to try to modify the related code.
If you have any additional idea, Please do not hesitate to let me know.
Thanks again and best regards,
Francesco
 
You have many alsa_outputs in your mpd config, apparently all of them enabled at the same time. Does each of them really output to a different HW device? If not, logically a latecomer will hit the "resource busy" error unless dmix plugin is somewhere in the alsalib chain to allow mixing multiple streams.
 
Hello Phofman,
It is true: that is the infrastructure of moode, my goal is to make Peppymeter running in that environment.
Last week I did it without any additional DAC board, using the headphone directly connected to the rpi.
Adding the board I am, now, experiencing the problem you are kindly helping to risolve.
Thanks a lot,
Francesco
 
It really does not matter which particular soundcard you are using, any HW device will be busy when a second open call is attempted.

I would be surprised if moode ruined MPD config to produce multiple opening the same device.

I would start by cleaning all the MPD outputs from the config and adding them back one by one. For peppymeter and playback IMO just the peppy meter with HW as slave should do. The other configs either should point at a different soundcard or should be incorporated into the peppymeter config chain. Experimenting will certainly take you to the desired result.
 
Hello "rpi", hello Phofman, hello everybody,
the results of several tests are:
1. moOde ver. 7.0.1 without any DAC board: Peppyalsa OK, PeppyMeter OK, it seems that the quality of sound is not very high (?because the ALSA chain sends the data twice to output?). The command to redirect to the touch has to be initiated in the PeppyMeter as default directory
Code:
cd /home/pi/PeppyMeter
sudo python3 peppymeter.py > /dev/fb0

2.moOde ver. 7.0.1 with a directly connected DAC card (GPIO): Peppyalsa no OK: if I use the same asound.conf (point 1) it raises a "device busy" error. I tried different configurations: the error disappears if I use null as type of pcm: the program opens the fifo file but (I think due to null) it does not write any data (checked via cat, tail -f, peppyalsa-client). I tried with a pcm with the file as type but it has the same result.

I think the best way should be to send data to an HDMI port to get:
a. clean data stream
b. an output for peppyalsa

Do you have any suggestions?
Thanks for your attention and best regards,
Francesco
 
Last edited:
This is moving in circles.

Please post mpd.conf + all relevant asound configs (/etc/asound.conf, .asoundrc for the mpd user, aplay -l to see the device IDs) for the working and not working case.

Adding a soundcard does not cause a resource busy message. It is an incorrect configuration which does it. Should moode generate the incorrect config, it must be fixed. But trial/error does not lead anywhere, only proper troubleshooting does.
 
Hi Phofman,
please find attached two .zip:
1. It is related to the setup without additional DAC: it works fine but (it seems to me) with an audio issue (it looks like it goes through a metal tube).
2. It is related to the configuration with a GPIO DAC card: using "type null" peppyalsa starts, opens the fifo, but (it seems) there is no data.
Obviously I have done a lot of tests and please be free to ask for any additional tests.
It is my opinion that the problem reported in point 1 is related to a double flow of data to the (internal) DAC.
If we can send the data to a "dummy" slave, I think (and hope) we will solve both problems.
Thanks a lot and best regards,
Francesco
 

Attachments

  • peppyalsa OK - no DAC.zip
    324.2 KB · Views: 56
  • peppyalsa no OK - DAC.zip
    2.7 KB · Views: 51
Thanks. The no-OK zip - I could not find the resource busy error plus the alsa config uses that null slave. We need the nonworking config instead.

Also - mpd opens lots of alsa pcm devices which are not listed in the asound.conf file (eqfa12p, alsaequal, invpolarity, etc.). They must have their definition somewhere. If mpd runs under regular mpd user, it's home dir is typically /var/lib/mpd - that dir may have the user-specific .asoundrc file.

For exact info - user under which the mpd process runs is to find in output of ps axu. Home dir of that user is listed in /etc/passwd.
 
Hello Phofman,
thanks a lot for your prompt reply: please find below the answers.

The Non-working configuration was already sent:
you can find it in the post #398

The configurations for the other ALSA are in the /etc/alsa/conf.d/ directory:
please find attached .zip

The user under which the mpd process runs is:
mpd 764 0.1 0.5 137740 21528 ? SLsl 22:42 0:00 /usr/local/bin/mpd --no-daemon /etc/mpd.conf

The home directory for mpd user is:
mpd:x:1001:1001::/home/mpd:/bin/bash
Thanks again and best regards,
Francesco
 

Attachments

  • Other ALSA.zip
    5.2 KB · Views: 40
I think the cause is this:

RPi's bcm2835 driver is just an alsa shim on top of a closed-source firmware running on the Broadcom VideoCore GPU. This device supports hardware mixing of 8 substreams - see posts by the RPi firmware engineer in [SOLVED] Need help disabling software audio mixer (DMIX) * Issue #439 * raspberrypi/linux * GitHub .

A driver/soundcard supports hardware mixing if it defines multiple substreams, as listed in aplay -l. Very few soundcards support hardware mixing, hence most offer only one substream. Just like your I2S DAC.

Now your mpd configuration clearly counts on device hw:0 having multiple substreams available - look how many times the same device was opened in mpd.log of the working config, when hw:0 is the bcm2835 device.

Therefore I need the mpd.conf and corresponding mpd.log for the nonworking case.
 
I have a question: as I already explained, in the moOde environment it is not possible to edit the "mpd.conf" because it is automatically generated. To do that I have edited two files called playerlib.php and worker.php which seems correctly generated the mpd.conf. I am afraid that my modifications could be not complete or correct. If you need I can send the modified files, the original are already in the .zip.
Thanks again,
Francesco