Author Topic: BASS_SETVOLUME level under Win7 does not match actual slider level  (Read 1900 times)

djwim

  • Posts: 33
If I use BASS_SETVOLUME (under Win7), it does change the master volume. And 0 = 0, and 1 = 100. OK. But in between it is not linear..!? I used BASS_SETVOLUME with values from 0...1, in steps of 0.1. This results in the master volume going from 0...100, but not in steps of 10 as I would expect. What is going on here?

BASS      WIN7
0      0
0.1      27
0.2      40
0.3      50
0.4      59
0.5      67
0.6      75
0.7      82
0.8      88
0.9      94
1      100

Ian @ un4seen

  • Administrator
  • Posts: 21991
BASS_SetVolume will use a linear or logarithmic curve, depending on the BASS_CONFIG_CURVE_VOL setting. But Windows 7 volume controls use a curve that is neither linear or logarithmic, which is why the levels don't match. If you would like to use Windows' volume curve, it is possible to do so with the BASSWASAPI add-on; see BASS_WASAPI_SetVolume with mode=BASS_WASAPI_CURVE_WINDOWS. Note that BASSWASAPI's device list is different to BASS's device list, so if you want to use BASSWASAPI to control the volume with BASS output, then you will need to find the BASSWASAPI device that corresponds to the BASS device; you can match the BASS_DEVICEINFO "driver" and BASS_WASAPI_DEVICEINFO "id" values to do that.

cahbka

  • Posts: 10
maybe it was better to put this feature to bass.dll? (BASS_CONFIG_CURVE_VOL: linear, logarithmic and new one: windows)

djwim

  • Posts: 33
I was away for a few days, sorry for a late reply...
Thanks for the explanation Ian. I think I won't bother to use the suggestion to use the BASSWASAPI add-on. After all (for me) it is more cosmetic...
But I agree with cahbka, to update the BASS_CONFIG_CURVE_VOL setting in the .dll ..

Ian @ un4seen

  • Administrator
  • Posts: 21991
The problem regarding a new BASS_CONFIG_CURVE_VOL option is that it doesn't only apply to device volume controls, but also the per-channel BASS_ATTRIB_VOL controls, which means that BASS would need to know the exact shape of Windows' curve to apply it there too. As far as I have seen, WASAPI doesn't provide a way to get that information. An alternative could be to add support for the Windows curve only for the device volume via a new BASS_Set/GetVolumeEx function with an extra "mode" parameter (like BASS_WASAPI_SetVolume has) that overrides the BASS_CONFIG_CURVE_VOL setting.

rv

  • Posts: 291
Hi Ian,

I am trying to add a volume control on a MP3 stream, but I am not finding the current curves very good.

With the logarithmic curve, we have almost no sound from 0% to 75%, and all is changed in the last highest percents
With the linear curve, we have almost all the sound from 25% to 100%, and all is changed in the first percents. There is not so much difference between 50% and 100%

So to my ears, the actual bass volume curves are not ideally reflecting the audio loudness. exp : 50% of the slider mean 50% of the perceived loudness

Maybe that's why Windows did it differently


I have found this : https://www.dr-lex.be/info-stuff/volumecontrols.html

Maybe you can create a 3rd kind of curve?

rv

  • Posts: 291
Would you add an exponential curve too ?
Or maybe I should do it myself with the actual linear curve

Ian @ un4seen

  • Administrator
  • Posts: 21991
Oops, I thought I replied to this yesterday. Anyway, I would suggest sticking with the default linear curve in BASS but try making your slider use a logarithmic curve with a range of 40 dB. For example, if your slider ranges 0 to 100, you could do something like this:

Code: [Select]
float vol = slider > 0 ? pow10(((float)slider / 100 - 1) * 40 / 20) : 0;
BASS_ChannelSetAttribute(handle, BASS_ATTRIB_VOL, vol);

Alternatively, you could indeed implement your own curve in a similar way (on top of the default linear one).

rv

  • Posts: 291
Thank you Ian, it works better now

rv

  • Posts: 291
« Last Edit: 2 Apr '19 - 18:55 by rv »

Steve Grant

  • Posts: 178
I wrote this some time ago in an attempt to match a standard Penny & Giles 104mm broadcast fader.

It is in VB6 but is very simple, so should not present problems in conversion to other languages.

It works extremely well.

Code: [Select]
Private Sub Fader_Scrolling(index As Integer)
    Dim gain As Single, x As Integer
    x = 100 - Fader(index).Value
    gain = 1 / 10 ^ ((x * 0.4) / 20)
    If x > 50 Then gain = 1 / 10 ^ ((x * (0.4 + (x - 50) * 0.01) / 20))
    BASS_ChannelSetAttribute Strm(index), BASS_ATTRIB_VOL, gain
End Sub

rv

  • Posts: 291
Interesting...

Here is what Ian said :
Vol = 10 ^ (x*0.02  - 2)
50> 0.1 60>0.15  70> 0.25 80> 0.4  90>0.63  95>0.79  100>1


Here is what you said :
Vol = 10 ^ (x*-0,0005  +x*0,095  - 4.5)
50>0.1  60>0.25 70> 0,50  80> 0.79  90>1  95>1.02   100>1

Not sure what is the best :)

rv

  • Posts: 291
Here are the graphics

Steve Grant

  • Posts: 178
Could you re-post the complete graphic showing the dB marks. Also which colour is which.

In the meantime I will look out the graph of a Penny & Giles fader (these are used in all premium mixers) and post it.

As to which is best, only your ears and control-ability will tell you that. 

Steve Grant

  • Posts: 178
Here you go.

I am no mathematician but I don't think you have broken down my example correctly. Also I have 2 attenuation rates (as does P & G). You show an X2 unless that is a typo.
« Last Edit: 4 Apr '19 - 10:11 by Steve Grant »

rv

  • Posts: 291
Yours is the green curve. It is linear values 0 to 1, not dB like your graphical
yes x because you have x * x somewhere in your formula

Steve Grant

  • Posts: 178
Well you have something not quite right as you show a gain at the 95% mark.

Here is a run just done of the actual value and attenuation. The first figure is the fader position. The second the gain sent to BASS. The third the gain in dB.

100          1.0000        0.00dB dB
 95           0.7943        -2.00dB dB
 90           0.6310        -4.00dB dB
 85           0.5012        -6.00dB dB
 80           0.3981        -8.00dB dB
 75           0.3162        -10.00dB dB
 70           0.2512        -12.00dB dB
 65           0.1995        -14.00dB dB
 60           0.1585        -16.00dB dB
 55           0.1259        -18.00dB dB
 50           0.1000        -20.00dB dB
 45           0.0579        -24.75dB dB
 40           0.0316        -30.00dB dB
 35           0.0163        -35.75dB dB
 30           0.0079        -42.00dB dB
 25           0.0037        -48.75dB dB
 20           0.0016        -56.00dB dB
 15           0.0006        -63.75dB dB
 10           0.0003        -72.00dB dB
 5            0.0001        -80.75dB dB
 0            0.0000        -90.00dB dB


rv

  • Posts: 291
Oh you are right, you have 2 functions

In facts, if the slider is > 50 then you do exactly the same as Ian

So look at the curves
Green curves up to to 50, then blue curve