aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcModulator.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-23 23:11:35 -0700
committerChris Robinson <[email protected]>2011-09-23 23:11:35 -0700
commit9060d0cc36eb0bbc52b0d9cc9caefaf89451a138 (patch)
tree32010f6c538eda0c44c4c51c1719b8569e75e492 /Alc/alcModulator.c
parentb4f9f894806fe5fa9adb1ebb481392838cc81e2e (diff)
Add a WAVEFORM_FRACONE macro and minor cleanups for the ring modulator
Diffstat (limited to 'Alc/alcModulator.c')
-rw-r--r--Alc/alcModulator.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c
index 4c1bd2f7..ed8d151e 100644
--- a/Alc/alcModulator.c
+++ b/Alc/alcModulator.c
@@ -50,21 +50,22 @@ typedef struct ALmodulatorState {
} ALmodulatorState;
#define WAVEFORM_FRACBITS 16
-#define WAVEFORM_FRACMASK ((1<<WAVEFORM_FRACBITS)-1)
+#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
+#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
static __inline ALfloat Sin(ALuint index)
{
- return aluSin(index * (F_PI*2.0f / (1<<WAVEFORM_FRACBITS)));
+ return aluSin(index * (F_PI*2.0f / WAVEFORM_FRACONE));
}
static __inline ALfloat Saw(ALuint index)
{
- return index*(2.0f/(1<<WAVEFORM_FRACBITS)) - 1.0f;
+ return index*(2.0f/WAVEFORM_FRACONE) - 1.0f;
}
static __inline ALfloat Square(ALuint index)
{
- return (index&(1<<(WAVEFORM_FRACBITS-1))) ? -1.0f : 1.0f;
+ return ((index>>(WAVEFORM_FRACBITS-1))&1)*2.0f - 1.0f;
}
@@ -146,10 +147,9 @@ static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const
else if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)
state->Waveform = SQUARE;
- state->step = Slot->effect.Modulator.Frequency*(1<<WAVEFORM_FRACBITS) /
- Device->Frequency;
- if(!state->step)
- state->step = 1;
+ state->step = (ALuint)(Slot->effect.Modulator.Frequency*WAVEFORM_FRACONE /
+ Device->Frequency);
+ if(state->step == 0) state->step = 1;
cw = aluCos(F_PI*2.0f * Slot->effect.Modulator.HighPassCutoff /
Device->Frequency);
@@ -199,8 +199,8 @@ ALeffectState *ModulatorCreate(void)
state->state.Update = ModulatorUpdate;
state->state.Process = ModulatorProcess;
- state->index = 0.0f;
- state->step = 1.0f;
+ state->index = 0;
+ state->step = 1;
state->iirFilter.coeff = 0.0f;
state->iirFilter.history[0] = 0.0f;