Skip to main content

Audio · AudioStart · AudioExpect

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Capture what the device plays: start, stop with a path to save it as a WAV, or omit the action to ask whether a capture is running. These call app_audio.

Audio​

func (d *Device) Audio(ctx context.Context, action, path string) (Audio, error)

Audio starts ("start") or stops ("stop", saving a WAV to path) a capture of what the device plays, or with an empty action asks whether one is running. Assert on the timeline's sound, silence and pitch; the level follows the device's volume. An Android emulator only.

AudioStart​

func (d *Device) AudioStart(ctx context.Context, app string) (Audio, error)

AudioStart starts a capture for app, whose interruptions the stop reports; Audio with "start" uses the app in front.

AudioExpect​

func (d *Device) AudioExpect(ctx context.Context, path string, expect []AudioExpected, ignoreMs int) (Audio, error)

AudioExpect stops a capture as an assertion: it saves the WAV at path and checks the sounds it held are expect, in order; an empty expect is silence. A sound of ignoreMs or less on its own does not count, but short ones that run on into each other do; 0 keeps the default of 200. Anything else is a not_confirmed error saying what was heard, and the capture is still saved.

Examples​

Start capturing what an app plays​

if _, err := dev.AudioStart(ctx, "dev.mobium.mobiumapp"); err != nil {
return err
}

The same call from the command line, mobium audio start --app dev.mobium.mobiumapp, printed on an Android 15 emulator:

capturing audio — stop it with action "stop" and a path

Stop, save the capture, and assert what was heard​

heard, err := dev.AudioExpect(ctx, "heard.wav", []mobium.AudioExpected{{Hz: 440}}, 0)
if err != nil {
return err
}
fmt.Println(heard.Path, len(heard.Timeline), "segments")

The same call from the command line, mobium audio stop -o heard.wav --expect 440, printed on an Android 15 emulator:

saved …/heard.wav: 3.746s of audio: 0.0–0.5s silence, 0.5–0.6s sound, no one pitch (-46 dBFS), 0.6–2.6s 440 Hz (-42 dBFS), 2.6–3.7s silence — at media volume 5 of 15