Module: Toybox.Audio.Capture
Overview
The Capture module provides APIs for capturing audio on the device.
Classes Under Namespace
Classes: InitializationFailedException
Constant Summary
-
Filter
-
WindowFilledBehavior
-
State
-
Error
Filters for audio capture.
| Name | Value | Since | Description |
|---|---|---|---|
| FILTER_NREC | 0 | API Level 6.0.3 |
Noise reduction and echo cancellation. |
What audio capture should do when the window is filled.
| 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. |
| 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. |
| 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
-
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.
- Settings as { :format as Audio.AudioFormat, :windowSize as Lang.Number, :windowFilledBehavior as Capture.WindowFilledBehavior, :filters as Lang.Array<Capture.Filter> }
Instance Method Summary collapse
-
getState() as Capture.State
Get the current state of audio capture.
-
getSupportedFilters() as Lang.Array<Capture.Filter>
Gets a list of capture filters supported by the device.
-
initializeAudioCapture(callbacks as Capture.Callbacks, settings as Capture.Settings) as Capture.Settings
Initialize audio capture.
-
isFormatSupported(format as Audio.AudioFormat) as Lang.Boolean
Checks if the device supports the format for audio capture.
-
start() as Void
Start audio capture.
-
stop() as Void
Stop audio capture.
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.
Settings as { :format as Audio.AudioFormat, :windowSize as Lang.Number, :windowFilledBehavior as Capture.WindowFilledBehavior, :filters as Lang.Array<Capture.Filter> }
Instance Method Details
getState() as Capture.State
Get the current state of audio capture.
getSupportedFilters() as Lang.Array<Capture.Filter>
Gets a list of capture filters supported by the device.
initializeAudioCapture(callbacks as Capture.Callbacks, settings as Capture.Settings) as Capture.Settings
Initialize audio capture
isFormatSupported(format as Audio.AudioFormat) as Lang.Boolean
Checks if the device supports the format for audio capture.
start() as Void
Start audio capture.
stop() as Void
Stop audio capture.
Stopping capture will send any remaining data to the registered callback.