$ErrorActionPreference = 'Stop' $root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path $sources = Join-Path $root '.tmp\audio-downloads' $audio = Join-Path $root 'assets\audio' $candidates = Join-Path $audio 'attack-candidates' function Invoke-FFmpeg([string[]]$Arguments) { & ffmpeg @Arguments if ($LASTEXITCODE -ne 0) { throw "ffmpeg failed with exit code $LASTEXITCODE" } } function Mix-IceSound([string]$First, [string]$Second, [string]$Target, [string]$Filter) { Invoke-FFmpeg @('-y','-v','error','-i',$First,'-i',$Second,'-filter_complex',$Filter,'-map','[out]','-ac','1','-ar','48000','-c:a','libvorbis','-q:a','5',$Target) } $legacy = Join-Path $audio 'sfx-attack-legacy.ogg' if (-not (Test-Path -LiteralPath $legacy)) { Copy-Item -LiteralPath (Join-Path $audio 'sfx-attack.ogg') -Destination $legacy } Copy-Item -LiteralPath (Join-Path $candidates 'layered-swish-phaser.ogg') -Destination (Join-Path $audio 'sfx-attack.ogg') -Force $magic1 = Join-Path $sources 'magic-spell\magical_1.ogg' $magic3 = Join-Path $sources 'magic-spell\magical_3.ogg' $phaser = Join-Path $sources 'digital\Audio\phaserUp6.ogg' $swish = Join-Path $sources 'swishes\swishes\swish-9.wav' $glassLight = Join-Path $sources 'impact\Audio\impactGlass_light_001.ogg' $glassHeavy = Join-Path $sources 'impact\Audio\impactGlass_medium_003.ogg' Mix-IceSound $magic1 $phaser (Join-Path $audio 'sfx-ice-bow-charge.ogg') '[0:a]atrim=0:0.64,asetpts=PTS-STARTPTS,volume=0.55[a];[1:a]volume=0.5,adelay=70|70[b];[a][b]amix=2:duration=longest:normalize=0,afade=t=out:st=0.48:d=0.16,loudnorm=I=-18:TP=-2:LRA=7[out]' Mix-IceSound $swish $glassLight (Join-Path $audio 'sfx-ice-arrow.ogg') '[0:a]volume=0.72[a];[1:a]atrim=0:0.42,asetpts=PTS-STARTPTS,volume=0.36,adelay=35|35[b];[a][b]amix=2:duration=longest:normalize=0,afade=t=out:st=0.34:d=0.12,loudnorm=I=-18:TP=-2:LRA=7[out]' Mix-IceSound $magic3 $phaser (Join-Path $audio 'sfx-ice-charge.ogg') '[0:a]atrim=0:0.82,asetpts=PTS-STARTPTS,volume=0.48[a];[1:a]volume=0.42,adelay=180|180[b];[a][b]amix=2:duration=longest:normalize=0,afade=t=out:st=0.64:d=0.18,loudnorm=I=-18:TP=-2:LRA=7[out]' Mix-IceSound $swish $glassHeavy (Join-Path $audio 'sfx-ice-heavy.ogg') '[0:a]volume=0.78[a];[1:a]atrim=0:0.58,asetpts=PTS-STARTPTS,volume=0.62,adelay=85|85[b];[a][b]amix=2:duration=longest:normalize=0,afade=t=out:st=0.46:d=0.15,loudnorm=I=-17:TP=-2:LRA=7[out]' Invoke-FFmpeg @('-y','-v','error','-i',$glassLight,'-af','atrim=0:0.48,asetpts=PTS-STARTPTS,afade=t=out:st=0.34:d=0.14,loudnorm=I=-18:TP=-2:LRA=7','-ac','1','-ar','48000','-c:a','libvorbis','-q:a','5',(Join-Path $audio 'sfx-freeze.ogg')) Write-Host 'Built ice combat sound set and replaced sfx-attack.ogg; legacy sound preserved.'