Move the direct and send params into separate different types
[openal-soft/openal-hmr.git] / OpenAL32 / Include / alSource.h
blob53286a03d844d016a7b06aa19b32cb757e38f0cf
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 ALfloat History[MAXCHANNELS][SRC_HISTORY_LENGTH];
35 ALfloat Values[MAXCHANNELS][HRIR_LENGTH][2];
36 ALuint Offset;
37 } HrtfState;
39 typedef struct HrtfParams {
40 ALfloat Gain;
41 ALfloat Dir[3];
42 ALfloat Coeffs[MAXCHANNELS][HRIR_LENGTH][2];
43 ALuint Delay[MAXCHANNELS][2];
44 ALfloat CoeffStep[HRIR_LENGTH][2];
45 ALint DelayStep[2];
46 } HrtfParams;
48 typedef struct DirectParams {
49 /* A mixing matrix. First subscript is the channel number of the input data
50 * (regardless of channel configuration) and the second is the channel
51 * target (eg. FRONT_LEFT). */
52 ALfloat Gains[MAXCHANNELS][MAXCHANNELS];
54 /* A low-pass filter, using 2 chained one-pole filters. */
55 FILTER iirFilter;
56 ALfloat history[MAXCHANNELS*2];
57 } DirectParams;
59 typedef struct SendParams {
60 /* Gain control, which applies to all input channels to a single (mono)
61 * output buffer. */
62 ALfloat Gain;
64 /* A low-pass filter, using a one-pole filter. */
65 FILTER iirFilter;
66 ALfloat history[MAXCHANNELS];
67 } SendParams;
70 typedef struct ALsource
72 /** Source properties. */
73 volatile ALfloat Pitch;
74 volatile ALfloat Gain;
75 volatile ALfloat OuterGain;
76 volatile ALfloat MinGain;
77 volatile ALfloat MaxGain;
78 volatile ALfloat InnerAngle;
79 volatile ALfloat OuterAngle;
80 volatile ALfloat RefDistance;
81 volatile ALfloat MaxDistance;
82 volatile ALfloat RollOffFactor;
83 volatile ALfloat Position[3];
84 volatile ALfloat Velocity[3];
85 volatile ALfloat Orientation[3];
86 volatile ALboolean HeadRelative;
87 volatile ALboolean Looping;
88 volatile enum DistanceModel DistanceModel;
89 volatile ALboolean DirectChannels;
91 volatile ALboolean DryGainHFAuto;
92 volatile ALboolean WetGainAuto;
93 volatile ALboolean WetGainHFAuto;
94 volatile ALfloat OuterGainHF;
96 volatile ALfloat AirAbsorptionFactor;
97 volatile ALfloat RoomRolloffFactor;
98 volatile ALfloat DopplerFactor;
100 enum Resampler Resampler;
103 * Last user-specified offset, and the offset type (bytes, samples, or
104 * seconds).
106 ALdouble Offset;
107 ALenum OffsetType;
109 /** Source type (static, streaming, or undetermined) */
110 volatile ALint SourceType;
112 /** Source state (initial, playing, paused, or stopped) */
113 volatile ALenum state;
114 ALenum new_state;
117 * Source offset in samples, relative to the currently playing buffer, NOT
118 * the whole queue, and the fractional (fixed-point) offset to the next
119 * sample.
121 ALuint position;
122 ALuint position_fraction;
124 /** Source Buffer Queue info. */
125 ALbufferlistitem *queue;
126 ALuint BuffersInQueue;
127 ALuint BuffersPlayed;
129 /** Current buffer sample info. */
130 ALuint NumChannels;
131 ALuint SampleSize;
133 /** Direct filter and auxiliary send info. */
134 ALfloat DirectGain;
135 ALfloat DirectGainHF;
137 struct {
138 struct ALeffectslot *Slot;
139 ALfloat Gain;
140 ALfloat GainHF;
141 } Send[MAX_SENDS];
143 /** HRTF info. */
144 HrtfState Hrtf;
146 /** Current target parameters used for mixing. */
147 struct {
148 DryMixerFunc DryMix;
149 WetMixerFunc WetMix;
151 ALint Step;
153 HrtfParams Hrtf;
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