# Long Term Average Spectrum of large batch of audio files

I'm trying to obtain the overall LTAS of a large batch of audio (wav) files. To do this, I should obtain the LTAS of each file individually, then take the average value across all LTASs for each frequency. I also need the standard deviation for each frequency. I'm doing this in Matlab, but am rather a noob. Can anyone offer any pointers to help me write a Matlab script to do this? Thanks!

2. use "pwelch()" to calculated the power spectrum of the songs
3. you do energy averagin over multiple songs.

Something like this (just a code sketch)

nx = 8192; % that's about 5 Hz @44.1 kHz
dd = dir('*.wav'); % all files in the current directory
nFiles = length(dd);
LTAS = zeros(nx/2+1,nFiles)
for i = 1:nFiles
LTAS(:,i) = pwelch(x,hanning(nx),nx/2);
end
LTASOverAllSongs = mean(LTAS,2);

• Thanks for your reply, Hilmar. I can't figure out what to do with the wavread - x = wavread(dd(i).name; - line, though. That's not how I've used wavread previously. Any suggestions? Thanks! – Nobbynomates Mar 3 '14 at 14:35
• It is simply reading the wav file listed previously by dd=dir('*.wav'); (all in current folder). Please mind that there is a missing bracket in this line, should be: x = wavread(dd(i).name). – jojek Mar 29 '14 at 20:12

I know this question is a few years old but here is a solution for the record:

LTASS.m function for MATLAB (Github)

(This is a similar solution to Hilmar's)(Note: Will require getAllFiles() function to work)

• Hi, can you explain further how to make "getAllfiles()_function" to work? I am very new to MATLAB and unsure how to solve this. Thanks! – rjh3m8 Jan 30 at 21:10