Move the target effect slot to the SendParams struct
[openal-soft.git] / OpenAL32 / Include / alSource.h
blobace0b5b504f99c51c34e3df0057fcf24daf5c591
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 struct ALeffectslot *Slot;
64 /* Gain control, which applies to all input channels to a single (mono)
65 * output buffer. */
66 ALfloat Gain;
68 /* A low-pass filter, using 2 chained one-pole filters. */
69 FILTER iirFilter;
70 ALfloat history[MaxChannels*2];
71 } SendParams;
74 typedef struct ALsource
76 /** Source properties. */
77 volatile ALfloat Pitch;
78 volatile ALfloat Gain;
79 volatile ALfloat OuterGain;
80 volatile ALfloat MinGain;
81 volatile ALfloat MaxGain;
82 volatile ALfloat InnerAngle;
83 volatile ALfloat OuterAngle;
84 volatile ALfloat RefDistance;
85 volatile ALfloat MaxDistance;
86 volatile ALfloat RollOffFactor;
87 volatile ALfloat Position[3];
88 volatile ALfloat Velocity[3];
89 volatile ALfloat Orientation[3];
90 volatile ALboolean HeadRelative;
91 volatile ALboolean Looping;
92 volatile enum DistanceModel DistanceModel;
93 volatile ALboolean DirectChannels;
95 volatile ALboolean DryGainHFAuto;
96 volatile ALboolean WetGainAuto;
97 volatile ALboolean WetGainHFAuto;
98 volatile ALfloat OuterGainHF;
100 volatile ALfloat AirAbsorptionFactor;
101 volatile ALfloat RoomRolloffFactor;
102 volatile ALfloat DopplerFactor;
104 enum Resampler Resampler;
107 * Last user-specified offset, and the offset type (bytes, samples, or
108 * seconds).
110 ALdouble Offset;
111 ALenum OffsetType;
113 /** Source type (static, streaming, or undetermined) */
114 volatile ALint SourceType;
116 /** Source state (initial, playing, paused, or stopped) */
117 volatile ALenum state;
118 ALenum new_state;
121 * Source offset in samples, relative to the currently playing buffer, NOT
122 * the whole queue, and the fractional (fixed-point) offset to the next
123 * sample.
125 ALuint position;
126 ALuint position_fraction;
128 /** Source Buffer Queue info. */
129 ALbufferlistitem *queue;
130 ALuint BuffersInQueue;
131 ALuint BuffersPlayed;
133 /** Current buffer sample info. */
134 ALuint NumChannels;
135 ALuint SampleSize;
137 /** Direct filter and auxiliary send info. */
138 ALfloat DirectGain;
139 ALfloat DirectGainHF;
141 struct {
142 struct ALeffectslot *Slot;
143 ALfloat Gain;
144 ALfloat GainHF;
145 } Send[MAX_SENDS];
147 /** HRTF info. */
148 HrtfState Hrtf;
150 /** Current target parameters used for mixing. */
151 struct {
152 DryMixerFunc DryMix;
153 WetMixerFunc WetMix;
155 ALint Step;
157 DirectParams Direct;
159 SendParams Send[MAX_SENDS];
160 } Params;
161 /** Source needs to update its mixing parameters. */
162 volatile ALenum NeedsUpdate;
164 /** Method to update mixing parameters. */
165 ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
167 /** Self ID */
168 ALuint id;
169 } ALsource;
170 #define ALsource_Update(s,a) ((s)->Update(s,a))
172 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
173 ALboolean ApplyOffset(ALsource *Source);
175 ALvoid ReleaseALSources(ALCcontext *Context);
177 #ifdef __cplusplus
179 #endif
181 #endif