Sound Pressure Level Calculator

バージョン 1.2.0.0 (121 KB) 作成者: Chad Greene
Calculates sound pressure level in decibels, given a pressure signal in pascals.
ダウンロード: 4.4K
更新 2016/3/4

ライセンスの表示

Calculate sound pressure level (in dB) of given pressure signal 'p_Pa'.
SYNTAX
spl_dB = spl(p_Pa,ref)
spl_dB = spl(p_Pa,ref,windowSize)
spl_dB = spl(p_Pa,ref,windowSize,Fs)

DESCRIPTION
spl_dB = spl(p_Pa,ref) returns sound pressure level in decibels referenced to reference pressure |ref| in pascals. This usage returns a scalar value of spl_dB for the entire p_Pa signal.
spl_dB = spl(p_Pa,ref,windowSize) returns a moving SPL calculation along the window size specified by windowSize, where the units of windowSize are number of time indicies.

spl_dB = spl(p_Pa,ref,windowSize,Fs) returns a moving SPL, where windowSize is not indices of time, but _units_of time equivalent to units of 1/Fs.

INPUTS:
p_Pa = vector of pressure signal in units of pascals. Can be other units if you declare a reference pressure of matching units.

ref = reference pressure in units matching p_Pa or simply 'air' or 'water' if p_Pa is in pascals.

windowSize = window size of moving spl calculation. If no windowSize is declared, the spl of the entire input signal will be returned as a scalar. If windowSize is declared, but Fs is not declared, the units of windowSize are number of elements of the input vector. If windowSize and Fs are declared, the units of windowSize are time given by 1/Fs.

Fs = (optional) sampling frequency. Note! including Fs changes how this function interprets the units of windowSize.

OUTPUT:
SPL = sound pressure level in decibels. If windowSize is declared SPL is a vector of the same length as p_Pa. If windowSize is not declared, SPL is a scalar.

Note that this does account for frequency content. A-weighted decibels (dBA) are frequency-dependent. This function does not compute dBA.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
EXAMPLES
* * * Example 1: * * *

load train % (let's assume y is has pascals as its units)
spl(y,'air')
ans =
84.6

* * * Example 2: Enter your own custom reference pressure: * * *

load train % (let's assume y is has pascals as its units)
spl(y,20*10^-6)
ans =
84.6

* * * Example 3: A moving window of 501 elements and plot: * * *

load train
SPL = spl(y,'air',501); % <-- Here's how to use the function.

t = cumsum(ones(size(y))/Fs);
figure
subplot(2,1,1)
plot(t,y)
axis tight
ylabel('pressure (Pa)')

subplot(2,1,2)
plot(t,SPL)
axis tight
ylabel('spl (dB)')
xlabel('time (s)')

* * * Example 3: A 10 ms moving window and plot: * * *

load train
SPL = spl(y,'air',0.010,Fs);

t = cumsum(ones(size(y))/Fs);
figure
subplot(2,1,1)
plot(t,y)
axis tight
ylabel('pressure (Pa)')

subplot(2,1,2)
plot(t,SPL)
axis tight
ylabel('spl (dB)')
xlabel('time (s)')

引用

Chad Greene (2024). Sound Pressure Level Calculator (https://www.mathworks.com/matlabcentral/fileexchange/35876-sound-pressure-level-calculator), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2016a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersAudio and Video Data についてさらに検索
謝辞

ヒントを得たファイル: slidefun

ヒントを与えたファイル: Water sound speed calculator, Seawater Acoustic Absorption Calculator, plotpsd

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

spl_demo/

spl_demo/html/

バージョン 公開済み リリース ノート
1.2.0.0

slidefun now included in the function. Demo included.
MathWorks update: Added Live Script.

1.1.0.0

Version 2 now allows for a moving SPL calculation.

1.0.0.0