#Crunchy audio with effects

4 messages · Page 1 of 1 (latest)

honest breach
#

I made a lowpassfilter effect for my audio when the player is underwater, but the audio sounds crunchy. With noise.

//CreateEvent
lowpass_filter = audio_effect_create(AudioEffectType.LPF2);

//StepEvent
if (swimming) {
    if !audio_bus_main.effects[0] != lowpass_filter {
        audio_bus_main.effects[0] = lowpass_filter
    }
} else {
    if (audio_bus_main.effects[0] = lowpass_filter) {
        var null_effect = audio_effect_create(AudioEffectType.Reverb1);
        null_effect.mix = 0
        audio_bus_main.effects[0] = null_effect;
    }
}
vivid wind
#

There's a double negative in your condition:
if !audio_bus_main.effects[0] != lowpass_filter which leads to it always being true if swimming. This replaces the low-pass filter instance with a new one each step. This essentially resets the filter's internal state each step which is what causes the crackle.

#

Also if you want to clear an effect, you can set the element in the effects array to undefined

#

Alternatively, you can keep the effect there all the time and bypass when it isn't needed. For example:

//CreateEvent
lowpass_filter = audio_effect_create(AudioEffectType.LPF2, { bypass: true });
audio_bus_main.effects[0] = lowpass_filter

//StepEvent
if (swimming) {
    lowpass_filter.bypass = false;
} else {
    lowpass_filter.bypass = true;
}