How can I convert a .wav file to Pascals?
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a 1 kHz tone, which is calibrated at 94 dB re. 20 uPa, and I am asked to calculate a scale factor which, by multiplying any point of the normalised amplitude, converts it to Pascals.
So far I have this, but it is wrong:
% Load the calibration audio file
[calibration_audio, calibration_fs] = audioread('calsig_1k_94dB.wav');
[unknown_audio, unknown_fs] = audioread('pianochord1scaled_corrected.wav');
% Calculate the number of samples corresponding to the first 50 ms
num_samples = round(0.05 * calibration_fs);
% Extract the first 50 ms of each signal
calibration_signal_original = calibration_audio(1:num_samples, 1); % Assuming a single-channel file
music_signal_original = unknown_audio(1:num_samples, 1); % Assuming a single-channel file
% Create a time vector for the x-axis
time_vector = (0:(num_samples - 1)) / calibration_fs;
% Create a figure to display the signals
figure;
subplot(2, 2, 1);
plot(time_vector, calibration_signal_original);
title('Calibration Signal (Original)');
xlabel('Time (s)');
ylabel('Amplitude');
% Define the scale factor for calibration signal in pascals
RMS = sqrt(calibration_audio/num_samples);
calibration_scale_factor = (20e-6)*(10^(RMS/20));
% Scale the calibration signal
calibration_signal_scaled = calibration_audio(1:num_samples, 1) * calibration_scale_factor;
First, I convert the normalised amplitude to dB RMS with the RMS variable (which I assume is wrong) and then apply the formula to convert RMS to Pascals.
Once I have the scale factor, I can also convert a .wav piano chord to Pascals as well.
Risposte (2)
Brahmadev
il 20 Set 2023
Hi Ferran,
I understand that you would like to convert '.wav' data into ‘Pascals’.
For calculation of RMS value of the calibration signal, the following approach can be used:
RMS = sqrt(mean(calibration_signal_original.^2));
To find the 'calibration_scale_factor', you can refer to the following code:
% Calculate the scale factor of the calibration signal
reference_spl = 94; % dB re. 20 uPa
reference_pressure = 20e-6; % 20 microPascals
calibration_scale_factor = 10^((reference_spl - 20 * log10(reference_pressure)) / 20);
Hence this new 'calibration_scale_factor' value can be used to convert the '.wav' values to ‘Pascals’ using:
audio_scaled = calibration_signal_original*calibration_scale_factor ;
I hope this provides you with relevant information on how to convert '.wav' values into 'Pascals'.
Best regards,
Brahmadev
0 Commenti
Vedere anche
Categorie
Scopri di più su Audio I/O and Waveform Generation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!