Module: Toybox.Audio.Capture

Overview

The Capture module provides APIs for capturing audio on the device.

Since:

API Level 6.0.3

Requires Permission:

  • AudioInput

Classes Under Namespace

Classes: InitializationFailedException

Constant Summary

Filter

Filters for audio capture.

Since:

API Level 6.0.3

Name Value Since Description
FILTER_NREC 0

API Level 6.0.3

Noise reduction and echo cancellation.

WindowFilledBehavior

What audio capture should do when the window is filled.

Since:

API Level 6.0.3

Name Value Since Description
WINDOW_FILLED_STOP 0

API Level 6.0.3

Stop capturing when the window is filled.

WINDOW_FILLED_CONTINUE 1

API Level 6.0.3

Continue capturing when the window is filled.

State

Since:

API Level 6.0.3

Name Value Since Description
CAPTURE_UNINITIALIZED 0

API Level 6.0.3

The audio capture is not initialized.

CAPTURE_STOPPED 1

API Level 6.0.3

The audio capture is stopped.

CAPTURE_CAPTURING 2

API Level 6.0.3

The audio capture is in progress.

Error

Since:

API Level 6.0.3

Name Value Since Description
CAPTURE_ERR_UNKNOWN 0

API Level 6.0.3

An unknown error occurred during audio capture.

CAPTURE_ERR_UNSUPPORTED_FORMAT 1

API Level 6.0.3

The audio format requested is not supported for capture.

CAPTURE_ERR_INTERNAL 2

API Level 6.0.3

There was an internal error during audio capture.

CAPTURE_ERR_BACKGROUNDED 3

API Level 6.0.3

The audio capture was attempted while the app was in the background.

Typedef Summary collapse

Instance Method Summary collapse

Typedef Details

Callbacks as interface {
function onData(audioData as Lang.ByteArray) as Void;
function onError(error as Capture.Error) as Void;
function onComplete() as Void;
}

Callbacks defines the interface for getting data and information during audio capture.

Since:

API Level 6.0.3

Member Details

onData(audioData as Lang.ByteArray) as Void

This method is called with captured audio data.

Parameters:

  • audioData — (Lang.ByteArray) —

    A buffer of encoded audio data up to the window size.

Since:

API Level 6.0.3

onError(error as Capture.Error) as Void

This method is called if there is an error during audio capture.

Parameters:

Since:

API Level 6.0.3

onComplete() as Void

This method is called when the audio capture ends without an error.

Since:

API Level 6.0.3

Settings as { :format as Audio.AudioFormat, :windowSize as Lang.Number, :windowFilledBehavior as Capture.WindowFilledBehavior, :filters as Lang.Array<Capture.Filter> }

Since:

API Level 6.0.3

Instance Method Details

getState() as Capture.State

Get the current state of audio capture.

Returns:

Since:

API Level 6.0.3

getSupportedFilters() as Lang.Array<Capture.Filter>

Gets a list of capture filters supported by the device.

Returns:

Since:

API Level 6.0.3

initializeAudioCapture(callbacks as Capture.Callbacks, settings as Capture.Settings) as Capture.Settings

Initialize audio capture

Parameters:

  • callbacks — (Capture.Callbacks) —

    Callback interface to be used during audio capture.

  • settings — (Capture.Settings) —

    The settings to be used for audio capture.

Returns:

  • Capture.Settings —

    The settings which will be used for audio capture. This will fill out any defaults that were not included in the settings argument.

Since:

API Level 6.0.3

Throws:

isFormatSupported(format as Audio.AudioFormat) as Lang.Boolean

Checks if the device supports the format for audio capture.

Parameters:

Returns:

Since:

API Level 6.0.3

start() as Void

Start audio capture.

Since:

API Level 6.0.3

stop() as Void

Stop audio capture.

Stopping capture will send any remaining data to the registered callback.

Since:

API Level 6.0.3


Generated Oct 19, 2026, 4:16:38 PM