Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Understanding volume setting with CamillaDSP
#1
Hello Forum,

I am trying to get my head around the volume information displayed in moOde when playing audio using CamillaDSP.

For example:
Code:
Volume typeCamillaDSP (64-bit), Range 70 dB
Volume levelsKnob 80, ALSA 0.00dB, CDSP -14dB

I can see that the Knob Position (KP), Volume Range (VR), and volume level are related: -(100-KP)*VRdB/100 is -14dB
(This formula is not valid for very low knob positions but I am only interested in redondance here. It is valid for all volume ranges from 30dB to 80dB.)

Changing the Audio ALSA Options Max Volume value from 100 to 80 changes the current ALSA volume to 94% (according to moOde GUI) but yields:
Code:
Volume typeCamillaDSP (64-bit), Range 70 dB
Volume levelsKnob 80, ALSA -6.00dB, CDSP -14dB

My (limited) understanding is that a -6dB drop is a 50% drop in amplitude (10^(-6/20) = 50%).

How can I relate the change in Max Volume value and the resulting ALSA dB value ?

Regards,

PS: Thanks to every contributors that produced docs/moode_audio_infrastructure.md at main · moode-player/docs · GitHub.
Reply
#2
Hello Tim,

I realize my question screams "newbie". Here is a second attempt.

On a RPi5 HDMI audio interface (MAI PCM i2s-hifi-0), there is a single control named "PCM" with limits of 0 to 255 to set the volume.

As noted on the moOde Audio configuration page, "Alsamixer volume units (1 to 100) are used".

If I set the "ALSA Options" "Max volume" to 80, the web page displays "Current ALSA volume: 90%" (after a gentle refresh).

This value of 90% translate to a "PCM" control value of 230 (that is 90% * 255 / 100 =229.5).

I can verify that this index decrease the volume by 5dB ON THIS CARD (this is hard coded in the device):
Code:
musical@moOde:~ $ amixer -c vc4hdmi1 sget PCM
Simple mixer control 'PCM',0
 Capabilities: pvolume
 Playback channels: Front Left - Front Right
 Limits: Playback 0 - 255
 Mono:
 Front Left: Playback 230 [90%] [-5.00dB]
 Front Right: Playback 230 [90%] [-5.00dB]
musical@moOde:~ $

And I can verify in the "Audio Information" of the currently playing entry that volumes levels are shown as "Volume levels: Knob 100, ALSA -5.00dB, CDSP 0dB".

The question is: how do you compute this 90% result from the "Max Volume" set at 80?

Regards,
Reply
#3
Hello Tim,

I did not realize that this question is akin to prying out a trade secret and I aplogize for any inconvenience.

In the "Audio Information" display, volume levels are reported in dB (eg, "Volume levelsKnob 90, ALSA -3.00dB, CDSP -6dB").

I want to set ALSA level in "Audio Settings" to a specific value in dB.

A value of 89 is entered for a HiFiBerry DSP+ ADC Pro to get the -3dB shown above.

If using the HDMI port connected to a RaspBerry Pi Monitor, a value of 87 must be entered to obtain the -3dB level (even if this device is using a strictly linear function to calculate its gain, as shown below).

Would it be possible to enter the desired volume level in "Audio Settings" rather than what looks like a magic number to obtain this result ?

Regards,


Code:
musical@moOde:~ $ amixer -c vc4hdmi1 contents
[ ... ]
numid=6,iface=MIXER,name='PCM Playback Volume'
 ; type=INTEGER,access=rw---RW-,values=2,min=0,max=255,step=0
 : values=240,240
 | dBscale-min=-51.00dB,step=0.20dB,mute=0
[ ... ]
Reply
#4
I suspect the lack of replies is probably because you are the only person who's looked this deeply into the various relationships between volume controls. I expect you are the expert Smile
----------------
Robert
Reply
#5
Thank you for your sense of humor!

Actually, if CamillaDSP is active, you have a linear step of (CamillaRange/100)dB for a 100 positions knob.

So if you set Camilla to a range of 50dB and you want to reduce the volume by 3dB, you need to set the knob position to (100-3/.5)=94.

Note that moOde displays a single decimal and that is sufficient for the allowed 30 t0 80dB ranges, regardless of knob position.

It would be nice to have the same functionality at the hardware level. Unfortunately, the 'PCM Playback Volume' (or whatever the ALSA control is named for the card in use) will have a different  scale and it becomes difficult to know the final result.

Regards,
Reply


Forum Jump: