Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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]);

回答(1 个)

Stalin Samuel
Stalin Samuel 2015-2-5
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!

Translated by