From 39066900773e7857faf2d02e7ed51b71d219d97d Mon Sep 17 00:00:00 2001 From: godosa Date: Tue, 6 Oct 2026 23:39:36 +0200 Subject: godosa-engine: initial public history --- scripts/audio_report.py | 101 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 scripts/audio_report.py (limited to 'scripts/audio_report.py') diff --git a/scripts/audio_report.py b/scripts/audio_report.py new file mode 100755 index 0000000..14af9ab --- /dev/null +++ b/scripts/audio_report.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +"""Levels (and a spectrogram) of a game audio capture — smoke runs write DIR/audio.wav +through OpenAL Soft's wave backend (audio spec §8). The game is killed at the end of a +run, so the WAV header sizes may be unfinished: data is read to end of file. + +Usage: scripts/audio_report.py WAV [--png OUT.png] [--start S] [--end S] + prints one line per second: RMS and peak in dBFS (mono mix) + --png: spectrogram of [start, end] via ffmpeg (skipped if ffmpeg is missing) +""" +import argparse +import array +import math +import shutil +import struct +import subprocess +import sys +import tempfile +from pathlib import Path + + +def read_wav(path): + """Returns (rate, channels, samples as list of ints, interleaved). 16-bit PCM only.""" + data = Path(path).read_bytes() + if data[:4] != b"RIFF" or data[8:12] != b"WAVE": + raise ValueError("not a RIFF/WAVE file") + pos, rate, channels, bits = 12, None, None, None + while pos + 8 <= len(data): + cid, size = data[pos:pos + 4], struct.unpack("