Skip to content

Audio filters

Updated

Audio filters change how a source sounds. Muffle music behind a closed door, thin a voice into a walkie-talkie, give a cave its echo, a cathedral its reverberation, a synth a shimmering chorus or a guitar amp its grit. Each filter is a component you add to an audio entity. The source is heard through every enabled filter on its entity, one after the other, in the order the components are listed.

  • Read Audio sources to know the audio entities and how to reach their components from a script.
  • Every audio entity accepts filters: Audio, Positional Audio, Audio Ambisonic, Audio Tone and Positional Audio Tone.
  • A few terms used below:
    • Frequency is the pitch of a part of the sound, in hertz (Hz). Bass is low (around 50 to 250 Hz), voices sit in the middle, cymbals are high (several thousand Hz).
    • Cutoff is the frequency where a low-pass or high-pass filter starts cutting.
    • Dry is the untouched sound; wet is the effect. The wet prop mixes the two.
Component Class Type What it does
Low pass AudioLowPassFilterComponent comp-audio-low-pass-filter Cuts the highs above the cutoff: muffles, as through a wall or under water.
High pass AudioHighPassFilterComponent comp-audio-high-pass-filter Cuts the lows below the cutoff: thins, as through a phone speaker.
Echo AudioEchoFilterComponent comp-audio-echo-filter Repeats the sound, each repeat quieter and duller.
Reverb AudioReverbFilterComponent comp-audio-reverb-filter Puts the sound in a room, with a tail that dies away.
Chorus AudioChorusFilterComponent comp-audio-chorus-filter Thickens and widens the sound with two wavering copies.
Distortion AudioDistortionFilterComponent comp-audio-distortion-filter Overdrives the sound, from a warm edge to a hard crunch.
  • Order. The source feeds the first enabled filter, which feeds the next, and the last feeds the listener. A low pass before a reverb muffles the sound going into the room; after it, it muffles the room too.
  • After the source. Filters come after the source’s volume, distance falloff, fade and zone mute. So a fade or a zone mute feeds the effect, and when the source stops, an echo or reverb tail dies away by itself instead of being cut.
  • Free when unused. A source without filters goes straight to the listener, and a disabled filter costs nothing.
  • Rewiring. The chain is rebuilt only when a filter is added, removed, enabled or disabled. Changing a prop never rewires anything.

Turn a filter on or off with filter.setEnabled(on), and change its sound with filter.setProps({ … }). Add one at runtime with entity.addComponent(new AudioReverbFilterComponent({ … })); each filter’s constructor takes its props.

Most props glide to a new value over a few milliseconds, so a slider or a script can change them every frame without clicks. A few rebuild part of the effect and apply at once:

Filter Glides smoothly Applies at once
Low pass, High pass frequency, q rolloff
Echo delayTime (with a slower glide that bends pitch like tape), feedback, highCut, wet none
Chorus frequency, delayTime, depth, wet none
Reverb wet decay, preDelay
Distortion none amount, wet

Change the props in the right-hand column on an event, not every frame. The reverb in particular regenerates its room when decay or preDelay change.

Echo, Reverb, Chorus and Distortion mix their effect with the dry sound by wet, from 0 (dry only) to 1 (effect only). Each mix keeps the overall level steady across the range, so moving wet changes the character of the sound, not its loudness. The low-pass and high-pass filters have no wet: they replace the signal.

Both are smooth filters, flat up to the cutoff, then falling more steeply with a higher rolloff.

Prop Type Default Description
frequency number 5000 for low pass, 200 for high pass Cutoff in Hz, from 10 to 22000.
q number 0.707 Resonance, from 0.1 to 20. The default is flat; higher values add a peak at the cutoff, for a more synthetic, “wah” sound.
rolloff 12, 24 or 48 24 How steeply it cuts past the cutoff, in dB per octave.

Typical low-pass cutoffs: 20000 leaves the sound open, 2000 sounds like the next room, 800 sounds behind a closed door, 300 sounds under water.

A delay that feeds back into itself through a high cut, so each repeat is quieter and duller than the one before.

Prop Type Default Description
delayTime number 0.25 Seconds between repeats, from 0.01 to 5.
feedback number 0.5 How much of each repeat feeds the next, from 0 to 0.95. Higher lasts longer; repeats always die away.
highCut number 6000 Frequency in Hz above which each repeat loses brightness, from 200 to 22000.
wet number 0.5 Effect mix, from 0 to 1.

A generated stereo room: the sound’s reflections fade out over decay, growing darker as they die, after preDelay of silence. A longer decay makes a bigger room, not a louder sound; wet alone sets the balance.

Prop Type Default Description
decay number 1.5 Seconds the tail takes to die away, from 0.1 to 10. About 0.5 is a small room, 2 a hall, 5 or more a cathedral or a cave.
preDelay number 0.01 Seconds of silence before the tail, from 0 to 0.5. A longer pre-delay suggests a larger space.
wet number 0.5 Effect mix, from 0 to 1.

The same decay and preDelay always give the same room.

Two copies of the sound, one per side, each delayed by a few milliseconds that waver slowly. The copies detune against each other into a wide, shimmering stereo image. A mono source is spread to both sides.

Prop Type Default Description
frequency number 0.8 How fast the copies waver, in Hz, from 0 to 20.
delayTime number 7 The copies’ average delay, in milliseconds, from 1 to 50.
depth number 0.35 How far the delay swings around delayTime, as a share of it, from 0 to 1.
wet number 0.5 Effect mix, from 0 to 1.

A saturation curve that adds harmonics as it drives the sound harder. It keeps moderate material at the same level whatever the amount: more drive means more grit, not more volume.

Prop Type Default Description
amount number 0.4 How hard the sound is driven, from 0 to 1: clean, a warm edge, then a hard crunch.
wet number 1 Effect mix, from 0 to 1.

Muffle the music while a door is closed and open it up when the door opens.

DoorMuffle.jx
#pragma lifecycle(startup)
let lowPass;
function startup() {
lowPass = findEntity('Party Music').getComponent(AudioLowPassFilterComponent);
on('door/open', () => lowPass.setProps({ frequency: 20000 }));
on('door/close', () => lowPass.setProps({ frequency: 600 }));
}

How it works:

  • The filter is authored on the entity at 600 Hz, so the party sounds muffled from the start.
  • setProps({ frequency }) glides the cutoff to its new value, so the change is smooth even while the music plays.
  • 20000 Hz is above almost everything people hear, so the filter is effectively open, without switching it off and risking a click.

Add a band of filters at runtime to make any voice line sound like a radio.

RadioVoice.jx
#pragma lifecycle(startup)
let voice;
function startup() {
const commander = findEntity('Commander');
voice = commander.getComponent(AudioComponent);
// Order matters: thin first, then cut the highs, then a little grit.
commander.addComponent(new AudioHighPassFilterComponent({ frequency: 400, rolloff: 24 }));
commander.addComponent(new AudioLowPassFilterComponent({ frequency: 3000, rolloff: 24 }));
commander.addComponent(new AudioDistortionFilterComponent({ amount: 0.3, wet: 0.5 }));
on('radio/call', () => {
voice.stop();
voice.play();
});
}

How it works:

  • A high pass at 400 Hz removes the body of the voice and a low pass at 3000 Hz removes its air. Together they keep only the narrow middle band a small speaker plays.
  • A light distortion, half mixed in, adds the crackle of a cheap speaker.
  • Components added with addComponent join the chain in the order they are added, after any filters already on the entity.

Fade in a reverb when the listener enters a cave zone, and out when they leave.

CaveReverb.jx
#pragma lifecycle(startup)
let reverb;
let mix = 0;
let fade;
function setWet(target) {
if (fade) fade.stop();
fade = Tween.value(mix, target, (value) => {
mix = value;
reverb.setProps({ wet: value });
}, { duration: 1.5 });
}
function startup() {
reverb = findEntity('Footsteps').getComponent(AudioReverbFilterComponent);
on('cave', (event) => {
if (event.eventType === EventType.AudioZone.Enter) setWet(0.6);
if (event.eventType === EventType.AudioZone.Exit) setWet(0);
});
}

How it works:

  • The reverb stays enabled at wet: 0, which sounds dry. Tweening wet brings the effect in without the click that enabling a filter could cause.
  • wet glides smoothly, so updating it every frame during the tween is safe. decay is set once in the scene, since changing it regenerates the room.
  • mix remembers the current value so a new fade starts from wherever the last one is.

Drive an echo from two UI sliders.

EchoControls.jx
#pragma lifecycle(startup)
let echo;
let timeSlider;
let repeatSlider;
function startup() {
echo = findEntity('Synth').getComponent(AudioEchoFilterComponent);
timeSlider = findEntity('Echo Time');
repeatSlider = findEntity('Echo Repeats');
on('echo/ui', (event) => {
if (event.eventType !== EventType.UISlider.Change) return;
if (event.entityId === timeSlider.entityId) echo.setProps({ delayTime: event.data.value });
if (event.entityId === repeatSlider.entityId) echo.setProps({ feedback: event.data.value });
});
}

How it works:

  • Both sliders share one signal; event.entityId compared with each slider’s entityId tells which one moved.
  • UISlider::change arrives at each step of a drag with { value }. Echo props glide, so following every step is smooth.
  • Changing delayTime while repeats are still ringing bends their pitch, like a tape echo. That is expected, and can be a fun effect.

Muffle and darken everything the player hears while the camera is under water.

Underwater.jx
#pragma lifecycle(startup)
// Scene: a Water Volume with a Signal Emitter on 'water'. Every audio entity that should
// be affected has an Audio Low Pass Filter (frequency: 20000) and an Audio Reverb Filter
// (decay: 2.5, wet: 0). Their names are listed below.
const AFFECTED = ['Waves', 'Gulls', 'Boat Engine'];
const filters = [];
function setUnderwater(under) {
for (const { lowPass, reverb } of filters) {
lowPass.setProps({ frequency: under ? 350 : 20000 });
reverb.setProps({ wet: under ? 0.5 : 0 });
}
}
function startup() {
for (const name of AFFECTED) {
const entity = findEntity(name);
filters.push({
lowPass: entity.getComponent(AudioLowPassFilterComponent),
reverb: entity.getComponent(AudioReverbFilterComponent),
});
}
on('water', (event) => {
if (event.eventType === EventType.WaterVolume.Submerge) setUnderwater(true);
if (event.eventType === EventType.WaterVolume.Emerge) setUnderwater(false);
});
}

How it works:

  • WaterVolume::submerge is sent when the camera goes fully under the water line, and WaterVolume::emerge when part of it comes back out.
  • A cutoff of 350 Hz leaves only a dull rumble, and a reverb adds the enclosed feeling of water. Both props glide, so the transition is smooth.
  • The filters are looked up once and kept in an array; the events only change their props.

Grow a distortion on the music as the player gets hurt, then clear it on recovery.

DamageGrit.jx
#pragma lifecycle(startup)
// Scene: an Audio entity "Music" with an Audio Distortion Filter (amount: 0, wet: 1),
// starting disabled. Game code emits 'player/health' with a number from 0 to 100.
let grit;
function startup() {
grit = findEntity('Music').getComponent(AudioDistortionFilterComponent);
on('player/health', (health) => {
if (health > 60) {
grit.setEnabled(false);
return;
}
grit.setEnabled(true);
// Rounded to steps, because distortion changes apply at once.
const amount = Math.round(((60 - health) / 60) * 4) / 4;
grit.setProps({ amount });
});
}

How it works:

  • Healthy players hear clean music: the filter is disabled, so it is not in the chain at all.
  • Below 60 health the filter is enabled and its amount grows as health falls.
  • Distortion changes rebuild its curve and apply at once, so the script rounds the amount to four steps instead of changing it on every hit point.
  • Toggling a strong effect with setEnabled during playback. It can click. Keep the filter enabled and move wet (or a low pass’s frequency) instead.
  • Changing reverb decay or preDelay every frame. They regenerate the room each time. Set them on events; animate wet.
  • Forgetting the order. Filters run in component order. A distortion after a reverb distorts the whole room; before it, only the dry sound.
  • Expecting wet on a pass filter. Low pass and high pass have no wet. Open a low pass with a high frequency instead.
  • Looking for the filter on the wrong entity. A filter affects only the source on its own entity. Each sound that should change needs its own filter.
  • Very high feedback with short delayTime. The repeats pile up into a loud ring. Keep feedback moderate for short delays.