disp(' ');
disp(' audio_txt.m   ver 1.1   April 11, 2013 ');
disp(' by Tom Irvine ');
disp(' ');
disp(' This program reads a PCM wav file and converts ');
disp(' it to an ASCII text time history format. ');
disp(' ');
disp(' The output file has two columns: time(sec) & acoustic pressure ');
disp(' ');
disp(' The acoustic pressure is uncalibrated. ');
disp(' ');
%
clear length;
clear y;
clear dt;
clear Fs;
clear tc;
clear filename;
clear fname;
%
qqq=input(' press Enter to select file ');
%
[filename, pathname] = uigetfile('*.*');
filename = fullfile(pathname, filename);
%
[y, Fs] = wavread(filename);
%
out1=sprintf(' Sample rate = %d \n',Fs);
disp(out1);
%
dt=1/Fs;
%
sz=size(y);
%
nq=max(sz);
nc=min(sz);
%
tc=linspace(0,nq*dt,nq);
tc=tc';
%
for(i=1:nc)
   y(:,i)=y(:,i)-mean(y(:,i));
   str=sprintf('sdata%d',i);
   varname = genvarname(str);
   eval([varname ' = [tc,y(:,i)];']);
   fname{i}=sprintf(' %s ',varname);  
end
%
disp(' ');
disp(' Output filename: ');
disp(' ');
for(i=1:nc)
   out1=sprintf(' %s ',fname{i});
   disp(out1);    
end
%
close all;
figure(1);
plot(sdata1(:,1),sdata1(:,2));
xlabel('Time(sec)');
title('Acoustic Pressure Time History');