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;
}
}
// 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
paramsChanged: Bool
paramsAcquired: Bool
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) |
Name | Type |
---|---|
index |
Int |
value |
Bool |
Name | Type |
---|---|
index |
Int |
value |
Int |
Name | Type |
---|---|
index |
Int |
value |
Float |
Called when filter is attached to a bus
Name | Type |
---|---|
bus |
Int |
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() |