AudioEngine

actual class AudioEngine : AutoCloseable

Entry point for the Klarinet audio library.

AudioEngine is the main factory for creating audio streams and querying available audio devices on the current platform.

Usage

val engine = AudioEngine.create()
val stream = engine.openStream(
config = AudioStreamConfig(sampleRate = 48000, channelCount = 2),
callback = myCallback,
)
stream.start()
// ... audio is playing ...
stream.stop()
stream.close()
engine.release()

Platform Behavior

  • Android: Backed by Google Oboe (AAudio / OpenSL ES).

  • Apple: Backed by AVAudioEngine / Core Audio.

  • JS / Browser: Backed by the Web Audio API. Effects are native Web Audio nodes (not the C++ DSP core). File reads require decodeAudioFile or an AudioFileWriter first.

Always call release when the engine is no longer needed to free native resources.

actual class AudioEngine : <ERROR CLASS> ERROR CLASS: Symbol not found for AutoCloseable

Entry point for the Klarinet audio library.

AudioEngine is the main factory for creating audio streams and querying available audio devices on the current platform.

Usage

val engine = AudioEngine.create()
val stream = engine.openStream(
config = AudioStreamConfig(sampleRate = 48000, channelCount = 2),
callback = myCallback,
)
stream.start()
// ... audio is playing ...
stream.stop()
stream.close()
engine.release()

Platform Behavior

  • Android: Backed by Google Oboe (AAudio / OpenSL ES).

  • Apple: Backed by AVAudioEngine / Core Audio.

  • JS / Browser: Backed by the Web Audio API. Effects are native Web Audio nodes (not the C++ DSP core). File reads require decodeAudioFile or an AudioFileWriter first.

Always call release when the engine is no longer needed to free native resources.

expect class AudioEngine : AutoCloseable

Entry point for the Klarinet audio library.

AudioEngine is the main factory for creating audio streams and querying available audio devices on the current platform.

Usage

val engine = AudioEngine.create()
val stream = engine.openStream(
config = AudioStreamConfig(sampleRate = 48000, channelCount = 2),
callback = myCallback,
)
stream.start()
// ... audio is playing ...
stream.stop()
stream.close()
engine.release()

Platform Behavior

  • Android: Backed by Google Oboe (AAudio / OpenSL ES).

  • Apple: Backed by AVAudioEngine / Core Audio.

  • JS / Browser: Backed by the Web Audio API. Effects are native Web Audio nodes (not the C++ DSP core). File reads require decodeAudioFile or an AudioFileWriter first.

Always call release when the engine is no longer needed to free native resources.

actual class AudioEngine : AutoCloseable

Entry point for the Klarinet audio library.

AudioEngine is the main factory for creating audio streams and querying available audio devices on the current platform.

Usage

val engine = AudioEngine.create()
val stream = engine.openStream(
config = AudioStreamConfig(sampleRate = 48000, channelCount = 2),
callback = myCallback,
)
stream.start()
// ... audio is playing ...
stream.stop()
stream.close()
engine.release()

Platform Behavior

  • Android: Backed by Google Oboe (AAudio / OpenSL ES).

  • Apple: Backed by AVAudioEngine / Core Audio.

  • JS / Browser: Backed by the Web Audio API. Effects are native Web Audio nodes (not the C++ DSP core). File reads require decodeAudioFile or an AudioFileWriter first.

Always call release when the engine is no longer needed to free native resources.

actual class AudioEngine : AutoCloseable

Entry point for the Klarinet audio library.

AudioEngine is the main factory for creating audio streams and querying available audio devices on the current platform.

Usage

val engine = AudioEngine.create()
val stream = engine.openStream(
config = AudioStreamConfig(sampleRate = 48000, channelCount = 2),
callback = myCallback,
)
stream.start()
// ... audio is playing ...
stream.stop()
stream.close()
engine.release()

Platform Behavior

  • Android: Backed by Google Oboe (AAudio / OpenSL ES).

  • Apple: Backed by AVAudioEngine / Core Audio.

  • JS / Browser: Backed by the Web Audio API. Effects are native Web Audio nodes (not the C++ DSP core). File reads require decodeAudioFile or an AudioFileWriter first.

Always call release when the engine is no longer needed to free native resources.

actual class AudioEngine : AutoCloseable

Entry point for the Klarinet audio library.

AudioEngine is the main factory for creating audio streams and querying available audio devices on the current platform.

Usage

val engine = AudioEngine.create()
val stream = engine.openStream(
config = AudioStreamConfig(sampleRate = 48000, channelCount = 2),
callback = myCallback,
)
stream.start()
// ... audio is playing ...
stream.stop()
stream.close()
engine.release()

Platform Behavior

  • Android: Backed by Google Oboe (AAudio / OpenSL ES).

  • Apple: Backed by AVAudioEngine / Core Audio.

  • JS / Browser: Backed by the Web Audio API. Effects are native Web Audio nodes (not the C++ DSP core). File reads require decodeAudioFile or an AudioFileWriter first.

Always call release when the engine is no longer needed to free native resources.

Types

Link copied to clipboard
actual object Companion
actual object Companion
expect object Companion
actual object Companion
actual object Companion
actual object Companion

Functions

Link copied to clipboard
actual open override fun close()

Closes this engine. Equivalent to release.

actual open override fun close()

Closes this engine. Equivalent to release.

expect open override fun close()

Closes this engine. Equivalent to release.

actual open override fun close()

Closes this engine. Equivalent to release.

actual open override fun close()

Closes this engine. Equivalent to release.

actual open override fun close()

Closes this engine. Equivalent to release.

Link copied to clipboard

Create a new audio effect of the given type.

Create a new audio effect of the given type.

Create a new audio effect of the given type.

Create a new audio effect of the given type.

Create a new audio effect of the given type.

Create a new audio effect of the given type.

Link copied to clipboard

Create a new empty effect chain for grouping and ordering effects.

Create a new empty effect chain for grouping and ordering effects.

Create a new empty effect chain for grouping and ordering effects.

Create a new empty effect chain for grouping and ordering effects.

Create a new empty effect chain for grouping and ordering effects.

Create a new empty effect chain for grouping and ordering effects.

Link copied to clipboard

List all available audio devices on the current platform.

List all available audio devices on the current platform.

List all available audio devices on the current platform.

List all available audio devices on the current platform.

List all available audio devices on the current platform.

List all available audio devices on the current platform.

Link copied to clipboard

Get the default audio device for the given direction.

Get the default audio device for the given direction.

Get the default audio device for the given direction.

Get the default audio device for the given direction.

Get the default audio device for the given direction.

Get the default audio device for the given direction.

Link copied to clipboard

Open a new audio stream with the given configuration.

Open a new audio stream with the given configuration.

expect fun openStream(config: AudioStreamConfig, callback: AudioStreamCallback? = null): AudioStream

Open a new audio stream with the given configuration.

Open a new audio stream with the given configuration.

Open a new audio stream with the given configuration.

Open a new audio stream with the given configuration.

Link copied to clipboard
fun AudioEngine.playFile(filePath: String, config: AudioStreamConfig = AudioStreamConfig()): AudioStream

Play an audio file through the engine.

Link copied to clipboard
fun AudioEngine.recordToFile(filePath: String, format: AudioFileFormat = AudioFileFormat.WAV, config: AudioStreamConfig = AudioStreamConfig(direction = StreamDirection.INPUT)): AudioStream

Record audio from the microphone to a file.

Link copied to clipboard
actual fun release()

Release all native resources held by this engine.

actual fun release()

Release all native resources held by this engine.

expect fun release()

Release all native resources held by this engine.

actual fun release()

Release all native resources held by this engine.

actual fun release()

Release all native resources held by this engine.

actual fun release()

Release all native resources held by this engine.