help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: create loop for auload


From: Ben Abbott
Subject: Re: create loop for auload
Date: Fri, 9 May 2008 09:30:51 -0400


On May 9, 2008, at 8:14 AM, miguel olivares varela wrote:

Hi,

I'm a student and i want to create a routine "m-file" to be able to read all the "wav" files that I have in my current directory. I found auload to do it like this:

payload = auload("audio.wav");
save audio.mat payload
auplot(payload);

but i want to create a loop or mayba change the fonction auload i mean in place to accept the name of the file, can accept a variable in order to read all wav files. Does anybody knows how can i do it?

Thanks

I haven't tested it, but is this the sort of thing you're looking for?

function [wavdata] = auloadfiles(filter)
  if (nargin < 1)
    filter = "*.wav";
  endif
  wavfiles = dir (filter);
  N = numel(wavfiles);
  wavdata(N).name = "";
  wavdata(N).data = [];
  wavdata(N).rate = 0
  wavdata(N).fmt  = "";
  for n = 1:N
    wavdata(n).name = wavfiles(n).name;
[wavdata(n).data, wavdata(n).rate, wavdata.fmt] = auload (wavdata(n).name);
  endfor
endfunction

Ben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]