Tekkotsu 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 
00018 #ifndef WAV_h_DEFINED
00019 #define WAV_h_DEFINED
00020 
00021 #include "Shared/ODataFormats.h"
00022 
00023 enum WAVError {
00024     WAV_SUCCESS,
00025     WAV_FAIL,
00026     WAV_NOT_RIFF,
00027     WAV_NOT_WAV,
00028     WAV_FORMAT_NOT_SUPPORTED,
00029     WAV_CHANNEL_NOT_SUPPORTED,
00030     WAV_SAMPLINGRATE_NOT_SUPPORTED,
00031     WAV_BITSPERSAMPLE_NOT_SUPPORTED,
00032     WAV_SIZE_NOT_ENOUGH,
00033 };
00034 
00035 class WAV {
00036 public:
00037     WAV();
00038     WAV(byte* addr);
00039     ~WAV() {}
00040 
00041     WAVError Set(byte *addr);
00042     WAVError CopyTo(OSoundVectorData* data);
00043     WAVError Rewind();
00044 
00045     unsigned int    GetSamplingRate()  { return soundInfo.samplingRate;  }
00046     unsigned int    GetBitsPerSample() { return soundInfo.bitsPerSample; }
00047     size_t GetSoundUnitSize() { return soundUnitSize;           }
00048     
00049     byte*  GetDataStart()     { return dataStart;               }
00050     byte*  GetDataEnd()       { return dataEnd;                 }
00051 
00052 private:
00053     longword get_longword(byte* addr);
00054     word     get_word(byte* addr);
00055 
00056     // 8KHz 8bits MONO (8 * 1 * 1 * 32ms = 256)
00057     static const size_t MONO8K8B_UNIT_SIZE  = 256;
00058 
00059     // 16KHz 16bits MONO (16 * 2 * 1 * 32ms = 1024)
00060     static const size_t MONO16K16B_UNIT_SIZE  = 1024;
00061 
00062     static const size_t FMTSIZE_WITHOUT_EXTINFO = 16;
00063 
00064     OSoundInfo soundInfo;
00065     size_t     soundUnitSize;
00066     byte*      dataStart;
00067     byte*      dataEnd;
00068     byte*      dataCurrent;
00069 
00070     WAV(const WAV&); //!< don't call
00071     WAV& operator=(const WAV&); //!< don't call
00072 };
00073 
00074 #endif // WAV_h_DEFINED

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:52 2016 by Doxygen 1.6.3