home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2003 March / VPR0303A.ISO / AIBO / MoNet / SoundAgent / WAV.h < prev   
C/C++ Source or Header  |  2002-12-19  |  1KB  |  59 lines

  1. //
  2. // Copyright 2002 Sony Corporation 
  3. //
  4. // Permission to use, copy, modify, and redistribute this software for
  5. // non-commercial use is hereby granted.
  6. //
  7. // This software is provided "as is" without warranty of any kind,
  8. // either expressed or implied, including but not limited to the
  9. // implied warranties of fitness for a particular purpose.
  10. //
  11.  
  12. #ifndef WAV_h_DEFINED
  13. #define WAV_h_DEFINED
  14.  
  15. #include <OPENR/ODataFormats.h>
  16.  
  17. enum WAVError {
  18.     WAV_SUCCESS,
  19.     WAV_FAIL,
  20.     WAV_NOT_RIFF,
  21.     WAV_NOT_WAV,
  22.     WAV_FORMAT_NOT_SUPPORTED,
  23.     WAV_CHANNEL_NOT_SUPPORTED,
  24.     WAV_SAMPLINGRATE_NOT_SUPPORTED,
  25.     WAV_BITSPERSAMPLE_NOT_SUPPORTED,
  26.     WAV_SIZE_NOT_ENOUGH,
  27. };
  28.  
  29. class WAV {
  30. public:
  31.     WAV();
  32.     WAV(byte* addr);
  33.     ~WAV() {}
  34.  
  35.     WAVError Set(byte *addr);
  36.     WAVError CopyTo(OSoundVectorData* data);
  37.     WAVError Rewind();
  38.  
  39.     int GetSamplingRate()  { return soundInfo.samplingRate;  }
  40.     int GetBitsPerSample() { return soundInfo.bitsPerSample; }
  41.  
  42. private:
  43.     longword get_longword(byte* addr);
  44.     word     get_word(byte* addr);
  45.  
  46.     //
  47.     // 8KHz 8bits MONO (8 * 1 * 1 * 32 = 256)
  48.     //
  49.     static const size_t SOUND_UNIT_SIZE  = 256; // bytes / 32ms
  50.     static const size_t FMTSIZE_WITHOUT_EXTINFO = 16;
  51.  
  52.     OSoundInfo soundInfo;
  53.     byte*      dataStart;
  54.     byte*      dataEnd;
  55.     byte*      dataCurrent;
  56. };
  57.  
  58. #endif // WAV_h_DEFINED
  59.