home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SOUNDS.DI$ / AUREAD.M next >
Encoding:
Text File  |  1993-03-07  |  872 b   |  26 lines

  1. function y = auread(name)
  2. %AUREAD    Read mu-law encoded audio file.
  3. %    Y = AUREAD('filename') reads the audio file in 'filename'
  4. %    and converts the data from mu-law encoded bytes to a signal
  5. %    in the range -1 <= Y <= 1.
  6.  
  7. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  8.  
  9. % The data samples processed by the audio device  are  encoded
  10. % in  8  bits.  The high-order bit is a sign bit: 1 represents
  11. % positive data and 0 represents negative data.  The low-order
  12. % 7 bits represent signal magnitude and are inverted (1's com-
  13. % plement).  The magnitude is encoded  according  to  a mu-law
  14. % transfer  function;   such  an encoding provides an improved
  15. % signal-to-noise ratio at low amplitude levels.
  16.  
  17. fp = fopen(name,'rb');
  18. [mu,len] = fread(fp,inf,'uchar');
  19. fclose(fp);
  20.  
  21. % Strip off file header
  22. k = max(find(mu(1:64)==0));
  23. mu(1:k) = [];
  24.  
  25. y = mu2lin(mu);
  26.