aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/modulator.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-07-21 14:21:00 -0700
committerChris Robinson <[email protected]>2018-07-21 14:21:00 -0700
commit6fe1ffa3bb822105f1f0a848adba22478eef02a9 (patch)
tree2167d4b82341f47d4f72d9d8d4dca758fff1162a /Alc/effects/modulator.c
parentd117a5209f390dfe97e072fa9665fdbf449828f5 (diff)
Improve handling of 0hz ring modulator frequency
Diffstat (limited to 'Alc/effects/modulator.c')
-rw-r--r--Alc/effects/modulator.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c
index a5180669..797a2075 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.c
@@ -76,6 +76,11 @@ static inline ALfloat Square(ALsizei index)
return (ALfloat)(((index>>(WAVEFORM_FRACBITS-2))&2) - 1);
}
+static inline ALfloat One(ALsizei UNUSED(index))
+{
+ return 1.0f;
+}
+
#define DECL_TEMPLATE(func) \
static void Modulate##func(ALfloat *restrict dst, ALsizei index, \
const ALsizei step, ALsizei todo) \
@@ -92,6 +97,7 @@ static void Modulate##func(ALfloat *restrict dst, ALsizei index, \
DECL_TEMPLATE(Sin)
DECL_TEMPLATE(Saw)
DECL_TEMPLATE(Square)
+DECL_TEMPLATE(One)
#undef DECL_TEMPLATE
@@ -128,17 +134,19 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCcontext
ALfloat f0norm;
ALsizei i;
- if(props->Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
+ state->step = fastf2i(props->Modulator.Frequency / (ALfloat)device->Frequency *
+ WAVEFORM_FRACONE);
+ state->step = clampi(state->step, 0, WAVEFORM_FRACONE-1);
+
+ if(state->step == 0)
+ state->GetSamples = ModulateOne;
+ else if(props->Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
state->GetSamples = ModulateSin;
else if(props->Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH)
state->GetSamples = ModulateSaw;
else /*if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/
state->GetSamples = ModulateSquare;
- state->step = fastf2i(props->Modulator.Frequency / (ALfloat)device->Frequency *
- WAVEFORM_FRACONE);
- state->step = clampi(state->step, 1, WAVEFORM_FRACONE-1);
-
f0norm = props->Modulator.HighPassCutoff / (ALfloat)device->Frequency;
f0norm = clampf(f0norm, 1.0f/512.0f, 0.5f);
/* Bandwidth value is constant in octaves. */