Use separate methods for the dry and wet mixing loops
[openal-soft/openal-hmr.git] / OpenAL32 / Include / alSource.h
blobbadf4e18dda0bc321e5b7ae7fc6edf085bacc34f
1 #ifndef _AL_SOURCE_H_
2 #define _AL_SOURCE_H_
4 #define MAX_SENDS 4
6 #include "alFilter.h"
7 #include "alu.h"
8 #include "AL/al.h"
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
14 #define SRC_HISTORY_BITS (6)
15 #define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS)
16 #define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1)
18 extern enum Resampler DefaultResampler;
20 extern const ALsizei ResamplerPadding[ResamplerMax];
21 extern const ALsizei ResamplerPrePadding[ResamplerMax];
24 typedef struct ALbufferlistitem
26 struct ALbuffer *buffer;
27 struct ALbufferlistitem *next;
28 struct ALbufferlistitem *prev;
29 } ALbufferlistitem;
31 typedef struct HrtfParams {
32 ALfloat Gain;
33 ALfloat Dir[3];
34 ALfloat Coeffs[MAXCHANNELS][HRIR_LENGTH][2];
35 ALuint Delay[MAXCHANNELS][2];
36 ALfloat CoeffStep[HRIR_LENGTH][2];
37 ALint DelayStep[2];
38 } HrtfParams;
40 typedef struct HrtfState {
41 ALboolean Moving;
42 ALuint Counter;
43 ALfloat History[MAXCHANNELS][SRC_HISTORY_LENGTH];
44 ALfloat Values[MAXCHANNELS][HRIR_LENGTH][2];
45 ALuint Offset;
46 } HrtfState;
48 typedef struct ALsource
50 /** Source properties. */
51 volatile ALfloat Pitch;
52 volatile ALfloat Gain;
53 volatile ALfloat OuterGain;
54 volatile ALfloat MinGain;
55 volatile ALfloat MaxGain;
56 volatile ALfloat InnerAngle;
57 volatile ALfloat OuterAngle;
58 volatile ALfloat RefDistance;
59 volatile ALfloat MaxDistance;
60 volatile ALfloat RollOffFactor;
61 volatile ALfloat Position[3];
62 volatile ALfloat Velocity[3];
63 volatile ALfloat Orientation[3];
64 volatile ALboolean HeadRelative;
65 volatile ALboolean Looping;
66 volatile enum DistanceModel DistanceModel;
67 volatile ALboolean DirectChannels;
69 volatile ALboolean DryGainHFAuto;
70 volatile ALboolean WetGainAuto;
71 volatile ALboolean WetGainHFAuto;
72 volatile ALfloat OuterGainHF;
74 volatile ALfloat AirAbsorptionFactor;
75 volatile ALfloat RoomRolloffFactor;
76 volatile ALfloat DopplerFactor;
78 enum Resampler Resampler;
80 /**
81 * Last user-specified offset, and the offset type (bytes, samples, or
82 * seconds).
84 ALdouble Offset;
85 ALenum OffsetType;
87 /** Source type (static, streaming, or undetermined) */
88 volatile ALint SourceType;
90 /** Source state (initial, playing, paused, or stopped) */
91 volatile ALenum state;
92 ALenum new_state;
94 /**
95 * Source offset in samples, relative to the currently playing buffer, NOT
96 * the whole queue, and the fractional (fixed-point) offset to the next
97 * sample.
99 ALuint position;
100 ALuint position_fraction;
102 /** Source Buffer Queue info. */
103 ALbufferlistitem *queue;
104 ALuint BuffersInQueue;
105 ALuint BuffersPlayed;
107 /** Current buffer sample info. */
108 ALuint NumChannels;
109 ALuint SampleSize;
111 /** Direct filter and auxiliary send info. */
112 ALfloat DirectGain;
113 ALfloat DirectGainHF;
115 struct {
116 struct ALeffectslot *Slot;
117 ALfloat Gain;
118 ALfloat GainHF;
119 } Send[MAX_SENDS];
121 /** HRTF info. */
122 HrtfState Hrtf;
124 /** Current target parameters used for mixing. */
125 struct {
126 DryMixerFunc DryMix;
127 WetMixerFunc WetMix;
129 ALint Step;
131 HrtfParams Hrtf;
133 struct {
134 /* A mixing matrix. First subscript is the channel number of the
135 * input data (regardless of channel configuration) and the second
136 * is the channel target (eg. FRONT_LEFT). */
137 ALfloat Gains[MAXCHANNELS][MAXCHANNELS];
139 FILTER iirFilter;
140 ALfloat history[MAXCHANNELS*2];
141 } Direct;
143 struct {
144 struct ALeffectslot *Slot;
145 ALfloat Gain;
146 FILTER iirFilter;
147 ALfloat history[MAXCHANNELS];
148 } Send[MAX_SENDS];
149 } Params;
150 /** Source needs to update its mixing parameters. */
151 volatile ALenum NeedsUpdate;
153 /** Method to update mixing parameters. */
154 ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
156 /** Self ID */
157 ALuint id;
158 } ALsource;
159 #define ALsource_Update(s,a) ((s)->Update(s,a))
161 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
162 ALboolean ApplyOffset(ALsource *Source);
164 ALvoid ReleaseALSources(ALCcontext *Context);
166 #ifdef __cplusplus
168 #endif
170 #endif