maad.spl.amplitude2dBSPL
- maad.spl.amplitude2dBSPL(s, gain, Vadc=2, sensitivity=-35, dBref=94, pRef=2e-05)[source]
Convert signal (amplitude) to instantaneous sound pressure level (L [dB SPL]).
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:
- sndarray-like or scalar
s is an amplitude signal (not energy signal : s² )
- 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 waveform in dB SPL (Sound Pressure level in dB)
See also
Examples
>>> import numpy as np >>> w, fs = maad.sound.load('../data/cold_forest_daylight.wav') >>> Sxx_amplitude,tn,fn,_ = maad.sound.spectrogram (w, fs, nperseg=1024, mode='amplitude') >>> S_amplitude_mean = np.mean(Sxx_amplitude, axis=1)
Get instantaneous sound pressure level (L).
>>> maad.spl.amplitude2dBSPL(S_amplitude_mean, gain=42) array([ 33.54362056, 38.35057445, 35.93645686, 33.5848702 , 30.41177332, 27.22906075, 25.42079962, 24.42677998, 22.89529647, 21.24902085, 20.75161999, 20.25268302, ... -12.18064124, -12.32827014, -12.48541472, -12.51967103, -12.54814367, -12.54536435, -12.75677825, -12.77745939])