Skip to main content

Realtime Engine

The real-time engine uses the system IO and can access the microphone and render to the device speaker.


Configuration

graph

Type: Graph Config

The audio graph the engine runs.

microphoneEnabled

Type: Boolean. Default: false.

Whether the engine opens an input stream.

inputPreset

Type: String. Default: "GENERIC".

Android equivalent: AAudioStreamBuilder_setInputPreset().

What kind of capture this is, which decides the microphone used and the preprocessing applied. Takes a MediaRecorder.AudioSource constant name. VOICE_COMMUNICATION is the one that asks for echo cancellation.

outputUsage

Type: String. Default: "USAGE_MEDIA".

Android equivalent: AAudioStreamBuilder_setUsage().

Why you are playing audio, which drives the volume stream and routing. Takes an AudioAttributes USAGE_* constant name.

performanceMode

Type: String. Default: "AAUDIO_PERFORMANCE_MODE_NONE".

Android equivalent: AAudioStreamBuilder_setPerformanceMode().

Trades latency against buffer size and battery. Takes an aaudio_performance_mode_t constant name.

audioManagerMode

Type: String. Default: unset — the audio mode is not touched.

Android equivalent: AudioManager.setMode().

Set when the engine starts. Takes an AudioManager MODE_* constant name; MODE_IN_COMMUNICATION is what arms the hardware echo canceller on most devices.

Needs MODIFY_AUDIO_SETTINGS and an application context — see Requirements. Without them the key is ignored and a warning is logged.

speakerphoneOn

Type: Boolean. Default: unset — the route is not touched.

Android equivalent: AudioManager.setCommunicationDevice() on API 31 and above, setSpeakerphoneOn() below it.

Routes to the loudspeaker rather than the earpiece. Applied after audioManagerMode and before the streams open, the only point the platform accepts it.

Needs MODIFY_AUDIO_SETTINGS and an application context — see Requirements. Without them the key is ignored and a warning is logged.


Properties

Inherits properties from its parent, Engine.

Every configuration key the platform accepts is also readable.

Configuration keys are readable as well. The enum keys return their constant name as a string, not the integer the platform uses internally.

graph

Type: Graph Config

The configuration of the graph that is set in the engine.

isRunning (Read only)

Type: Boolean

Whether the engine is currently running.

inputLatency / outputLatency (Read only)

Type: Double

Current input and output latency in milliseconds. -1 when the device does not report stream timestamps, which is what the engine's latency detection is built on.


Actions

Inherits actions from its parent, Engine.

start

Starts the audio engine.

Parameters

None.

Return Value

None.

stop

Stops the audio engine.

Parameters

None.

Return Value

None.


Events

Inherits events from its parent, Engine.