Audio

Entityceramic.Audio (Class)

Main audio system manager for Ceramic.

This class manages the audio system, including:

  • Audio mixers for different buses (channels)
  • Audio filters and effects
  • Global audio processing

The audio system uses a bus-based architecture where sounds can be routed through different buses (0, 1, 2, etc.) for separate processing. Bus 0 is the default/master bus.

Features:

  • Multiple audio buses for organizing sounds
  • Real-time audio filters (low-pass, high-pass, etc.)
  • Thread-safe filter management on native platforms
  • Per-bus volume and effect control via mixers

This class is automatically instantiated by the App and should be accessed via app.audio.

// Get the master mixer
var masterMixer = app.audio.mixer(0);
masterMixer.volume = 0.8;

// Add a low-pass filter to bus 1
var filter = new LowPassFilter();
filter.frequency = 1000;
app.audio.addFilter(filter, 1);

// Play a sound on bus 1
var sound = assets.sound('music');
sound.mixer = 1;
sound.play();

Instance Members

mixer(index: Int): AudioMixer

Get or create an audio mixer for the specified bus. Mixers are created lazily on first access.

Name Type Description
index Int The bus index (0 for master, 1+ for additional buses)
Returns Description
AudioMixer The audio mixer for the specified bus

addFilter(filter: AudioFilter, ?bus: Int = 0): Void

Add an audio filter to a specific bus. Filters are processed in the order they are added. If the filter is already attached to another bus, it will be moved.

Name Type Default Description
filter AudioFilter The filter to add
bus Int 0 The bus to add the filter to (0 = master, default)

removeFilter(filter: AudioFilter, ?bus: Int): Void

Remove an audio filter from a specific bus.

Name Type Default Description
filter AudioFilter The filter to remove
bus Int (optional) The bus to remove from (if null, uses filter's current bus)

Get all filters attached to a specific bus. Returns a copy of the filter array to prevent external modification.

Name Type Description
bus Int The bus to get filters for
Returns Description
ReadOnlyArray<AudioFilter> Read-only array of filters (empty if bus has no filters)

clearFilters(bus: Int): Void

Remove all filters from a specific bus.

Name Type Description
bus Int The bus to clear of all filters

Private Members

Map of audio mixers indexed by bus number. Created lazily as buses are accessed.


busFilters: Array<Array<AudioFilter>>

Filters attached to each bus. First dimension is bus index, second is list of filters for that bus.


busFiltersLock: SpinLock

initMixerIfNeeded(index: Int): Void
Name Type
index Int

new(): Void

Private constructor - Audio is created internally by App. Access via app.audio.

Metadata

Name Parameters
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()