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 Map<String, Object> audio(String action, String path)

Captures what the device plays: action "start", or "stop" with a path to save a WAV; null 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.

@param action "start", "stop", or null to ask whether one is running @param path where to save the WAV on stop, or null @return whether a capture is running, or on stop its timeline

audioStart​

public Map<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(String, String) with "start" uses the app in front. On an Android phone only the interruptions are recorded: nothing outside it hears the sound.

@param app the app's package @return that a capture is running

audioExpect​

public Map<String, Object> audioExpect(String path, List<Map<String, Object>> expect, Integer ignoreMs)

Stops a capture as an assertion: saves the WAV at path and checks the sounds it held, in order — each a map 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.

@param path where to save the WAV @param expect the sounds to hear, in order @param ignoreMs how short a sound may be and not count, or null @return the capture's timeline and volumes

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​

Map<String, Object> heard = device.audioExpect("heard.wav", List.of(Map.of("hz", 440)), null);
System.out.println(heard.get("timeline"));

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