Code covered by the BSD License
-
initDisplay(AI,x,X,dBA,Fs,C)
INITDISPLAY Initializes SLM figure window.
-
SLM
SLM Implements a basic sound level meter.
-
analyzeSignal(x,Fs)
ANALYZESIGNAL Evaluates dBA level of input signal.
-
estimateLevel(x,Fs,C)
ESTIMATELEVEL Estimates signal level in dBA.
-
filterA(f,plotFilter)
FILTERA Generates an A-weighting filter.
-
initSoundCard(Fs,responseType...
INITSOUNDCARD Initializes the sound card.
-
runCalibration
RUNCALIBRATION Estimates the calibration constant.
-
stopSoundCard(obj,event)
STOPSOUNDCARD Closes sound card device.
-
updateDisplay(obj,event)
UPDATEDISPLAY Updates the SLM display.
-
View all files
from
Sound Level Meter
by Douglas Lanman
Implements real-time spectrum analyzer and displays decibel level.
|
| SLM
|
function SLM
% SLM Implements a basic sound level meter.
% SLM Uses the Data Acquisition Toolbox to estimate
% the windowed FFT of the microphone input signal.
% A-weighting is applied to the frequency spectrum
% to measure sound level in dBA. Results are
% displayed in real-time for fast/slow responses.
%
% Author: Douglas R. Lanman, 11/21/05
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set sound level meter (SLM) options.
% Set sampling rate (in Hz).
% Typical rates: {8.000, 11.025, 22.050, 44.100} kHz
Fs = 44.1e3;
% Choose response type.
% Note: {'fast' = ~125 ms, 'slow' = ~1.0 s}
responseType = 'fast';
% Set calibration constant.
% Note: A quite location will be ~55 dBA.
C = 50;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Reset Matlab display.
clc;
% Initialize sound card acquisition.
[AI,Fs,N] = initSoundCard(Fs,responseType);
% Process initial sound card sample.
x = getdata(AI);
[X,dBA] = estimateLevel(x,Fs,C);
% Initialize display window.
initDisplay(AI,x,X,dBA,Fs,C);
% Start real-time data acquisition.
set(AI,'TimerFcn',@updateDisplay);
|
|
Contact us at files@mathworks.com