AudioFilter

Entityceramic.AudioFilter (Class) → HighPassFilter, LowPassFilter

Base class for audio filters that can process audio buffers in real-time.

AudioFilter is an abstract class for creating custom audio effects that can be attached to audio buses for real-time processing. Filters process audio data as it flows through the bus, allowing effects like reverb, distortion, EQ, etc.

To create a custom filter:

  1. Extend this class
  2. Mark parameters with @param metadata
  3. Implement the workletClass() method
  4. Create a corresponding AudioFilterWorklet class

The macro system automatically generates getters/setters for @param fields and handles thread-safe parameter updates.

class MyFilter extends AudioFilter {
    override function workletClass():Class<AudioFilterWorklet> {
        return MyFilterWorklet;
    }
}

// Use the filter
var filter = new MyFilter();
app.audio.addFilter(filter, 0); // Add to master bus

Instance Members

filterId: Int

The unique identifier for this filter instance. Automatically assigned on creation.


bus: Int

The bus index this filter is currently attached to. -1 means the filter is not attached to any bus. Read-only - use Audio.addFilter/removeFilter to change.


active: Bool

Whether this filter is currently processing audio. Set to false to bypass the filter while keeping it attached.


acquireParams(): Void

releaseParams(): Void

workletClass(): Class<AudioFilterWorklet>

Return the AudioFilterWorklet class that implements the actual audio processing. This method must be overridden by subclasses to specify their worklet implementation. The worklet class handles the real-time audio processing on the audio thread.

Returns Description
Class<AudioFilterWorklet> The worklet class to instantiate for this filter

numParams(): Int

Return the number of parameters this filter has. This is automatically generated by the macro system based on @param fields. Subclasses should not override this method.

Returns Description
Int Number of parameters

destroy(): Void

new(): Void

Private Members

paramsLock: SpinLock

paramsAcquireLock: SpinLock

params: Array<Float>

paramsChanged: Bool

paramsAcquired: Bool

emitReady(bus: Int): Void

Fired when the audio filter is successfully attached to a given bus. When this event is emitted, the filter is fully initialized and processing audio. The underlying audio worklet has been created and connected to the audio graph.

Name Type Description
bus Int The bus index this filter is now attached to

getBool(index: Int): Bool

Get a boolean parameter at the given position. Used internally by generated property getters.

Name Type Description
index Int Parameter index (0-based)
Returns Description
Bool Boolean value (false if null)

getInt(index: Int): Int

Get an integer parameter at the given position. Used internally by generated property getters.

Name Type Description
index Int Parameter index (0-based)
Returns Description
Int Integer value (0 if null)

getFloat(index: Int): Float

Get a float parameter at the given position. Used internally by generated property getters.

Name Type Description
index Int Parameter index (0-based)
Returns Description
Float Float value (0.0 if null)

setBool(index: Int, value: Bool): Void
Name Type
index Int
value Bool

setInt(index: Int, value: Int): Void
Name Type
index Int
value Int

setFloat(index: Int, value: Float): Void
Name Type
index Int
value Float

attach(bus: Int): Void

Called when filter is attached to a bus

Name Type
bus Int

detach(bus: Int): Void

Called when filter is detached from a bus

Name Type
bus Int

Metadata

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