home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
windows3
/
mtlabsnd.zip
/
WRITEWAV.M
< prev
Wrap
Text File
|
1993-04-26
|
1KB
|
41 lines
function writewav(filename,variable,samplerate,datasize)
% writewav(filename,variable,samplerate,datasize)
%
% Writes a Windows 3.1 WAV type file for the given variable
% and filename. Assumes the variable is column-major and
% of a single column.
%
a_write_wav = variable;
nwrv = size(variable);
twrv = 1;
if nwrv(2) ~= twrv
if nwrv(1) ~= twrv
disp(['Bad variable format. Got ',nwrv(1),' ',nwrv(2),'.'])
else
a_write_wav = a_write_wav';
string = ['save testfoo a_write_wav'];
eval(string);
rate=sprintf('%g',samplerate);
if (datasize == 8)
string = ['!sox -b -r ' rate ' testfoo.mat ' filename '.wav'];
else
string = ['!sox -w -r ' rate ' testfoo.mat ' filename '.wav'];
end;
eval(string);
end
else
string = ['save testfoo a_write_wav'];
eval(string);
rate=sprintf('%g',samplerate);
if (datasize == 8)
string = ['!sox -b -r ' rate ' testfoo.mat ' filename '.wav'];
else
string = ['!sox -w -r ' rate ' testfoo.mat ' filename '.wav'];
end;
eval(string);
end
clear a_write_wav;