[pulseaudio-discuss] Volume algorithm

Colin Guthrie gmane at colin.guthr.ie
Sat Mar 5 04:00:57 PST 2011


'Twas brillig, and Tarantism at 05/03/11 11:29 did gyre and gimble:
> On Sat, 2011-03-05 at 11:08 +0000, Colin Guthrie wrote:
>> 'Twas brillig, and Tarantism at 04/03/11 22:23 did gyre and gimble:
>>> I need to implement a volume scaling in a pulse module.
>>> I have 0-100 input values.
>>> What algorithm does pulse usually implement for this so that I can match
>>> it?
>>
>> Can you explain a little more what you're trying to do? You shouldn't
>> generally need to worry about volume scaling in PA modules.
> The module is a signal source for the default sink (based on
> module-sine.c) so it creates a sink_input and provides pop (etc)
> callbacks for that. I'm using it to produce low latency sound on Maemo.
> 
> I had expected that system volume would be handled downstream of the
> sink_input but changing system volume has no effect. I've managed to
> hook up to the system volume level by dbus and just want to know how to
> scale my data correctly.
> 
> At the moment I'm getting reasonable results by y = y * x^4 where 0 <= x
> <= 100 but I wondered if pulse has some other algorithm available?

If you have a sink_input in your code, can you not simply use:
pa_sink_input_set_volume() ?

With regards to a the %age mapping we use a cubic scale to map dBs to %.

I'm still not 100% sure what you're meaning tho'. If your system volume
is totally busted, then pa_sink_input_set_volume() wont work by default
as it will use flat volumes which ultimately cause the system volume to
change if it's the only stream. If this is the case, then it's likely
just a problem with your system volume using the correct ALSA kcontrols
to make adjustments (e.g. I've noticed some problems recently with the
"Speakers" element....)

In order to test this, you could disable flat-volumes in daemon.conf and
then pa_sink_input_set_volume() should be 100% software and should work.
If this is the case, please let us know and we can debug things further.

Does the system volume affect other sounds OK or is it totally busted?

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




More information about the pulseaudio-discuss mailing list