How to Use FFmpeg afir Filter for Guitar Cabinet Simulation
This article provides a straightforward guide on how to use FFmpeg’s
afir (Acoustic Impulse Response) filter to apply a speaker
cabinet simulation to a raw, direct-input (DI) guitar audio track. By
convolving your dry guitar recording with a cabinet Impulse Response
(IR) file, you can achieve a realistic, mic’d amplifier sound directly
from the command line.
Guitar cabinet simulation relies on Impulse Responses (IRs), which
are audio files (usually in WAV format) that capture the acoustic
characteristics of a specific speaker cabinet, microphone, and room.
FFmpeg’s afir filter performs frequency domain convolution
to apply these characteristics to your dry audio.
1. Prerequisites
To follow this guide, you will need: * A dry guitar track (typically recorded through a DI box or audio interface). * A cabinet Impulse Response file (available from various free or commercial IR library websites). * FFmpeg installed and accessible in your system’s terminal.
2. The FFmpeg Command
The basic syntax to apply a cabinet IR to a guitar track using the
afir filter is:
ffmpeg -i dry_guitar.wav -i cabinet_ir.wav -filter_complex "[0:a][1:a]afir=grms=1[out]" -map "[out]" output_guitar.wav3. Command Breakdown
-i dry_guitar.wav: The first input (index 0) is your dry guitar track.-i cabinet_ir.wav: The second input (index 1) is your cabinet impulse response file.-filter_complex: This flag is used because the filter processes multiple input streams.[0:a][1:a]: This feeds the audio stream of the first input (guitar) and the audio stream of the second input (IR) into the filter.afir=grms=1: This calls theafirfilter. Thegrms=1option enables RMS normalization, which helps prevent the output volume from clipping or becoming too quiet after convolution.-map "[out]": Maps the processed output stream to the final output file.output_guitar.wav: The resulting audio file with the cabinet simulation applied.
4. Fine-Tuning the Volume
Depending on the specific IR file used, the output level may still
require adjustment to prevent digital clipping or to match a desired mix
level. You can chain the volume filter immediately after
the afir filter:
ffmpeg -i dry_guitar.wav -i cabinet_ir.wav -filter_complex "[0:a][1:a]afir=grms=1,volume=-3dB[out]" -map "[out]" output_guitar.wavIn this command, volume=-3dB reduces the overall output
gain by 3 decibels to ensure adequate headroom.