Acoustics research centre
Calculating the Metrics
These are MATLAB codes provided to calculate values for the following metrics: Third octave band levels, loudness and sharpness. Before using the MATLAB codes 2-channel .wav files should be separated into two 1-channel .wav files. The left and right channels can be extracted separately to .wav file as described using Adobe audition, the codes DO NOT work for 2-channel .wav files.
In order to use the MATLAB codes all codes and .wav files should be in the current MATLAB directory. The .wav file must be imported as a matrix to be used by the sound quality functions ‘filter_third_octaves_downsample’, ‘loudness_1991’, ‘sharpness_Fastl’ and ‘roughness4’. This can be done by typing ‘[x Fs] = wavread(‘
Third Octave Spectrum
To calculate the powers in the third octave bands we require: x and Fs (see above), Fmin and Fmax which are the lowest and the highest third octave bands for which a power value is required (usually these would be 25 Hz and 12.5 kHz respectively), Pref which is a reference value (this can be calculated by inputting a reference tone into the filters Pref is then the difference between the level of the tone and the value returned by the filters), and N which is the steepness of the third octave filters (usually this would be 8). Typing ‘[Ptotal,P,F]=filter_third_octaves_downsample(x,Pref,Fs,Fmin,Fmax,N)’ at the console then returns the values Ptotal which is the total power of the sound, P which is a matrix of power values for each of the corresponding third octave centre frequencies in the matrix F. A bar chart of these values is also plotted.
To calculate loudness we require: x and Fs (see above), and Pref which is a reference value (this can be calculated by inputting a reference tone into the third octave filters function described above, in this case N should be input as ‘4’, Pref is then the difference between the level of the tone and the value returned by the filters) and Mod which is 0 for a free field and 1 for a diffuse field. Typing ‘[N_entire,N_single] = loudness_1991(x,Pref,Fs,Mod)’ at the console returns the values N_entire which is the total loudness of the sound (in sones) and N_single which is a matrix of 240 specific loudness values spaced at 0.1 Bark intervals (in sones/Bark). A graph of these values is also plotted.
To calculate the sharpness we must first calculate the loudness using the function above. Then typing ‘[sharp] = sharpness_Fastl(loudspec)’ at the console returns the value sharp which is the sharpness (in Acum).