Store the output buffers in the DirectParams struct
[openal-soft.git] / OpenAL32 / Include / alSource.h
blob8c231d8bfc4664986db4836a70d0b75d4338ce16
1 #ifndef _AL_SOURCE_H_
2 #define _AL_SOURCE_H_
4 #define MAX_SENDS 4
6 #include "alMain.h"
7 #include "alu.h"
8 #include "alFilter.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 HrtfState {
32 ALboolean Moving;
33 ALuint Counter;
34 ALIGN(16) ALfloat History[MaxChannels][SRC_HISTORY_LENGTH];
35 ALIGN(16) ALfloat Values[MaxChannels][HRIR_LENGTH][2];
36 ALuint Offset;
37 } HrtfState;
39 typedef struct HrtfParams {
40 ALfloat Gain;
41 ALfloat Dir[3];
42 ALIGN(16) ALfloat Coeffs[MaxChannels][HRIR_LENGTH][2];
43 ALIGN(16) ALfloat CoeffStep[HRIR_LENGTH][2];
44 ALuint Delay[MaxChannels][2];
45 ALint DelayStep[2];
46 ALuint IrSize;
47 } HrtfParams;
49 typedef struct DirectParams {
50 ALfloat (*OutBuffer)[BUFFERSIZE];
51 ALfloat *ClickRemoval;
52 ALfloat *PendingClicks;
54 HrtfParams Hrtf;
55 HrtfState *hrtfState;
57 /* A mixing matrix. First subscript is the channel number of the input data
58 * (regardless of channel configuration) and the second is the channel
59 * target (eg. FrontLeft). Not used with HRTF. */
60 ALfloat Gains[MaxChannels][MaxChannels];
62 /* A low-pass filter, using 2 chained one-pole filters. */
63 FILTER iirFilter;
64 ALfloat history[MaxChannels*2];
65 } DirectParams;
67 typedef struct SendParams {
68 struct ALeffectslot *Slot;
70 /* Gain control, which applies to all input channels to a single (mono)
71 * output buffer. */
72 ALfloat Gain;
74 /* A low-pass filter, using 2 chained one-pole filters. */
75 FILTER iirFilter;
76 ALfloat history[MaxChannels*2];
77 } SendParams;
80 typedef struct ALsource
82 /** Source properties. */
83 volatile ALfloat Pitch;
84 volatile ALfloat Gain;
85 volatile ALfloat OuterGain;
86 volatile ALfloat MinGain;
87 volatile ALfloat MaxGain;
88 volatile ALfloat InnerAngle;
89 volatile ALfloat OuterAngle;
90 volatile ALfloat RefDistance;
91 volatile ALfloat MaxDistance;
92 volatile ALfloat RollOffFactor;
93 volatile ALfloat Position[3];
94 volatile ALfloat Velocity[3];
95 volatile ALfloat Orientation[3];
96 volatile ALboolean HeadRelative;
97 volatile ALboolean Looping;
98 volatile enum DistanceModel DistanceModel;
99 volatile ALboolean DirectChannels;
101 volatile ALboolean DryGainHFAuto;
102 volatile ALboolean WetGainAuto;
103 volatile ALboolean WetGainHFAuto;
104 volatile ALfloat OuterGainHF;
106 volatile ALfloat AirAbsorptionFactor;
107 volatile ALfloat RoomRolloffFactor;
108 volatile ALfloat DopplerFactor;
110 enum Resampler Resampler;
113 * Last user-specified offset, and the offset type (bytes, samples, or
114 * seconds).
116 ALdouble Offset;
117 ALenum OffsetType;
119 /** Source type (static, streaming, or undetermined) */
120 volatile ALint SourceType;
122 /** Source state (initial, playing, paused, or stopped) */
123 volatile ALenum state;
124 ALenum new_state;
127 * Source offset in samples, relative to the currently playing buffer, NOT
128 * the whole queue, and the fractional (fixed-point) offset to the next
129 * sample.
131 ALuint position;
132 ALuint position_fraction;
134 /** Source Buffer Queue info. */
135 ALbufferlistitem *queue;
136 ALuint BuffersInQueue;
137 ALuint BuffersPlayed;
139 /** Current buffer sample info. */
140 ALuint NumChannels;
141 ALuint SampleSize;
143 /** Direct filter and auxiliary send info. */
144 ALfloat DirectGain;
145 ALfloat DirectGainHF;
147 struct {
148 struct ALeffectslot *Slot;
149 ALfloat Gain;
150 ALfloat GainHF;
151 } Send[MAX_SENDS];
153 /** HRTF info. */
154 HrtfState Hrtf;
156 /** Current target parameters used for mixing. */
157 struct {
158 ResamplerFunc Resample;
159 DryMixerFunc DryMix;
160 WetMixerFunc WetMix;
162 ALint Step;
164 DirectParams Direct;
166 SendParams Send[MAX_SENDS];
167 } Params;
168 /** Source needs to update its mixing parameters. */
169 volatile ALenum NeedsUpdate;
171 /** Method to update mixing parameters. */
172 ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
174 /** Self ID */
175 ALuint id;
176 } ALsource;
177 #define ALsource_Update(s,a) ((s)->Update(s,a))
179 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
180 ALboolean ApplyOffset(ALsource *Source);
182 ALvoid ReleaseALSources(ALCcontext *Context);
184 #ifdef __cplusplus
186 #endif
188 #endif