Playback (Realtime)

How to play in real time: graph creation and source loading

This example demonstrates how to play an audio file. It creates a simple graph that connects a local media source to the destination, allowing you to control playback start and stop. This flow showcases the basic structure of an output pipeline.

// 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.wav")
let source = MediaRenderer(contentsOf: url)

// Configure node connections
try context.connect(source: source, 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