Skip to content

host/audio_input: DM_MIC_FILE plays a recording, DM_MIC_DUMP records - #3000

Open
The-Inceptions wants to merge 1 commit into
seedds:mainfrom
The-Inceptions:mic-recording-feed
Open

The-Inceptions wants to merge 1 commit into
seedds:mainfrom
The-Inceptions:mic-recording-feed

Conversation

@The-Inceptions

Copy link
Copy Markdown
Contributor

What and why

Testing a game's microphone input needs someone at the microphone every time, humming the same tune at the same level, and a miss cannot be played back to see what the game was given. Ocarina of Time's Ocarina Mic Input shows why that matters: whether a hum is taken for the right song depends on its level, and live humming at a laptop is never twice the same. c25d4011 notes that fresh microphone gameplay still needs hardware validation; this makes that repeatable.

  • DM_MIC=1 DM_MIC_FILE=<file> (Mac) plays a recording to a game's input streams in place of a microphone, through the same queues, gain and limiter. Any file AudioToolbox reads (WAV, M4A, MP3, ...) is decoded, its channels averaged and resampled to 48 kHz; a .pcm or .raw file is 16-bit mono samples at 48 kHz. A thread of its own hands it to dm_audio_input_process in 512-frame blocks at the pace of a 48 kHz device, from its start each time the capture starts, then silence. No device is opened and no microphone permission is involved. audio_input_mac.m routes its platform hooks to it while DM_MIC_FILE is set. The log says when the game stops listening, so a script can tell a recording the game took for a song from one it listened through.
  • DM_MIC_DUMP=<file> writes what the capture hands the streams, before any gain, in the form DM_MIC_FILE plays back; each capture logs where it starts in the file. It writes from the capture callback, so it is a test switch, not one for play.

Both are diagnostics in docs/env_switches.tsv, with no launcher setting. The gain table in the test report on #1822 was made with them.

Checked

  • Tests: make -C dm/host/tests GAME=0400486024DEC000 audio-input-file (a 441 Hz tone written as a stereo 44.1 kHz WAV reaches a stream in real time at 441 Hz and half scale, then silence; the dump holds the same samples, and played back as a .pcm file in a fresh process gives them again) and audio-input; the host test suite (make -C dm/host/tests GAME=0400486024DEC000 run); make -C dm/gfx/tests GAME=0400486024DEC000 -k run on Apple silicon: everything but check_t_dlss_mfx and check_t_dlss_scaler, which fail the same way on main (0b5fd602); test_usage, test_nsp_mac_app, test_docs, test_env_switches; python3 dm/tools/docs_symptoms.py (no change); lint_c.py tidy --against main with LLVM 23.1.4: no finding in the changed files (the one file/check pair above the baseline, bugprone-suspicious-memory-comparison in dm/gfx/tests/t_gl_imports.m, is in a file this change does not touch); lint_python.py --against main: 0 new
  • Games run: before Audio input streams on the Mac's microphone: Ocarina of Time's ocarina can be played into it, with a launcher permission step, device picker and gain #1822 was reworked into main, on its capture (the feed itself is unchanged here): Ocarina of Time (0400486024DEC000, v131072), headless with the game's sound off, one person's recorded hum of Zelda's Lullaby played as the microphone over 100 times at levels and gains from 1x to 8x, the song the game played back each time read from DM_AUDIO_DUMP; and a live session's 16 s of a DualSense's USB mic kept with DM_MIC_DUMP, with no underruns, zero fill or drops. Not yet played on this base.
  • Devices and OS: MacBook Pro, M5 Pro, macOS 27.2.
  • regress.py: regress.py impact maps the change to the hle:*InputStream* rows (the games that import the SDK's input streams; its new files are in dm/tools/impact_map.tsv). The new code runs only with DM_MIC_FILE or DM_MIC_DUMP set, so no game's default path changes and no regress.py check was run.

Docs

  • docs/env_switches.tsv lists both switches, and the docs/reference/audio.md entry for the input streams says how to check them with a recording; python3 dm/tools/docs_symptoms.py was run
  • No game files, keys or data extracted from a game in the change or the attachments (the test writes its own tone)

🤖 Generated with Claude Code

Testing a game's audio input needed someone at the microphone every time, humming the same tune at
the same level, and a miss could not be played back to see what the game had been given. Ocarina of
Time's Ocarina Mic Input (0400486024DEC000, v131072) shows why that matters: whether a hum is taken
for the right song depends on its level, and live humming at a laptop is never twice the same.

With DM_MIC=1, DM_MIC_FILE=<file> (Mac) plays a recording to a game's input streams in place of a
microphone. Any
file AudioToolbox reads (WAV, M4A, MP3, ...) is decoded, its channels averaged and resampled to
48 kHz; a .pcm or .raw file is 16-bit mono samples at 48 kHz. A thread of its own hands it to
dm_audio_input_process in 512-frame blocks at the pace of a 48 kHz device, from its start each time
the capture starts, then silence. No device is opened and no microphone permission is involved.
Another file named while the game runs (DM_CTL's env) is read at the next capture. The log says when
the game stops listening, so a script can tell a recording the game took for a song from one it
listened through.

DM_MIC_DUMP=<file> writes what the capture hands the streams, before any gain, as 16-bit mono
samples at 48 kHz without a header, the form DM_MIC_FILE plays back; each capture logs where it
starts in the file. It writes from the capture callback, so it is a test switch, not one for play.
Both are diagnostics (docs/env_switches.tsv), with no launcher setting.

Checked: t_audio_input_file (make -C dm/host/tests GAME=<id> audio-input-file): a 441 Hz tone
written as a stereo 44.1 kHz WAV reaches a stream in real time at 441 Hz and half scale, then
silence; the dump holds the same samples; and the dump, played back as a .pcm file in a fresh
process, gives them again. The host test suite. Before seedds#1822 was reworked into main, on its
capture (the feed itself is unchanged here): Ocarina of Time on an M5 Pro with macOS 27.2,
headless, with the game's sound off: one person's recorded hum of Zelda's Lullaby played as the
microphone over 100 times at levels and gains from 1x to 8x, the song the game played back each
time read from DM_AUDIO_DUMP; and a live session's 16 s of a DualSense's USB mic kept with
DM_MIC_DUMP, with no underruns, zero fill or drops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) tools Tools and scripts (dm/tools, scripts) docs Documentation labels Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation host The Horizon host: SVCs, services, threads, memory (dm/host) tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant