52 #define WAVEFORM_FRACBITS 16
53 #define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
54 #define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
78 output = output + (history[0]-
output)*a;
85 #define DECL_TEMPLATE(func) \
86 static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \
87 const ALfloat *RESTRICT SamplesIn, \
88 ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE]) \
90 const ALuint step = state->step; \
91 ALuint index = state->index; \
95 for(i = 0;i < SamplesToDo;i++) \
97 samp = SamplesIn[i]; \
100 index &= WAVEFORM_FRACMASK; \
101 samp *= func(index); \
103 samp = hpFilter1P(&state->iirFilter, 0, samp); \
105 for(k = 0;k < MaxChannels;k++) \
106 SamplesOut[k][i] += state->Gain[k] * samp; \
108 state->index = index; \
138 state->Waveform = SINUSOID;
140 state->Waveform = SAWTOOTH;
142 state->Waveform = SQUARE;
146 if(state->step == 0) state->step = 1;
150 a = (2.0f-cw) - sqrtf(powf(2.0
f-cw, 2.0
f) - 1.0f);
151 state->iirFilter.coeff =
a;
156 state->Gain[index] = 0.0f;
160 state->Gain[chan] = gain;
168 switch(state->Waveform)
171 ProcessSin(state, SamplesToDo, SamplesIn, SamplesOut);
175 ProcessSaw(state, SamplesToDo, SamplesIn, SamplesOut);
179 ProcessSquare(state, SamplesToDo, SamplesIn, SamplesOut);
188 state =
malloc(
sizeof(*state));
200 state->iirFilter.coeff = 0.0f;
201 state->iirFilter.history[0] = 0.0f;
203 return &state->state;
#define AL_RING_MODULATOR_SAWTOOTH
static ALvoid ModulatorProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat(*RESTRICT SamplesOut)[BUFFERSIZE])
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
static __inline ALfloat hpFilter1P(FILTER *iir, ALuint offset, ALfloat input)
static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
#define AL_RING_MODULATOR_SINUSOID
ALeffectState * ModulatorCreate(void)
static __inline ALfloat Sin(ALuint index)
GLboolean GLboolean GLboolean GLboolean a
struct ALeffect::@54 Modulator
static __inline ALfloat Square(ALuint index)
static __inline ALfloat Saw(ALuint index)
#define DECL_TEMPLATE(func)
enum Channel Speaker2Chan[MaxChannels]
static __inline ALuint fastf2u(ALfloat f)
#define WAVEFORM_FRACBITS
static ALvoid ModulatorDestroy(ALeffectState *effect)
GLenum GLenum GLenum input
struct ALmodulatorState ALmodulatorState
#define AL_RING_MODULATOR_SQUARE
static ALvoid ModulatorUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot)