#!/usr/bin/env bash
# Writes DIR/alsoft.conf so OpenAL Soft renders to DIR/audio.wav (wave backend, stereo
# int16) instead of the speakers, and removes an old DIR/audio.wav. Run the game with
# ALSOFT_CONF=DIR/alsoft.conf. Env: ALSOFT_EXTRA="key = value" lines added to [general].
# Usage: alsoft_wave.sh DIR
set -euo pipefail
out=${1:?usage: alsoft_wave.sh DIR}
mkdir -p "$out"
rm -f "$out/audio.wav"
cat >"$out/alsoft.conf" <<CONF
[general]
drivers = wave
channels = stereo
sample-type = int16
${ALSOFT_EXTRA:-}
[wave]
file = $out/audio.wav
CONF