Repository navigation
host/audio_input: DM_MIC_FILE plays a recording, DM_MIC_DUMP records - #3000
Open
The-Inceptions wants to merge 1 commit into
Open
The-Inceptions wants to merge 1 commit into
The-Inceptions wants to merge 1 commit into
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
c25d4011notes 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.pcmor.rawfile is 16-bit mono samples at 48 kHz. A thread of its own hands it todm_audio_input_processin 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.mroutes its platform hooks to it whileDM_MIC_FILEis 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 formDM_MIC_FILEplays 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
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.pcmfile in a fresh process gives them again) andaudio-input; the host test suite (make -C dm/host/tests GAME=0400486024DEC000 run);make -C dm/gfx/tests GAME=0400486024DEC000 -k runon Apple silicon: everything butcheck_t_dlss_mfxandcheck_t_dlss_scaler, which fail the same way onmain(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 mainwith LLVM 23.1.4: no finding in the changed files (the one file/check pair above the baseline,bugprone-suspicious-memory-comparisonindm/gfx/tests/t_gl_imports.m, is in a file this change does not touch);lint_python.py --against main: 0 newmain, 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 fromDM_AUDIO_DUMP; and a live session's 16 s of a DualSense's USB mic kept withDM_MIC_DUMP, with no underruns, zero fill or drops. Not yet played on this base.regress.py:regress.py impactmaps the change to thehle:*InputStream*rows (the games that import the SDK's input streams; its new files are indm/tools/impact_map.tsv). The new code runs only withDM_MIC_FILEorDM_MIC_DUMPset, so no game's default path changes and noregress.py checkwas run.Docs
docs/env_switches.tsvlists both switches, and thedocs/reference/audio.mdentry for the input streams says how to check them with a recording;python3 dm/tools/docs_symptoms.pywas run🤖 Generated with Claude Code