XA2_SoundSample.h (4287B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 #ifndef __XA2_SOUNDSAMPLE_H__ 29 #define __XA2_SOUNDSAMPLE_H__ 30 31 /* 32 ================================================ 33 idSoundSample_XAudio2 34 ================================================ 35 */ 36 class idSampleInfo; 37 class idSoundSample_XAudio2 { 38 public: 39 idSoundSample_XAudio2(); 40 41 // Loads and initializes the resource based on the name. 42 virtual void LoadResource(); 43 44 void SetName( const char * n ) { name = n; } 45 const char * GetName() const { return name; } 46 ID_TIME_T GetTimestamp() const { return timestamp; } 47 48 // turns it into a beep 49 void MakeDefault(); 50 51 // frees all data 52 void FreeData(); 53 54 int LengthInMsec() const { return SamplesToMsec( NumSamples(), SampleRate() ); } 55 int SampleRate() const { return format.basic.samplesPerSec; } 56 int NumSamples() const { return playLength; } 57 int NumChannels() const { return format.basic.numChannels; } 58 int BufferSize() const { return totalBufferSize; } 59 60 bool IsCompressed() const { return ( format.basic.formatTag != idWaveFile::FORMAT_PCM ); } 61 62 bool IsDefault() const { return timestamp == FILE_NOT_FOUND_TIMESTAMP; } 63 bool IsLoaded() const { return loaded; } 64 65 void SetNeverPurge() { neverPurge = true; } 66 bool GetNeverPurge() const { return neverPurge; } 67 68 void SetLevelLoadReferenced() { levelLoadReferenced = true; } 69 void ResetLevelLoadReferenced() { levelLoadReferenced = false; } 70 bool GetLevelLoadReferenced() const { return levelLoadReferenced; } 71 72 int GetLastPlayedTime() const { return lastPlayedTime; } 73 void SetLastPlayedTime( int t ) { lastPlayedTime = t; } 74 75 float GetAmplitude( int timeMS ) const; 76 77 protected: 78 friend class idSoundHardware_XAudio2; 79 friend class idSoundVoice_XAudio2; 80 81 ~idSoundSample_XAudio2(); 82 83 bool LoadWav( const idStr & name ); 84 bool LoadAmplitude( const idStr & name ); 85 void WriteAllSamples( const idStr &sampleName ); 86 bool LoadGeneratedSample( const idStr &name ); 87 void WriteGeneratedSample( idFile *fileOut ); 88 89 struct sampleBuffer_t { 90 void * buffer; 91 int bufferSize; 92 int numSamples; 93 }; 94 95 idStr name; 96 97 ID_TIME_T timestamp; 98 bool loaded; 99 100 bool neverPurge; 101 bool levelLoadReferenced; 102 bool usesMapHeap; 103 104 uint32 lastPlayedTime; 105 106 int totalBufferSize; // total size of all the buffers 107 idList<sampleBuffer_t, TAG_AUDIO> buffers; 108 109 int playBegin; 110 int playLength; 111 112 idWaveFile::waveFmt_t format; 113 114 idList<byte, TAG_AMPLITUDE> amplitude; 115 }; 116 117 /* 118 ================================================ 119 idSoundSample 120 121 This reverse-inheritance purportedly makes working on 122 multiple platforms easier. 123 ================================================ 124 */ 125 class idSoundSample : public idSoundSample_XAudio2 { 126 public: 127 }; 128 129 #endif