home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / windows3 / mtlabsnd.zip / WRITEWAV.M < prev   
Text File  |  1993-04-26  |  1KB  |  41 lines

  1. function writewav(filename,variable,samplerate,datasize)
  2.  
  3. % writewav(filename,variable,samplerate,datasize)
  4. %   
  5. %       Writes a Windows 3.1 WAV type file for the given variable
  6. %       and filename.  Assumes the variable is column-major and
  7. %       of a single column.
  8. %
  9. a_write_wav = variable;
  10. nwrv = size(variable);
  11. twrv = 1;
  12.  
  13. if nwrv(2) ~= twrv
  14.     if nwrv(1) ~= twrv
  15.         disp(['Bad variable format.  Got ',nwrv(1),' ',nwrv(2),'.'])
  16.     else
  17.        a_write_wav = a_write_wav';
  18.        string = ['save testfoo a_write_wav'];
  19.        eval(string);
  20.        rate=sprintf('%g',samplerate);
  21.        if (datasize == 8)
  22.          string = ['!sox -b -r ' rate ' testfoo.mat ' filename '.wav'];
  23.        else
  24.          string = ['!sox -w -r ' rate ' testfoo.mat ' filename '.wav'];
  25.        end;
  26.        eval(string);
  27.     end
  28. else
  29.        string = ['save testfoo a_write_wav'];
  30.        eval(string);
  31.        rate=sprintf('%g',samplerate);
  32.        if (datasize == 8)
  33.          string = ['!sox -b -r ' rate ' testfoo.mat ' filename '.wav'];
  34.       else
  35.          string = ['!sox -w -r ' rate ' testfoo.mat ' filename '.wav'];
  36.        end;
  37.        eval(string);
  38. end
  39. clear a_write_wav;
  40.  
  41.