PDA

View Full Version : Getting volume (Linux - C)


vank
11-15-2002, 03:12 PM
I want to build a small console volume meter, but I have no idea how to get the current volume.
I don't mean the volume which is set with some mixer, but the volume as it changes through a song.

I really hope anyone got a pointer or two...

Strike
11-15-2002, 03:41 PM
Well, depending on what sound daemon (if any) you are using, it'd differ. With no sound daemon, you'd have to monitor /dev/dsp (I guess you could clone the fd of it and then read it as well so you don't block on it). With esd, there's a program called esdmon that you can use to create a sort of socket you can connect to at any time to check the output of esd.

The easier (and generally more correct, but less universal) solution is to normalize volume before sending it to be played anywhere (i.e., write a normalization plugin for whatever program is playing the sound, or for the sound daemon).

skidooer
11-15-2002, 04:49 PM
Have a look at the source found in this:
http://mirror.bteg.net:8080/slackintosh/source/ap/rexima/rexima-1.2.tar.gz
It looks really straitfoward, so you should be able to quickly adapt it to whatever you want to do.

However, Strike is right, normalizing the sound stream would be a more elagant way to do it.