AudioFilter
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:
- Extend this class
- Mark parameters with
@param metadata
- Implement the
workletClass() method
- 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;
}
}
var filter = new MyFilter();
app.audio.addFilter(filter, 0);
Instance Members
The unique identifier for this filter instance.
Automatically assigned on creation.
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.
Whether this filter is currently processing audio.
Set to false to bypass the filter while keeping it attached.
releaseParams(?notifyChanges: Bool = true): Bool
Releases the params previously acquired with acquireParams().
| Name |
Type |
Default |
Description |
notifyChanges |
Bool |
true |
When false, params that changed during the acquisition are not notified to the audio backend: the caller takes responsibility for handling them. Used when copying params to the worklet, as the notification would try to acquire locks that are already held at that point. |
| Returns |
Description |
| Bool |
Whether params changed during the acquisition |
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.
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 |
Private Members
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 |
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) |
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) |
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) |
Called when filter is attached to a bus
Called when filter is detached from a bus
| 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() |