Files
logic-puzzle/scripts/check_soundscape_assets.py
Hadrian Burkhardt 68871ec573 Expand narrated story, preserve solved patterns, and add ambience
Connect the island story with new character memories and narrative transitions.
Blend each solved symbol into its artwork and retain a replayable pattern stamp.
Allow completed grids to be inspected after navigation and app restarts.
Reduce campaign difficulty spikes and keep explained story hints free.

Append 24 narrated continuations while preserving original PCM takes. Add
four offline environmental loops with saved mute/volume controls, scene
fades, narration ducking and lifecycle handling.

Validation: 31 unit/widget tests, Flutter analysis, narration and soundscape
asset checks, tablet discovery layouts and extended-audio integration,
including simultaneous active voice and ambience mixer tracks.
2026-11-02 05:04:57 +01:00

30 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Check bundled soundscapes without synthesis dependencies."""
import array
import hashlib
import json
import math
import wave
from pathlib import Path
root = Path(__file__).resolve().parents[1]
audio = root / 'assets/audio'
manifest = json.loads((audio / 'ambience_manifest.json').read_text())
assert set(manifest['tracks']) == {'cottage', 'harbour', 'bridge', 'tower'}
pubspec = (root / 'pubspec.yaml').read_text()
for scene, track in manifest['tracks'].items():
path = audio / track['file']
assert 'assets/audio/' + path.name in pubspec
assert hashlib.sha256(path.read_bytes()).hexdigest() == track['wavSha256']
with wave.open(str(path), 'rb') as reader:
assert reader.getnchannels() == 1 and reader.getsampwidth() == 2
assert reader.getframerate() == track['sampleRate'] == 24000
assert reader.getnframes() == track['frames']
samples = array.array('h', reader.readframes(reader.getnframes()))
rms = math.sqrt(sum(v * v for v in samples) / len(samples)) / 32768
peak = max(abs(v) for v in samples) / 32768
assert .05 < rms < .15 and peak < .73, 'Silent or clipped soundscape'
assert abs(samples[-1] - samples[0]) <= 1, 'Discontinuous loop join'
assert track['durationMs'] == len(samples) * 1000 // 24000
print(f'PASS {scene}: bundled PCM, checksum, level and loop join verified')