Files
spacetris/convert_to_ogg.ps1
2025-11-30 15:19:14 +01:00

46 lines
1.4 KiB
PowerShell

# Convert MP3 sound effects to OGG Vorbis format for cross-platform playback
# Requires ffmpeg (https://ffmpeg.org/). OGG keeps files small while SDL's decoders
# work everywhere the game ships.
$musicDir = "assets\music"
$sourceFiles = @(
"amazing.mp3",
"boom_tetris.mp3",
"great_move.mp3",
"impressive.mp3",
"keep_that_ryhtm.mp3",
"lets_go.mp3",
"nice_combo.mp3",
"smooth_clear.mp3",
"triple_strike.mp3",
"well_played.mp3",
"wonderful.mp3",
"you_fire.mp3",
"you_re_unstoppable.mp3",
"hard_drop_001.mp3",
"new_level.mp3",
"Every Block You Take.mp3"
)
if (!(Get-Command ffmpeg -ErrorAction SilentlyContinue)) {
Write-Host "ffmpeg is required. Install via https://ffmpeg.org/ or winget install Gyan.FFmpeg" -ForegroundColor Red
exit 1
}
Write-Host "Converting MP3 sound effects to OGG..." -ForegroundColor Cyan
foreach ($file in $sourceFiles) {
$src = Join-Path $musicDir $file
if (!(Test-Path $src)) {
Write-Host "Skipping (missing): $src" -ForegroundColor Yellow
continue
}
$ogg = ($file -replace ".mp3$", ".ogg")
$dest = Join-Path $musicDir $ogg
Write-Host "-> $ogg" -ForegroundColor Green
& ffmpeg -y -i $src -c:a libvorbis -qscale:a 4 $dest > $null 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to convert $file" -ForegroundColor Red
}
}
Write-Host "Conversion complete." -ForegroundColor Green