42 lines
2.8 KiB
PowerShell
42 lines
2.8 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
|
$sources = Join-Path $root '.tmp\audio-downloads'
|
|
$output = Join-Path $root 'assets\audio\attack-candidates'
|
|
New-Item -ItemType Directory -Path $output -Force | Out-Null
|
|
|
|
function Invoke-FFmpeg([string[]]$Arguments) {
|
|
& ffmpeg @Arguments
|
|
if ($LASTEXITCODE -ne 0) { throw "ffmpeg failed with exit code $LASTEXITCODE" }
|
|
}
|
|
|
|
function Convert-Candidate([string]$Source, [string]$Name, [string]$Filter = 'loudnorm=I=-18:TP=-2:LRA=7') {
|
|
$target = Join-Path $output $Name
|
|
Invoke-FFmpeg @('-y','-v','error','-i',$Source,'-af',$Filter,'-ac','1','-ar','48000','-c:a','libvorbis','-q:a','5',$target)
|
|
}
|
|
|
|
$swishRoot = Join-Path $sources 'swishes\swishes'
|
|
foreach ($number in 1,2,3,4,7,8,9,12) {
|
|
Convert-Candidate (Join-Path $swishRoot "swish-$number.wav") ("physical-swish-{0:d2}.ogg" -f $number)
|
|
}
|
|
Convert-Candidate (Join-Path $sources 'rpg\Audio\knifeSlice.ogg') 'physical-knife-slice-alt.ogg'
|
|
|
|
Convert-Candidate (Join-Path $sources 'digital\Audio\phaserUp2.ogg') 'energy-phaser-rise.ogg'
|
|
Convert-Candidate (Join-Path $sources 'digital\Audio\phaseJump2.ogg') 'energy-phase-snap.ogg'
|
|
Convert-Candidate (Join-Path $sources 'digital\Audio\laser3.ogg') 'energy-laser-short.ogg' 'atrim=0:0.55,asetpts=PTS-STARTPTS,afade=t=out:st=0.42:d=0.13,loudnorm=I=-18:TP=-2:LRA=7'
|
|
Convert-Candidate (Join-Path $sources 'magic-spell\magical_1.ogg') 'energy-magic-01-short.ogg' 'atrim=0:0.58,asetpts=PTS-STARTPTS,afade=t=out:st=0.43:d=0.15,loudnorm=I=-18:TP=-2:LRA=7'
|
|
Convert-Candidate (Join-Path $sources 'magic-spell\magical_2.ogg') 'energy-magic-02-short.ogg' 'atrim=0:0.58,asetpts=PTS-STARTPTS,afade=t=out:st=0.43:d=0.15,loudnorm=I=-18:TP=-2:LRA=7'
|
|
Convert-Candidate (Join-Path $sources 'magic-spell\magical_3.ogg') 'energy-magic-03-short.ogg' 'atrim=0:0.58,asetpts=PTS-STARTPTS,afade=t=out:st=0.43:d=0.15,loudnorm=I=-18:TP=-2:LRA=7'
|
|
|
|
function Mix-Candidate([string]$First, [string]$Second, [string]$Name, [double]$SecondVolume, [int]$DelayMs = 0) {
|
|
$target = Join-Path $output $Name
|
|
$filter = "[0:a]volume=0.92[a];[1:a]atrim=0:0.58,asetpts=PTS-STARTPTS,volume=$SecondVolume,adelay=$DelayMs|$DelayMs[b];[a][b]amix=inputs=2:duration=longest:normalize=0,loudnorm=I=-18:TP=-2:LRA=7[out]"
|
|
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)
|
|
}
|
|
|
|
Mix-Candidate (Join-Path $swishRoot 'swish-3.wav') (Join-Path $sources 'digital\Audio\phaserUp2.ogg') 'layered-swish-phaser.ogg' .48 8
|
|
Mix-Candidate (Join-Path $swishRoot 'swish-7.wav') (Join-Path $sources 'magic-spell\magical_2.ogg') 'layered-swish-magic.ogg' .30 12
|
|
Mix-Candidate (Join-Path $sources 'rpg\Audio\knifeSlice.ogg') (Join-Path $sources 'digital\Audio\phaseJump2.ogg') 'layered-knife-phase.ogg' .42 0
|
|
|
|
Write-Host "Built attack candidates in $output"
|