Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
test: compare synthetic loop lengths across browser codecs
Soohong Kimac79bae3885d
diff --git a/tests/audio/prepare_playback_fixture.py b/tests/audio/prepare_playback_fixture.pynew file mode 100644index 0000000..1065e3e--- /dev/null+++ b/tests/audio/prepare_playback_fixture.py@@ -0,0 +1,33 @@+# SPDX-License-Identifier: Apache-2.0+"""Create one synthetic encoded bundle for render_playback.mjs; no provider calls."""+import json+from pathlib import Path+import sys+import wave++import numpy as np++from sprite_gen.audio import playback, processing+++def prepare(directory):+ directory = Path(directory)+ directory.mkdir(parents=True)+ source = directory/'source.wav'+ frames = 144003 # fractional destination frame at 44.1 kHz+ t = np.arange(frames)/48000+ samples = np.stack([.1*np.sin(2*np.pi*317*t+.5), .3*np.cos(2*np.pi*73*t)], axis=1)+ with wave.open(str(source), 'wb') as stream:+ stream.setnchannels(2)+ stream.setsampwidth(2)+ stream.setframerate(48000)+ stream.writeframes((samples*32767).astype('<i2').tobytes())+ details = processing.export(source, directory, target_lufs=-20, loop=True, crossfade=.25)+ manifest = {'kind':'sprite-gen-sound', 'version':playback.VERSION, 'audio_kind':'bgm',+ 'event':'synthetic.loop', 'loop':True, 'target_lufs':-20, **details}+ (directory/'sound.json').write_text(json.dumps(manifest, indent=2)+'\n')+ return manifest+++if __name__ == '__main__':+ prepare(sys.argv[1])diff --git a/tests/audio/render_playback.mjs b/tests/audio/render_playback.mjsindex 50d705f..8803555 100644--- a/tests/audio/render_playback.mjs+++ b/tests/audio/render_playback.mjs@@ -178,5 +178,10 @@ for (const [name, engine] of Object.entries({ chromium, webkit })) {}} finally { await browser.close(); }}+for (const item of cases) for (const rate of [44100,48000]) {+ const rows=reports.filter(row=>row.name===item.name && row.rate===rate);+ assert.equal(rows.length,4, 'both codecs must render in both engines');+ assert.equal(new Set(rows.map(row=>row.length)).size,1, 'engine or codec changed the loop length');+}await writeFile(resolve(outputDir,'render.json'),JSON.stringify({module_sha256:digest,reports},null,2));console.log(JSON.stringify({passed:reports.length,module_sha256:digest}));