%% Measure Acoustic Sharpness from Sound Pressure Level
% Read in an audio file.

[audioIn,fs] = audioread('Turbine-16-44p1-mono-22secs.wav');

%
% To calculate sound pressure levels from an audio signal, first create an splMeter object. Call the splMeter object with the audio input.

spl = splMeter("SampleRate",fs,"Bandwidth","1/3 octave", ...
    "FrequencyWeighting","Z-weighting","OctaveFilterOrder",6);

splMeasurement = spl(audioIn);

%
% Compute the mean SPL level, skipping the first 0.2 seconds. Only keep the bands from 25 Hz to 12.5 kHz (the first 28 bands).

SPLIn = mean(splMeasurement(ceil(0.2*fs):end,1:28));

%
% To determine the acoustic sharpness of the audio signal, call acousticSharpness using the sound pressure level input.

sharpness = acousticSharpness(SPLIn)

%
% Copyright 2019 The MathWorks, Inc.