Convolution (IR)

Convolution with impulse response for acoustic modeling

This example demonstrates how to apply convolution using an impulse response (IR). The IR node loads an impulse-response local file and uses it to filter a mono or stereo audio source, modifying its timbre and spatial depth with precise phase accuracy.

// Configure the graph for rendering
let context = Assembler(rendering: .live).createAudioGraph()

// Configure an audio source (Renderer) from a local audio file
let url = URL(fileURLWithPath: "/path/to/audio.mp3")
let source = MediaRenderer(contentsOf: url)

// Configure the impulse response (IR) from a local file
let impulse = URL(fileURLWithPath: "/path/to/impulse.wav")
let destination = IR(contentsOf: impulse, channels: .stereo)

// Configure node connections
try context.connect(source: source, to: destination)
try context.connect(source: destination, to: context.destination)
source.play(after: 0)

The following video shows the sample code in action and its real-time processing.

circle-info

For a complete description of each class, method, and property referenced in this section, refer to the official API documentationarrow-up-right, where you will find detailed references, available components, parameters, and additional usage code examples.

Last updated