Place the alignment attribute before the variable declaration
[openal-soft/openal-hmr.git] / OpenAL32 / Include / alSource.h
blob0d9ac9f1cb4dc6344f5983511507cc0a775a1ba8
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 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 } HrtfParams;
48 typedef struct DirectParams {
49 HrtfParams Hrtf;
51 /* A mixing matrix. First subscript is the channel number of the input data
52 * (regardless of channel configuration) and the second is the channel
53 * target (eg. FrontLeft). Not used with HRTF. */
54 ALfloat Gains[MaxChannels][MaxChannels];
56 /* A low-pass filter, using 2 chained one-pole filters. */
57 FILTER iirFilter;
58 ALfloat history[MaxChannels*2];
59 } DirectParams;
61 typedef struct SendParams {
62 /* Gain control, which applies to all input channels to a single (mono)
63 * output buffer. */
64 ALfloat Gain;
66 /* A low-pass filter, using 2 chained one-pole filters. */
67 FILTER iirFilter;
68 ALfloat history[MaxChannels*2];
69 } SendParams;
72 typedef struct ALsource
74 /** Source properties. */
75 volatile ALfloat Pitch;
76 volatile ALfloat Gain;
77 volatile ALfloat OuterGain;
78 volatile ALfloat MinGain;
79 volatile ALfloat MaxGain;
80 volatile ALfloat InnerAngle;
81 volatile ALfloat OuterAngle;
82 volatile ALfloat RefDistance;
83 volatile ALfloat MaxDistance;
84 volatile ALfloat RollOffFactor;
85 volatile ALfloat Position[3];
86 volatile ALfloat Velocity[3];
87 volatile ALfloat Orientation[3];
88 volatile ALboolean HeadRelative;
89 volatile ALboolean Looping;
90 volatile enum DistanceModel DistanceModel;
91 volatile ALboolean DirectChannels;
93 volatile ALboolean DryGainHFAuto;
94 volatile ALboolean WetGainAuto;
95 volatile ALboolean WetGainHFAuto;
96 volatile ALfloat OuterGainHF;
98 volatile ALfloat AirAbsorptionFactor;
99 volatile ALfloat RoomRolloffFactor;
100 volatile ALfloat DopplerFactor;
102 enum Resampler Resampler;
105 * Last user-specified offset, and the offset type (bytes, samples, or
106 * seconds).
108 ALdouble Offset;
109 ALenum OffsetType;
111 /** Source type (static, streaming, or undetermined) */
112 volatile ALint SourceType;
114 /** Source state (initial, playing, paused, or stopped) */
115 volatile ALenum state;
116 ALenum new_state;
119 * Source offset in samples, relative to the currently playing buffer, NOT
120 * the whole queue, and the fractional (fixed-point) offset to the next
121 * sample.
123 ALuint position;
124 ALuint position_fraction;
126 /** Source Buffer Queue info. */
127 ALbufferlistitem *queue;
128 ALuint BuffersInQueue;
129 ALuint BuffersPlayed;
131 /** Current buffer sample info. */
132 ALuint NumChannels;
133 ALuint SampleSize;
135 /** Direct filter and auxiliary send info. */
136 ALfloat DirectGain;
137 ALfloat DirectGainHF;
139 struct {
140 struct ALeffectslot *Slot;
141 ALfloat Gain;
142 ALfloat GainHF;
143 } Send[MAX_SENDS];
145 /** HRTF info. */
146 HrtfState Hrtf;
148 /** Current target parameters used for mixing. */
149 struct {
150 DryMixerFunc DryMix;
151 WetMixerFunc WetMix;
153 ALint Step;
155 DirectParams Direct;
157 struct ALeffectslot *Slot[MAX_SENDS];
158 SendParams Send[MAX_SENDS];
159 } Params;
160 /** Source needs to update its mixing parameters. */
161 volatile ALenum NeedsUpdate;
163 /** Method to update mixing parameters. */
164 ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
166 /** Self ID */
167 ALuint id;
168 } ALsource;
169 #define ALsource_Update(s,a) ((s)->Update(s,a))
171 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
172 ALboolean ApplyOffset(ALsource *Source);
174 ALvoid ReleaseALSources(ALCcontext *Context);
176 #ifdef __cplusplus
178 #endif
180 #endif