SoundVoice.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #ifndef __SOUNDVOICE_H__
  21. #define __SOUNDVOICE_H__
  22. /*
  23. ================================================
  24. idSoundVoice_Base
  25. ================================================
  26. */
  27. class idSoundVoice_Base {
  28. public:
  29. idSoundVoice_Base();
  30. static void InitSurround( int outputChannels, int channelMask );
  31. void CalculateSurround( int srcChannels, float pLevelMatrix[ MAX_CHANNELS_PER_VOICE * MAX_CHANNELS_PER_VOICE ], float scale );
  32. void SetPosition( const idVec3 & p ) { position = p; }
  33. void SetGain( float g ) { gain = g; }
  34. void SetCenterChannel( float c ) { centerChannel = c; }
  35. void SetPitch( float p ) { pitch = p; }
  36. void SetInnerRadius( float r ) { innerRadius = r; }
  37. void SetChannelMask( uint32 mask ) { channelMask = mask; }
  38. const idSoundSample * GetCurrentSample();
  39. // Controls the low pass filter, where 0.0f = no filtering, 1.0f = full filter
  40. void SetOcclusion( float f ) { occlusion = f; }
  41. float GetGain() { return gain; }
  42. float GetPitch() { return pitch; }
  43. protected:
  44. idVec3 position; // Position of the sound relative to listener
  45. float gain; // Volume (0-1)
  46. float centerChannel; // Value (0-1) which indicates how much of this voice goes to the center channel
  47. float pitch; // Pitch multiplier
  48. float innerRadius; // Anything closer than this is omni
  49. float occlusion; // How much of this sound is occluded (0-1)
  50. uint32 channelMask; // Set to override the default channel mask
  51. // These are some setting used to do SSF_DISTANCE_BASED_STERO blending
  52. float innerSampleRangeSqr;
  53. float outerSampleRangeSqr;
  54. idList< idSoundSample *, TAG_AUDIO> samples;
  55. // These are constants which are initialized with InitSurround
  56. //-------------------------------------------------------------
  57. static idVec2 speakerPositions[idWaveFile::CHANNEL_INDEX_MAX];
  58. // This is to figure out which speakers are "next to" this one
  59. static int speakerLeft[idWaveFile::CHANNEL_INDEX_MAX];
  60. static int speakerRight[idWaveFile::CHANNEL_INDEX_MAX];
  61. // Number of channels in the output hardware
  62. static int dstChannels;
  63. // Mask indicating which speakers exist in the hardware configuration
  64. static int dstMask;
  65. // dstMap maps a destination channel to a speaker
  66. // invMap maps a speaker to a destination channel
  67. static int dstCenter;
  68. static int dstLFE;
  69. static int dstMap[MAX_CHANNELS_PER_VOICE];
  70. static int invMap[idWaveFile::CHANNEL_INDEX_MAX];
  71. // specifies what volume to specify for each channel when a speaker is omni
  72. static float omniLevel;
  73. };
  74. #endif