Decibel to percentage within a given range

121 Views Asked by At

I'm not sure if this is possible at all or if its not possible with the information that I currently have. If it's not possible please let me know. I'm not the best in math so searched on the internet but didn't find a suitable answer.

I'm building a USB device with receives information from Windows on the current volume setting and I would like to calculate that into a percentage. The issue that I'm facing is that the information received is not linear as it is notated in decibel.

I have the following information (raw and decibel):

  • lowest possible value: -1536 -> 0db (ie 0%)
  • highest possible value: 9216 -> 36db (ie 100%)
  • The received can never exceed these 2 values

since the lowest possible value is negative I increased all values (lowest, highest and incoming) with 1536 so that I wont have to deal with negatives. My latest attempt is close but not good. 98% in windows would calculate into 91% for me:

$(((receivedDB - dB_L) * 100) / (dB_M - dB_L))$

I'm not sure if this can help, but here are some values that Windows sends (from 100% to 90% (windows volume scale), windows jumps by 2%) these are corrected (increased by 1536):

  • 10752
  • 9814
  • 9814
  • 6891
  • 7884

To calculate the DB this formula is used $value * (1 / 256)$