Configure Haas Filter Delay and Balance in FFmpeg
This article explains how to configure the delay and channel balance
of the haas filter in FFmpeg to create a realistic stereo
widening effect. The Haas effect (or precedence effect) is a
psychoacoustic phenomenon where listeners perceive the spatial position
of a sound based on the first arriving wavefront, even if a delayed
version comes from a different direction. By adjusting the delay and
balance parameters in FFmpeg, you can transform flat, mono audio tracks
into rich, spacious stereo mixes.
The Haas Filter Syntax
In FFmpeg, the haas filter uses the following basic
syntax:
-af "haas=level_in:level_out:delay1:delay2:balance1:balance2"You can also use named parameters for clarity:
-af "haas=level_in=1.0:level_out=1.0:delay1=0:delay2=15:balance1=-0.5:balance2=0.5"Parameter Breakdown
level_in(default:1.0): Sets the input audio level.level_out(default:1.0): Sets the output audio level.delay1(default:0.0): The delay in milliseconds for the left channel (range:0.0to40.0).delay2(default:8.0): The delay in milliseconds for the right channel (range:0.0to40.0).balance1(default:1.0): The pan/balance of the first channel (range:-1.0to1.0).balance2(default:-1.0): The pan/balance of the second channel (range:-1.0to1.0).
Configuring Delay
To achieve the Haas effect, one channel must be slightly delayed relative to the other. The human brain perceives a sound as coming from a single source with spatial depth when the delay between the left and right ears is between 10 to 30 milliseconds.
- Delays below 5ms are perceived as phase cancellation or comb filtering.
- Delays above 35ms are perceived as two distinct, echoey audio sources instead of a single wide sound.
Example: Left Channel Dry, Right Channel Delayed (15ms)
To keep the left channel instantaneous and delay the right channel by 15 milliseconds, use:
ffmpeg -i input.wav -af "haas=delay1=0:delay2=15" output.wavConfiguring Channel Balance
Because the delayed channel can sound quieter or “heavy” on one side due to the psychoacoustic precedence effect, you must configure the balance parameters to restore a center image.
balance1controls the stereo placement of the left channel.balance2controls the stereo placement of the right channel.- A value of
-1pans the signal hard left,0is center, and1pans the signal hard right.
Example: Centering the Stereo Image
To counter-balance a 20ms delay on the right channel, you can pan the delayed signal slightly back toward the opposite side to stabilize the stereo image:
ffmpeg -i input.wav -af "haas=delay1=0:delay2=20:balance1=1.0:balance2=-0.3" output.wavExample: Extreme Stereo Widening
For maximum stereo width, pan both signals hard to their respective sides while applying a 12ms delay to one:
ffmpeg -i input.wav -af "haas=delay1=0:delay2=12:balance1=-1.0:balance2=1.0" output.wav