feat(windows): sound, through XAudio2

audio_win.ll implements audio.ll's snd_* contract over XAudio2 from IR: a
source voice per clip, restart on play, LoopCount for loops, SetVolume,
SetFrequencyRatio and a balance pan through SetOutputMatrix, with the COM
slots taken from the SDK's xaudio2.h. Clips are RIFF WAVE read through
lp_pak_open (weakly referenced), so a packed sound loads directly. ludicc links
it with xaudio2 and ole32, and silences xinput.lib's importeddllmain warning.

Verified: ludic-dev test 135/135, selfhost-test 32/32; on the PC a harness
loads, plays, pans, loops and stops clips, and Maroon Lake windowed reports
"sound: 31 of 31 clips loaded".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-13 02:42:48 +03:00
parent 00d25dcc3e
commit 3300fb3957
4 changed files with 646 additions and 231 deletions

View file

@ -237,10 +237,12 @@ entry {
# for pads), and audio_win.ll when the program uses Audio.*, as on macOS.
if g_windowed {
let win32 = join_path(home, "runtime/native/win32.ll")
cmd = `{cmd} {win32} -luser32 -lgdi32 -lxinput`
# xinput.lib carries an import named DllMain, which lld skips with a warning on every
# link; it is the SDK's, not a mistake in the program, so it is silenced
cmd = `{cmd} {win32} -luser32 -lgdi32 -lxinput -Wl,/ignore:importeddllmain`
if g_uses_audio {
let audiow = join_path(home, "runtime/native/audio_win.ll")
cmd = `{cmd} {audiow}`
cmd = `{cmd} {audiow} -lxaudio2 -lole32`
}
}
}