Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Conversation

@adrian-stepien
Copy link
Contributor

Knowing what is the SPL corresponding to 0 dBFS its possible to calibrate
the signal.

@topherbuckley
Copy link

topherbuckley commented Dec 8, 2018

@adrian-stepien I don't understand the logic here. How do you know the SPL corresponding to 0 dBFS? The typical way to calibrate dBFS to dB SPL would be to send in a calibrated signal (typically 94 or 114 dB from an acoustical calibrator/pistonphone) and then compare the current dB reading with the reference value. You can then offset the current reading by whatever difference is found.

Where does the assumption of "We know that peak value equals 1. 1 Pa" come from? 0 dBFS can correspond to any dB SPL depending on the gain structure of the equipment/software you are using. I don't think there is any way of hardcoding it like you have to just offset the gain by a fixed value.

Also, I'm not so familiar with the whole package, but your line 146 is just multiplying all decibel values by -92.98979. Assuming decibel is actually a logarithmic value, I don't think you'd want to do any calibration/adjustments via multiplication on log values.

@tcanders
Copy link

tcanders commented Dec 9, 2018

As far as I can see, the existing calibrate_to(...) and calibrate_with(...) sets the mean power of the signal to a certain dB SPL, but sometimes (with tones and a known input chain) you just know that 0 dBFS corresponds 27.3 dB SPL. In that case, it's nice to be able to say calibrate_peak(27.3).

Adrian's implementation adds 27.3 dB re 20uPa/MSB to the dBFS value, where MSB stands for a digital 1. So if you've measured -10 dB FS, your "calibrated" sound pressure level is 17.3 dB SPL.

Perhaps the "calibrated" terminology between the calibrate_ functions needs to be clearer.

@FRidh
Copy link
Member

FRidh commented Dec 9, 2018

Thanks for the explanation, that clarifies it. I never used it myself like that, but it makes sense.

@FRidh FRidh added the feature label Dec 9, 2018
@adrian-stepien
Copy link
Contributor Author

adrian-stepien commented Dec 9, 2018

@topherbuckley Certain devices offer you the calibration based on a peak amplitude. For example NTi XL2 embeds it in the filename, which allows for post-processing (see page 47).
Obviously @tcanders nailed the explanation ;)

@topherbuckley
Copy link

@adrian-stepien thanks for the link. Hadn't seen that before.

@tcanders It still wasn't make sense to me how setting the gain by inputting a decibel value and then subtracting 93.979 dB from it does anything of value, so allow me to walk myself through it and maybe help others understand later on.

If you had some signal that you measured on this NTi XL2, and it had a marked 27.3 dB SPL peak (ignoring the fact that this is absurdly quiet for any peak :D) signal and you wanted to set the gain such that the entire signal levels were now converted from dBFS to dB SPL. This is the goal right?

Lets start with Adrian's assignment of the gain:

gain = decibel * np.ones(self.shape) - 20*np.log10(1/2e-5)

And then just simplify this argument to only look at the single value in the array which represents the peak value (27.3 in this case), since I don't know a way to render equations in markdown and this is getting messy already. You could then redefine the gain assignment as:

gain = decibel * - 20*np.log10(1/2e-5)

The actual gain factor from gain() is defined as:

factor = 10.0**(decibel/20.0)

Fully evaluating the return from gain() would get you the equation below. .

self * 10.0**( (decibel - 20*np.log10(1/2e-5) ) / 20.0)

I would expect this to evaluate to the pressure equivalent of 27.3 dB, i.e. 20*np.log10(return/2e-5) = 27.3, and it does! I wanted to continue this derivation to show it analytically, but plugging it in to python and seeing it work is enough for me before bedtime.

I'm satisfied with my walk-through, and hopefully this helps someone in my shoes later.

@adrian-stepien
Copy link
Contributor Author

Hi @FRidh, any chance for merging that change?

@FRidh
Copy link
Member

FRidh commented Feb 17, 2020

This needs a rebase first.

@adrian-stepien
Copy link
Contributor Author

@FRidh I see. From what I can see, my branch is 4 commits ahead of the master.
Thank you for your reply.

Knowing what is the SPL corresponding to 0 dBFS its possible to calibrate
the signal.
@jftsang
Copy link

jftsang commented Aug 15, 2022

Hi @adrian-stepien and @FRidh, will there be any more progress merging this PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants