maad.spl.power2dBSPL
- maad.spl.power2dBSPL(P, gain, Vadc=2, sensitivity=-35, dBref=94, pRef=2e-05)[source]
Convert power (amplitude²) to sound pressure level (L [dB]).
Warning
- Important: Previous versions of this function incorrectly calculated the
volt conversion by omitting the division by 2 for the Vadc parameter. In dB SPL, this would lead to a 6 dB increase in the calculated sound pressure level. If you want to correct the SPL values obtained with the previous version, you can simply subtract 6 dB from the old results. This has been corrected in the version 1.5.1. Ensure you are using the latest version (>=1.5.1) to obtain accurate dB SPL values.
- Parameters:
- Pndarray-like or scalar
ndarray-like or scalar containing the power signal (P), for instance Sxx_power, the power spectral density (PSD)
- gaininteger
Total gain applied to the sound (preamplifer + amplifier)
- Vadcscalar, optional, default is 2Vpp (=>+/-1V)
Maximal voltage (peak to peak) converted by the analog to digital convertor ADC
- sensitivityfloat, optional, default is -35 (dB/V)
Sensitivity of the microphone
- dBrefinteger, optional, default is 94 (dBSPL)
Pressure sound level used for the calibration of the microphone (usually 94dB, sometimes 114dB)
- pRefSound pressure reference in the medium (air:20e-6 Pa, water:1e-6 Pa)
- Returns:
- Lndarray-like or scalar
ndarray-like or scalar containing the sound pressure level (L [dB])
See also
Examples
>>> import numpy as np >>> w, fs = maad.sound.load('../data/cold_forest_daylight.wav') >>> Sxx_power,tn,fn,_ = maad.sound.spectrogram (w, fs, nperseg=1024, mode='psd') >>> S_power_mean = np.mean(Sxx_power, axis=1)
Get instantaneous sound pressure level (L).
>>> maad.spl.power2dBSPL(S_power_mean, gain=42) array([ 3.55439604e+01, 3.94219755e+01, 3.71509454e+01, 3.54860553e+01, 3.20633292e+01, 2.85071055e+01, 2.65508217e+01, 2.56607733e+01, 2.43080132e+01, 2.24405108e+01, 2.18647044e+01, 2.14653511e+01, ... -1.11242771e+01, -1.12703297e+01, -1.14085678e+01, -1.14487227e+01, -1.14906343e+01, -1.14980091e+01, -1.16907591e+01, -1.17027481e+01])