2007-11-14 02:02:18 +00:00
|
|
|
#ifndef _AL_SOURCE_H_
|
|
|
|
#define _AL_SOURCE_H_
|
|
|
|
|
2010-11-06 22:08:54 +00:00
|
|
|
#define MAX_SENDS 4
|
2007-12-19 02:13:49 +00:00
|
|
|
|
2007-12-18 00:28:16 +00:00
|
|
|
#include "alFilter.h"
|
2008-08-14 12:43:52 +00:00
|
|
|
#include "alu.h"
|
2007-11-14 02:02:18 +00:00
|
|
|
#include "AL/al.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-06-17 23:22:39 +00:00
|
|
|
#define SRC_HISTORY_BITS (6)
|
2011-06-03 08:06:00 +00:00
|
|
|
#define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS)
|
|
|
|
#define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1)
|
|
|
|
|
2011-07-03 04:33:53 +00:00
|
|
|
extern enum Resampler DefaultResampler;
|
2010-01-11 13:37:20 +00:00
|
|
|
|
2012-02-12 16:45:19 +00:00
|
|
|
extern const ALsizei ResamplerPadding[ResamplerMax];
|
|
|
|
extern const ALsizei ResamplerPrePadding[ResamplerMax];
|
2010-11-29 01:37:14 +00:00
|
|
|
|
2010-11-26 10:53:15 +00:00
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
typedef struct ALbufferlistitem
|
|
|
|
{
|
2009-10-22 16:31:26 +00:00
|
|
|
struct ALbuffer *buffer;
|
2007-11-14 02:02:18 +00:00
|
|
|
struct ALbufferlistitem *next;
|
2010-11-26 02:30:57 +00:00
|
|
|
struct ALbufferlistitem *prev;
|
2007-11-14 02:02:18 +00:00
|
|
|
} ALbufferlistitem;
|
|
|
|
|
2012-04-28 08:32:52 +00:00
|
|
|
typedef struct HrtfState {
|
|
|
|
ALboolean Moving;
|
|
|
|
ALuint Counter;
|
|
|
|
ALfloat History[MAXCHANNELS][SRC_HISTORY_LENGTH];
|
|
|
|
ALfloat Values[MAXCHANNELS][HRIR_LENGTH][2];
|
|
|
|
ALuint Offset;
|
|
|
|
} HrtfState;
|
|
|
|
|
2012-04-27 07:45:42 +00:00
|
|
|
typedef struct HrtfParams {
|
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat Dir[3];
|
|
|
|
ALfloat Coeffs[MAXCHANNELS][HRIR_LENGTH][2];
|
|
|
|
ALuint Delay[MAXCHANNELS][2];
|
|
|
|
ALfloat CoeffStep[HRIR_LENGTH][2];
|
|
|
|
ALint DelayStep[2];
|
|
|
|
} HrtfParams;
|
|
|
|
|
2012-04-28 08:32:52 +00:00
|
|
|
typedef struct DirectParams {
|
2012-04-28 09:23:53 +00:00
|
|
|
HrtfParams Hrtf;
|
|
|
|
|
2012-04-28 08:32:52 +00:00
|
|
|
/* A mixing matrix. First subscript is the channel number of the input data
|
|
|
|
* (regardless of channel configuration) and the second is the channel
|
2012-04-28 09:23:53 +00:00
|
|
|
* target (eg. FRONT_LEFT). Not used with HRTF. */
|
2012-04-28 08:32:52 +00:00
|
|
|
ALfloat Gains[MAXCHANNELS][MAXCHANNELS];
|
|
|
|
|
|
|
|
/* A low-pass filter, using 2 chained one-pole filters. */
|
|
|
|
FILTER iirFilter;
|
|
|
|
ALfloat history[MAXCHANNELS*2];
|
|
|
|
} DirectParams;
|
|
|
|
|
|
|
|
typedef struct SendParams {
|
|
|
|
/* Gain control, which applies to all input channels to a single (mono)
|
|
|
|
* output buffer. */
|
|
|
|
ALfloat Gain;
|
|
|
|
|
|
|
|
/* A low-pass filter, using a one-pole filter. */
|
|
|
|
FILTER iirFilter;
|
|
|
|
ALfloat history[MAXCHANNELS];
|
|
|
|
} SendParams;
|
|
|
|
|
2012-04-27 07:45:42 +00:00
|
|
|
|
2007-12-31 09:09:21 +00:00
|
|
|
typedef struct ALsource
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Source properties. */
|
2012-04-20 04:46:29 +00:00
|
|
|
volatile ALfloat Pitch;
|
|
|
|
volatile ALfloat Gain;
|
|
|
|
volatile ALfloat OuterGain;
|
|
|
|
volatile ALfloat MinGain;
|
|
|
|
volatile ALfloat MaxGain;
|
|
|
|
volatile ALfloat InnerAngle;
|
|
|
|
volatile ALfloat OuterAngle;
|
|
|
|
volatile ALfloat RefDistance;
|
|
|
|
volatile ALfloat MaxDistance;
|
|
|
|
volatile ALfloat RollOffFactor;
|
|
|
|
volatile ALfloat Position[3];
|
|
|
|
volatile ALfloat Velocity[3];
|
|
|
|
volatile ALfloat Orientation[3];
|
|
|
|
volatile ALboolean HeadRelative;
|
|
|
|
volatile ALboolean Looping;
|
2011-09-11 08:18:57 +00:00
|
|
|
volatile enum DistanceModel DistanceModel;
|
2012-02-10 07:35:17 +00:00
|
|
|
volatile ALboolean DirectChannels;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2011-09-11 08:18:57 +00:00
|
|
|
volatile ALboolean DryGainHFAuto;
|
|
|
|
volatile ALboolean WetGainAuto;
|
|
|
|
volatile ALboolean WetGainHFAuto;
|
|
|
|
volatile ALfloat OuterGainHF;
|
2007-12-18 05:33:05 +00:00
|
|
|
|
2011-09-11 08:18:57 +00:00
|
|
|
volatile ALfloat AirAbsorptionFactor;
|
|
|
|
volatile ALfloat RoomRolloffFactor;
|
|
|
|
volatile ALfloat DopplerFactor;
|
2008-07-15 09:33:05 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
enum Resampler Resampler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Last user-specified offset, and the offset type (bytes, samples, or
|
|
|
|
* seconds).
|
|
|
|
*/
|
2012-04-17 05:11:03 +00:00
|
|
|
ALdouble Offset;
|
|
|
|
ALenum OffsetType;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Source type (static, streaming, or undetermined) */
|
2012-04-20 04:46:29 +00:00
|
|
|
volatile ALint SourceType;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Source state (initial, playing, paused, or stopped) */
|
|
|
|
volatile ALenum state;
|
|
|
|
ALenum new_state;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Source offset in samples, relative to the currently playing buffer, NOT
|
|
|
|
* the whole queue, and the fractional (fixed-point) offset to the next
|
|
|
|
* sample.
|
|
|
|
*/
|
|
|
|
ALuint position;
|
|
|
|
ALuint position_fraction;
|
|
|
|
|
|
|
|
/** Source Buffer Queue info. */
|
|
|
|
ALbufferlistitem *queue;
|
|
|
|
ALuint BuffersInQueue;
|
|
|
|
ALuint BuffersPlayed;
|
|
|
|
|
|
|
|
/** Current buffer sample info. */
|
2011-05-17 20:25:15 +00:00
|
|
|
ALuint NumChannels;
|
2011-05-19 00:02:18 +00:00
|
|
|
ALuint SampleSize;
|
2011-05-17 20:25:15 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Direct filter and auxiliary send info. */
|
|
|
|
ALfloat DirectGain;
|
|
|
|
ALfloat DirectGainHF;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct ALeffectslot *Slot;
|
2012-04-27 07:45:42 +00:00
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat GainHF;
|
2012-04-26 10:26:22 +00:00
|
|
|
} Send[MAX_SENDS];
|
|
|
|
|
|
|
|
/** HRTF info. */
|
2012-04-27 07:45:42 +00:00
|
|
|
HrtfState Hrtf;
|
2011-05-01 20:21:56 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Current target parameters used for mixing. */
|
2009-10-21 21:25:54 +00:00
|
|
|
struct {
|
2012-04-28 06:46:51 +00:00
|
|
|
DryMixerFunc DryMix;
|
|
|
|
WetMixerFunc WetMix;
|
2011-06-25 07:08:05 +00:00
|
|
|
|
2010-08-07 12:43:16 +00:00
|
|
|
ALint Step;
|
2009-10-21 21:25:54 +00:00
|
|
|
|
2012-04-28 08:32:52 +00:00
|
|
|
DirectParams Direct;
|
|
|
|
|
|
|
|
struct ALeffectslot *Slot[MAX_SENDS];
|
|
|
|
SendParams Send[MAX_SENDS];
|
2009-10-21 21:25:54 +00:00
|
|
|
} Params;
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Source needs to update its mixing parameters. */
|
2011-08-29 20:43:59 +00:00
|
|
|
volatile ALenum NeedsUpdate;
|
2010-09-26 08:15:27 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Method to update mixing parameters. */
|
2010-08-04 06:10:00 +00:00
|
|
|
ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
|
2009-10-21 21:25:54 +00:00
|
|
|
|
2012-04-26 10:26:22 +00:00
|
|
|
/** Self ID */
|
2012-04-20 05:28:01 +00:00
|
|
|
ALuint id;
|
2007-11-14 02:02:18 +00:00
|
|
|
} ALsource;
|
2011-05-06 07:20:40 +00:00
|
|
|
#define ALsource_Update(s,a) ((s)->Update(s,a))
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2011-08-20 13:31:10 +00:00
|
|
|
ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
|
2011-08-21 07:49:04 +00:00
|
|
|
ALboolean ApplyOffset(ALsource *Source);
|
|
|
|
|
2008-01-16 21:27:15 +00:00
|
|
|
ALvoid ReleaseALSources(ALCcontext *Context);
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|