I am calibrating my microphone system consisting of a microphine whose signal is amplified and then converted from analog to digital with an ADC. The ADC converts the data to a 16-bit integer.
The calibration microphone produces 94 dBSPL at 1 kHz. I am sampling with 192 kHz, then plotting the FFT of that signal to find the given dBV at 1kHz.
First, converting the unit-free signal to V using:
calibration_94dB_1kHz = signal * (1 / 32768)
Then applying a window:
N = len(calibration_94dB_1kHz)
s = signal.windows.flattop(N) * calibration_94dB_1kHz
Then calculating the one-sided FFT with:
X = 2 * np.abs(np.fft.rfft(s))/N # normalize the fft by the window-length and multiply by 2 since we are discarding the negative frequencies of the FFT
X_freq = np.fft.rfftfreq(N, 1.0 / 192000)
The data needs then to be plotted logarithmic so:
X_dbV = 20*np.log10(X) # get fft in dBV
When plotting the data with:
axs[1, 0].clear()
axs[1, 0].semilogx(X_freq, X_dbV, color=colors[1], label='Frequency response |S(jw)| detrended and windowed')
axs[1, 0].grid(True)
axs[1, 0].legend(loc='upper left')
I get a peak at approximately 1 kHz that is -48.3 dBV. How can I convert this value to dBSPL if the mic has a sensitivity of -38 dBV +- 1, which is tested from the manufacturer with 1 kHz at 94 dBSPL?
EDIT: Here is the updated code:
calibration_94dB_1kHz_detrended = signal.detrend(data=calibration_94dB_1kHz, type='constant')
s = calibration_94dB_1kHz_detrended
Gain = 1 + 100 / 4.7
calibration_in_rms_Vpp = s / (2*np.sqrt(2)) # assuming p-p sinusoidal waveform
sensitivity = -38 # dBV
# Apply window
N = len(calibration_in_rms_Vpp)
s = signal.windows.flattop(N) * calibration_in_rms_Vpp
X = 2 * np.abs(np.fft.rfft(s))/N # normalize the fft by the window-length and multiply by 2 since we are discarding the negative frequencies of the FFT
X_freq = np.fft.rfftfreq(N, 1.0 / 192000)
X_dbV = 20*np.log10(X) # dBVrms
X_dbSPL = X_dbV - Gain - sensitivity + 94 # dBSPL