Audio
SoundfileMixer
Audio mixer for combining real-time audio with sound files
Overview
SoundfileMixer
is an audio mixer that combines incoming audio with audio from files. It supports multiple audio file formats through the soundfile library and can handle runtime volume adjustments and sound switching.
Installation
The soundfile mixer requires additional dependencies:
Constructor Parameters
Dictionary mapping sound names to file paths. Files must be mono (single channel).
Name of the default sound to play (must be a key in sound_files).
Initial volume for the mixed sound. Values typically range from 0.0 to 1.0, but can go higher.
Whether to loop the sound file when it reaches the end.
Control Frames
Updates mixer settings at runtime
Enables or disables the mixer
Usage Example
Notes
- Supports any audio format that soundfile can read
- Automatically resamples audio files to match output sample rate
- Files must be mono (single channel)
- Thread-safe for pipeline processing
- Can dynamically switch between multiple sound files
- Volume can be adjusted in real-time
- Mixing can be enabled/disabled on demand