alSource.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _AL_SOURCE_H_
  2. #define _AL_SOURCE_H_
  3. #define MAX_SENDS 4
  4. #include "alFilter.h"
  5. #include "alu.h"
  6. #include "AL/al.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define SRC_HISTORY_BITS (6)
  11. #define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS)
  12. #define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1)
  13. extern enum Resampler DefaultResampler;
  14. extern const ALsizei ResamplerPadding[ResamplerMax];
  15. extern const ALsizei ResamplerPrePadding[ResamplerMax];
  16. typedef struct ALbufferlistitem
  17. {
  18. struct ALbuffer *buffer;
  19. struct ALbufferlistitem *next;
  20. struct ALbufferlistitem *prev;
  21. } ALbufferlistitem;
  22. typedef struct ALsource
  23. {
  24. volatile ALfloat flPitch;
  25. volatile ALfloat flGain;
  26. volatile ALfloat flOuterGain;
  27. volatile ALfloat flMinGain;
  28. volatile ALfloat flMaxGain;
  29. volatile ALfloat flInnerAngle;
  30. volatile ALfloat flOuterAngle;
  31. volatile ALfloat flRefDistance;
  32. volatile ALfloat flMaxDistance;
  33. volatile ALfloat flRollOffFactor;
  34. volatile ALfloat vPosition[3];
  35. volatile ALfloat vVelocity[3];
  36. volatile ALfloat vOrientation[3];
  37. volatile ALboolean bHeadRelative;
  38. volatile ALboolean bLooping;
  39. volatile enum DistanceModel DistanceModel;
  40. volatile ALboolean DirectChannels;
  41. enum Resampler Resampler;
  42. volatile ALenum state;
  43. ALenum new_state;
  44. ALuint position;
  45. ALuint position_fraction;
  46. ALbufferlistitem *queue; // Linked list of buffers in queue
  47. ALuint BuffersInQueue; // Number of buffers in queue
  48. ALuint BuffersPlayed; // Number of buffers played on this loop
  49. ALfloat DirectGain;
  50. ALfloat DirectGainHF;
  51. struct {
  52. struct ALeffectslot *Slot;
  53. ALfloat WetGain;
  54. ALfloat WetGainHF;
  55. } Send[MAX_SENDS];
  56. volatile ALboolean DryGainHFAuto;
  57. volatile ALboolean WetGainAuto;
  58. volatile ALboolean WetGainHFAuto;
  59. volatile ALfloat OuterGainHF;
  60. volatile ALfloat AirAbsorptionFactor;
  61. volatile ALfloat RoomRolloffFactor;
  62. volatile ALfloat DopplerFactor;
  63. ALint lOffset;
  64. ALint lOffsetType;
  65. // Source Type (Static, Streaming, or Undetermined)
  66. volatile ALint lSourceType;
  67. ALuint NumChannels;
  68. ALuint SampleSize;
  69. /* HRTF info */
  70. ALboolean HrtfMoving;
  71. ALuint HrtfCounter;
  72. ALfloat HrtfHistory[MAXCHANNELS][SRC_HISTORY_LENGTH];
  73. ALfloat HrtfValues[MAXCHANNELS][HRIR_LENGTH][2];
  74. ALuint HrtfOffset;
  75. /* Current target parameters used for mixing */
  76. struct {
  77. MixerFunc DoMix;
  78. ALint Step;
  79. ALfloat HrtfGain;
  80. ALfloat HrtfDir[3];
  81. ALfloat HrtfCoeffs[MAXCHANNELS][HRIR_LENGTH][2];
  82. ALuint HrtfDelay[MAXCHANNELS][2];
  83. ALfloat HrtfCoeffStep[HRIR_LENGTH][2];
  84. ALint HrtfDelayStep[2];
  85. /* A mixing matrix. First subscript is the channel number of the input
  86. * data (regardless of channel configuration) and the second is the
  87. * channel target (eg. FRONT_LEFT) */
  88. ALfloat DryGains[MAXCHANNELS][MAXCHANNELS];
  89. FILTER iirFilter;
  90. ALfloat history[MAXCHANNELS*2];
  91. struct {
  92. struct ALeffectslot *Slot;
  93. ALfloat WetGain;
  94. FILTER iirFilter;
  95. ALfloat history[MAXCHANNELS];
  96. } Send[MAX_SENDS];
  97. } Params;
  98. volatile ALenum NeedsUpdate;
  99. ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
  100. // Index to itself
  101. ALuint source;
  102. } ALsource;
  103. #define ALsource_Update(s,a) ((s)->Update(s,a))
  104. ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
  105. ALboolean ApplyOffset(ALsource *Source);
  106. ALvoid ReleaseALSources(ALCcontext *Context);
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif