Friday, 24 May 2019

How to calculate DB SPL given DB FS

I'm working on creating a volume fader using web audio api that allows for a gain of +12db. So far I've calculated the dbFS value for the peak meter.

How do I derive a dbSPL value given the dbFS? From what I understand, volume faders in daw use dbSPL while peak meters use dbFS. Somehow a conversion must be taking place. How do I implement the conversion ?

what I have so far:

//create random amplitude values ranging 0 to 1
let amplitudes = Array.from({ length: 16 }, (_,i) => Math.random() * 1);

//calculate average amplitude
let average = amplitudes.reduce((a, b) => a + b) / 16;

// derive dbFS of given average amplitude value
let dbFS = 20 * Math.log10(average)

//update input element value
peakMeter.value = dbFS;

Now I would like to do the same for volume fader

let dbSPL = //?????

fader.value = spl

//Translate dbSPL back to dbFS then update gain value
audioNode.gain.value = // ???

Any feedback would be helpful.



from How to calculate DB SPL given DB FS

No comments:

Post a Comment