mapcreator git · master
SDL3 2.5D game and engine using assets, with map editor
C++ 99.3%git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gzFix make record breakable
scripts/audio/record.sh | 50 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/scripts/audio/record.sh b/scripts/audio/record.sh index 5f19a61..5be1348 100755 --- a/scripts/audio/record.sh +++ b/scripts/audio/record.sh @@ -13,6 +13,31 @@ show_help() { echo "Outputs WAV to <output_name>.wav and plays it back." } +stop_recording() { + echo + echo "Stopping recording..." + # 2. Process the recorded audio with sox + sox "$tmp0" "$tmp1" highpass 120 remix 1,2 gain -n + + # 2. Remove mic crack (first 50ms) + ffmpeg -hide_banner -loglevel error -i "$tmp1" -ss 0.05 -c copy "$tmp2" + + # 3. Loudness normalize (LUFS) and back to 44100 Hz + ffmpeg -hide_banner -loglevel error -i "$tmp2" \ + -af "loudnorm=I=-18:TP=-1.5:LRA=7, aresample=44100, pan=mono|c0=0.5*c0+0.5*c1" \ + "${name}.wav" + + # Cleanup temporary files + rm -f "$tmp0" "$tmp1" "$tmp2" + + # 4. Playback + echo "Done. Playing back..." + aplay "${name}.wav" + + echo "Recording saved as ${name}.wav" +} +trap stop_recording SIGINT + if [[ $# -eq 0 || "$1" == "--help" || "$1" == "-h" ]]; then show_help exit 0 @@ -28,29 +53,16 @@ name="$1" duration="$2" # Temporary files -tmp1="${name}_raw.wav" +tmp0="${name}_raw.wav" +tmp1="${name}_ra1w.wav" tmp2="${name}_trim.wav" echo "Recording $duration seconds into $name.wav..." # 1. Record → high-pass → mono → peak normalize -arecord --duration="$duration" --format=cd | \ -sox -t wav -r 44100 -e signed-integer -b 16 -c 2 - \ - "$tmp1" highpass 120 remix 1,2 gain -n - -# 2. Remove mic crack (first 50ms) -ffmpeg -hide_banner -loglevel error -i "$tmp1" -ss 0.05 -c copy "$tmp2" - -# 3. Loudness normalize (LUFS) and back to 44100 Hz -ffmpeg -hide_banner -loglevel error -i "$tmp2" \ --af "loudnorm=I=-18:TP=-1.5:LRA=7, aresample=44100, pan=mono|c0=0.5*c0+0.5*c1" \ -"${name}.wav" - -# Cleanup temporary files -rm -f "$tmp1" "$tmp2" +arecord --duration="$duration" --format=cd "$tmp0" -# 4. Playback -echo "Done. Playing back..." -aplay "${name}.wav" +# Remove trap +trap - SIGINT -echo "Recording saved as ${name}.wav" +stop_recording