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​

public IDictionary<string, object?> Audio(string? action = null, string? path = null)

Captures what the device plays: action "start", or "stop" with a path to save a WAV; neither asks whether a capture is running. Stop returns a timeline of segments — from and to in nanoseconds, sound, and for a sound its hz (0 with no one pitch) and level in dBFS, and the volumes it was taken at. Assert on sound, silence and pitch; the level follows the device's volume, and at its lowest a playing app is silence. An Android emulator only. A relative path is this process's.

AudioStart​

public IDictionary<string, object?> AudioStart(string app)

Starts a capture for an app: stop then reports what interrupted it — a call muting it, a ringtone, alarm or notification over it — in interruptions. Audio with "start" uses the app in front. On an Android phone only the interruptions are recorded: nothing outside it hears the sound.

AudioExpect​

public IDictionary<string, object?> AudioExpect(string path, IEnumerable<IDictionary<string, object?>> expect, int? ignoreMs = null)

Stops a capture as an assertion: saves the WAV at path and checks the sounds it held, in order — each a dictionary with hz, and optional min_ms and max_ms; an empty list is silence. A sound of ignoreMs or less on its own does not count, but short ones that run on into each other do; null keeps the default of 200. Anything else throws NotConfirmedException saying what was heard, and the capture is still saved.

Examples​

Start capturing what an app plays​

device.AudioStart("dev.mobium.mobiumapp");

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​

var heard = device.AudioExpect("heard.wav", new List<IDictionary<string, object?>>
{
new Dictionary<string, object?> { ["hz"] = 440 },
});

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