Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

WAV.h

Go to the documentation of this file.
00001 /*! @file
00002  * @brief Allows you to load WAV files from the memory stick
00003  * @author Sony (Creator)
00004  *
00005  * This file is from the SoundPlay example from the Sony sample code, with a few if any modifications.
00006  * Here's the license Sony provided with it:
00007  *
00008  * Copyright 2002,2003 Sony Corporation 
00009  *
00010  * Permission to use, copy, modify, and redistribute this software for
00011  * non-commercial use is hereby granted.
00012  *
00013  * This software is provided "as is" without warranty of any kind,
00014  * either expressed or implied, including but not limited to the
00015  * implied warranties of fitness for a particular purpose.
00016  *
00017  * $Author: ejt $
00018  * $Name: tekkotsu-2_4_1 $
00019  * $Revision: 1.2 $
00020  * $State: Exp $
00021  * $Date: 2005/06/01 05:47:54 $
00022  */
00023 
00024 #ifndef WAV_h_DEFINED
00025 #define WAV_h_DEFINED
00026 
00027 #include "Shared/ODataFormats.h"
00028 
00029 enum WAVError {
00030     WAV_SUCCESS,
00031     WAV_FAIL,
00032     WAV_NOT_RIFF,
00033     WAV_NOT_WAV,
00034     WAV_FORMAT_NOT_SUPPORTED,
00035     WAV_CHANNEL_NOT_SUPPORTED,
00036     WAV_SAMPLINGRATE_NOT_SUPPORTED,
00037     WAV_BITSPERSAMPLE_NOT_SUPPORTED,
00038     WAV_SIZE_NOT_ENOUGH,
00039 };
00040 
00041 class WAV {
00042 public:
00043     WAV();
00044     WAV(byte* addr);
00045     ~WAV() {}
00046 
00047     WAVError Set(byte *addr);
00048     WAVError CopyTo(OSoundVectorData* data);
00049     WAVError Rewind();
00050 
00051     unsigned int    GetSamplingRate()  { return soundInfo.samplingRate;  }
00052     unsigned int    GetBitsPerSample() { return soundInfo.bitsPerSample; }
00053     size_t GetSoundUnitSize() { return soundUnitSize;           }
00054     
00055     byte*  GetDataStart()     { return dataStart;               }
00056     byte*  GetDataEnd()       { return dataEnd;                 }
00057 
00058 private:
00059     longword get_longword(byte* addr);
00060     word     get_word(byte* addr);
00061 
00062     // 8KHz 8bits MONO (8 * 1 * 1 * 32ms = 256)
00063     static const size_t MONO8K8B_UNIT_SIZE  = 256;
00064 
00065     // 16KHz 16bits MONO (16 * 2 * 1 * 32ms = 1024)
00066     static const size_t MONO16K16B_UNIT_SIZE  = 1024;
00067 
00068     static const size_t FMTSIZE_WITHOUT_EXTINFO = 16;
00069 
00070     OSoundInfo soundInfo;
00071     size_t     soundUnitSize;
00072     byte*      dataStart;
00073     byte*      dataEnd;
00074     byte*      dataCurrent;
00075 
00076     WAV(const WAV&); //!< don't call
00077     WAV& operator=(const WAV&); //!< don't call
00078 };
00079 
00080 #endif // WAV_h_DEFINED

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:49 2005 by Doxygen 1.4.4