Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix: taper loop boundaries before lossy audio encoding
Soohong Kim0e8980da0323
diff --git a/sprite_gen/audio/processing.py b/sprite_gen/audio/processing.pyindex b4415fd..52c63d8 100644--- a/sprite_gen/audio/processing.py+++ b/sprite_gen/audio/processing.py@@ -13,6 +13,7 @@ import subprocessimport numpy as npRATE = 48000+CODEC_TAPER_SECONDS = .005def require_tools():@@ -49,7 +50,14 @@ def make_loop(samples, seconds):raise ValueError('loop crossfade must be positive and shorter than half the source')weight = (.5 - .5 * np.cos(np.linspace(0, np.pi, count)))[:, None]overlap = samples[-count:] * (1 - weight) + samples[:count] * weight- return np.concatenate((samples[count:-count], overlap)).astype('<f4')+ output = np.concatenate((samples[count:-count], overlap)).astype('<f4')+ # Lossy encoders have no preceding signal at the beginning of a standalone file.+ # A short, smooth zero boundary prevents that priming error becoming a wrap impulse.+ guard = min(round(CODEC_TAPER_SECONDS * RATE), len(output)//4)+ taper = (.5 - .5*np.cos(np.linspace(0, np.pi, guard)))[:, None]+ output[:guard] *= taper+ output[-guard:] *= taper[::-1]+ return outputdef _pcm_args():@@ -141,4 +149,5 @@ def export(source: Path, out_dir: Path, *, target_lufs, loop, crossfade):return {'files': files, 'duration_seconds': duration, 'source_duration_seconds': source_seconds,'sample_rate': RATE, 'loop_start_seconds': 0, 'loop_end_seconds': duration,'crossfade_seconds': crossfade if loop else 0,+ 'codec_taper_seconds': CODEC_TAPER_SECONDS if loop else 0,'normalization': {'method': 'loudnorm-two-pass', 'peak_limit_dbtp': -2, 'gain_limiter_passes': corrections}}