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.wav

3. Command Breakdown

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.wav

In this command, volume=-3dB reduces the overall output gain by 3 decibels to ensure adequate headroom.