home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / windows3 / mtlabsnd.zip / README.1ST < prev    next >
Text File  |  1993-04-26  |  4KB  |  79 lines

  1. This .ZIP file contains routines to make Matlab/Windows 3.5 and .WAV files
  2. compatible.  The routines were written by George Woyansky
  3. (woyansky@flamingo.ece.cmu.edu) and Kevin Bradley (kb35@andrew.cmu.edu) at
  4. Carnegie Mellon University for use in a course here and we figured that
  5. they'd be useful to the rest of the world (at least that portion of the
  6. world waiting for Windows 4.0 and its promised sound capabilities).
  7.  
  8. SOUND FILE IMPORT/EXPORT 
  9. ========================
  10. First, to get .WAV files in and out of Matlab, we wrote an extension for the
  11. SOX (SOund eXchange) program to allow SOX to read/write .MAT files directly.
  12. The files needed to allow Matlab to read/write .WAV files are:
  13.  
  14. readwav.m    <-- wrapper around SOX.EXE to read in .WAV file
  15. writewav.m   <-- wrapper around SOX.EXE to write .WAV file from a vector
  16. sox.exe      <-- requires windows; source provided if you want to recompile
  17.                  for DOS (use Borland C++ project file SOX.PRJ)
  18.  
  19. Basically, you can use readwav.m to read any .WAV file into a Matlab vector,
  20. and writewav.m to write out ANY matlab vector as a mono .WAV file.
  21.  
  22. writewav.m requires that you also specify a sampling rate (in Hz) and a data
  23. size - either 8 or 16 bits/sample.  We don't check to ensure that your data
  24. fits within the data size you specify, so make sure before you write your
  25. data to a .WAV file that it's within the range supported by 8 or 16 bits.
  26. Writewav also assumes that the Matlab data is signed - that is, -128 to +127
  27. for 8-bit data and -32768 to +32767 for 16-bit data.  Data points having
  28. nonzero fractional component are rounded to the nearest int.
  29.  
  30. Caveat/cop-out: we only support mono audio read/writes; if you try to read
  31. in a stereo .wav file what you'll get is a vector with the left and right
  32. channel data interleaved, i.e. [left(1);right(1);left(2);right(2)...]
  33.  
  34. SOUND PLAYBACK
  35. ==============
  36. Next, Windows has some fancy playback tools but most require mouse
  37. interaction.  We wanted one that would work from the Matlab command line -
  38. i.e. play('soundfile') from the >> prompt.  Two files implement this
  39. feature:
  40.  
  41. play.m       <-- wrapper around PLAYW.EXE
  42. playw.exe    <-- Windows executable that plays .WAV file specified as its
  43.                  only argument.
  44.  
  45. PLAYW.EXE uses the Borland C++ Windows extensions and essentially plays the
  46. .WAV file specified as argv[1].  It does no checking to make sure that the
  47. file is a valid .WAV file, and you must supply the .WAV extension.  You may
  48. supply a path as well when you specify the file.
  49.  
  50.  
  51. Using these routines: a sample scenario
  52. =======================================
  53. Assume that you've got a file called SOUND.WAV.  The commands you could use
  54. from within Matlab (>> omitted for clarity) to manipulate the data in that
  55. file are:
  56.  
  57. soundvect = readwav('SOUND');          % reads from SOUND.WAV into soundvect
  58. linramp = (1:length(soundvect))/length(soundvect);   % Generate a linear ramp
  59. newsound = soundvect.*linramp;         % A fade-in effect
  60. writewav('NEWSOUND',newsound,8000,16); % Write the file at 8kHz, 16 bits/sa
  61. play('NEWSOUND');
  62.  
  63. etc. etc. etc.
  64.  
  65. We hope that you enjoy using these tools.  No guarantee is made as to the
  66. functionality or correctness of the code.  These tools are released to the
  67. public domain.  Any use of these tools for commercial gain is prohibited.
  68. The Free Software Foundation's CopyLeft Policy applies.
  69.  
  70.  
  71. George Woyansky
  72. Kevin Bradley
  73. Carnegie Mellon University
  74. Department of Electrical and Computer Engineering
  75. 5000 Forbes Avenue
  76. Pittsburgh, PA  15213
  77.  
  78. April, 1993
  79.