Jump to content

Play sound at consistent volume regardless of system volume level

Recommended Posts


I'm trying to write a program that adjusts it's own volume level (SoundSetWaveVolume()) depending on the current system volume level (so the program doesn't blast my ears if the system volume is up high).

Both numbers (the script's volume, and the system volume) can be from 0-100.

My problem is i have no idea how to create a single formula that will work like this:

If system volume = 22 Then script volume = 50

If system volume = 100 Then script volume = 3

So if the formula is fed "22" it outputs "50".  If it's fed "100" it outputs "3".

I want the formula to work for all system volume levels (0-100), but the only numbers I know are:

system=22, script=50

system=100, script=3

Can anyone help?

Link to comment
Share on other sites

Link to comment
Share on other sites


Thanks a lot.  Unfortunately it doesn't work like I expected -- I think it's because the Windows master volume and the script volume (SoundSetWaveVolume) use different scale types (one linear and the other logarithmic?).

Apparently changing SoundSetWaveVolume() has no effect on the levels picked up by recording software, so I did some tests with my audio Line-out connected to Line-in.

For each system volume level, I found the value for SoundSetWaveVolume that resulted in getting closest to outputting  -42.3db (the level I'm trying to make output always be).

If anyone want's to try and build a formula, I'd really appreciate it.

Exactness isn't crucial, I just need a formula that outputs somewhere around 59 when fed the number 20, and somewhere around 5 when fed 80, that increases something like the center column of this chart (chart is also attached as a .CSV file):

System Volume    SoundSetWaveVolume    Line-out output
14                            100                                        -43.0db
15                             99                                        -42.3db
20                             59                                        -42.3db
30                             30                                        -42.1db
30                             29                                        -42.4db
40                             18                                        -42.2db
50                             12                                        -42.3db
60                              9                                        -42.1db
70                              7                                        -41.9db
70                              6                                        -43.2db
80                              5                                        -42.8db
90                              4                                        -43.0db
96                              4                                        -42.0db
100                             4                                        -41.4db

Is there a website or program  that you can feed four numbers, and it will build a logarithmic function what will work for both sets of numbers?  Meaning you specify 4 numbers (A1, A2, B1, B2) and it builds one formula that will turn number "A1" into number "A2"  AND also turn "B1" into "B2".

volume - system vs script.csv

Edited by lee321987
Link to comment
Share on other sites

What are you using to detect current volume level?


Here is something that might help...


Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites


Never mind about sound levels not changing in recording software when I changed SoundSetWaveVolume()  -- it's working now.  I don't know what happened that made me think it wasn't.

As far as what I'm using to measure sound levels,  I've been using Audacity (record audio, then do Plot Spectrum), and this:


And thanks for the link to your BASS.dll peak meter.  I saved it to my examples dir!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...