sfxWavStream.h
Engine/source/sfx/media/sfxWavStream.h
Classes:
class
An SFXFileStream that loads sample data from a WAV file.
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _SFXWAVSTREAM_H_ 25#define _SFXWAVSTREAM_H_ 26 27#ifndef _SFXFILESTREAM_H_ 28 #include "sfx/sfxFileStream.h" 29#endif 30#include "core/util/safeDelete.h" 31 32 33/// An SFXFileStream that loads sample data from a WAV file. 34class SFXWavStream : public SFXFileStream, 35 public IPositionable< U32 > 36{ 37 public: 38 39 typedef SFXFileStream Parent; 40 41 protected: 42 43 /// The file position of the start of 44 /// the PCM data for fast reset(). 45 U32 mDataStart; 46 47 // SFXFileStream 48 virtual bool _readHeader(); 49 virtual void _close(); 50 51 public: 52 53 /// 54 static SFXWavStream* create( Stream *stream ); 55 56 /// 57 SFXWavStream(); 58 59 /// 60 SFXWavStream( const SFXWavStream& cloneFrom ); 61 62 /// Destructor. 63 virtual ~SFXWavStream(); 64 65 // SFXStream 66 virtual void reset(); 67 virtual U32 read( U8 *buffer, U32 length ); 68 virtual SFXStream* clone() const 69 { 70 SFXWavStream* stream = new SFXWavStream( *this ); 71 if( !stream->mStream ) 72 SAFE_DELETE( stream ); 73 return stream; 74 } 75 76 // IPositionable 77 virtual U32 getPosition() const; 78 virtual void setPosition( U32 offset ); 79}; 80 81#endif // _SFXWAVSTREAM_H_ 82