Info

This question is closed. Reopen it to edit or answer.

Can I analyse more than one audio file in one code?

1 view (last 30 days)
Mike
Mike on 5 Feb 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
I have analysed one audio file, which is 1hour of recording, made a spectrogram and everything I wanted to do. I have 60 more files which are the following 60hours of recording which need analysing in the same graphs.
Is it possible to continuously loop through all of the files?
Here is the code:
[slab,S_R,bits] = wavread('E:\1.wav',[1 2]);

Answers (1)

Stalin Samuel
Stalin Samuel on 5 Feb 2015
dirName = 'your file directory'
dirData = dir(dirName); %# Get the data for the current directory
dirIndex = [dirData.isdir]; %# Find the index for directories
fileList = {dirData(~dirIndex).name}'; %'# Get a list of the files
if ~isempty(fileList)
fileList = cellfun(@(x) fullfile(dirName,x),... %# Prepend path to files
fileList,'UniformOutput',false);
end
subDirs = {dirData(dirIndex).name}; %# Get a list of the subdirectories
validIndex = ~ismember(subDirs,{'.','..'}); %# Find index of subdirectories
x = 0 %# that are not '.' or '..'
for iDir = find(validIndex)
%# Loop over valid subdirectories
x=x+1
nextDir = fullfile(dirName,subDirs{iDir}); %# Get the subdirectory path
fileList = [fileList; getAllFiles(nextDir)]; %# Recursively call getAllFiles
% pause(1)
end
nfil=size(fileList)
for m = 1:nfil
[y1, Fs1] = wavread(sprintf('%s',fileList{m,1}));
%%your code
end

Community Treasure Hunt

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

Start Hunting!