'Tis the season for spreading holiday cheer, and what better way than with a custom-crafted Christmas party mix? This year, I dove back into the world of CD burning, armed with a bash script I created that transforms raw MP3s into a festive audio experience!
The script does the following:
Checks and installs necessary audio tools
Normalizes track volumes
Removes awkward silences
xxxxxxxxxx
set -evu
set -o pipefail
# Dependency check and installation
command -v brew >/dev/null 2>&1 || { echo "Homebrew required but not installed. Exiting."; exit 1; }
# Install or upgrade dependencies
brew install sox mp3gain || { echo "Failed to install audio processing tools"; exit 1; }
# Optional: Warn if burn fails, but don't stop script
brew install --cask burn || { echo "Failed to install burn"; exit 1; }
mp3gain -r -T ./*.mp3
# Prepare output directory
export DIR='./final'
mkdir -p "$DIR"
ls *.mp3 | perl -MTerm::ANSIColor=':constants' -snlE'
$cmd = $sox =~ s~(INPUT)|OUTPUT~$1 ? $_ : qq|${dir}/$_|~ger;
say q|> |, GREEN $cmd, RESET;
system $cmd;
' -- -dir="$DIR" -sox='sox -V "INPUT" "OUTPUT" silence 1 0.1 2% reverse silence 1 0.1 2% reverse || echo "Sox processing failed"'
Let's unwrap this script like a Christmas present and examine each line:
xxxxxxxxxx
set -evu
set -o pipefail
-e
: Exit immediately if a command exits with a non-zero status
-v
: Verbose mode (prints shell input lines)
-u
: Treat unset variables as an error
-o pipefail
: Ensures that a pipeline returns a non-zero status if any command fails
xxxxxxxxxx
command -v brew >/dev/null 2>&1 || { echo "Homebrew required but not installed. Exiting."; exit 1; }
Checks if Homebrew is installed
If not found, prints an error message and exits
>/dev/null 2>&1
silences any output
xxxxxxxxxx
brew install sox mp3gain || { echo "Failed to install audio processing tools"; exit 1; }
Installs SoX (Sound eXchange) and MP3Gain
Provides an error message if installation fails
xxxxxxxxxx
brew install --cask burn || { echo "Failed to install burn"; exit 1; }
Attempts to install the Burn CD/DVD burning application and fails gracefully if installation doesn't work.
Burn is a free, open-source Mac utility that makes disc burning as easy as wrapping a present. Create audio CDs, data discs, and video DVDs with just a few clicks. Lightweight, user-friendly, and perfect for holiday mixtapes and quick backups. No fancy features, just straightforward disc creation! đđĨ
xxxxxxxxxx
mp3gain -r -T ./*.mp3
-r
: Applies track gain adjustments
-T
: Prevents audio clipping
Processes all MP3 files in the current directory
xxxxxxxxxx
export DIR='./final'
mkdir -p "$DIR"
Creates a 'final' directory for processed files
-p
flag ensures no error if directory exists
xxxxxxxxxx
ls *.mp3 | perl -MTerm::ANSIColor=':constants' -snlE'
$cmd = $sox =~ s~(INPUT)|OUTPUT~$1 ? $_ : qq|${dir}/$_|~ger;
say q|> |, GREEN $cmd, RESET;
system $cmd;
' -- -dir="$DIR" -sox='sox -V "INPUT" "OUTPUT" silence 1 0.1 2% reverse silence 1 0.1 2% reverse || echo "Sox processing failed"'
Lists all MP3 files
Uses Perl to:
Process each file through SoX
Remove silence from start and end
Display processing commands in green
Handle potential processing errors
Creating a holiday mix is more than just burning a CD - it's about crafting memories, spreading joy, and sharing the spirit of the season. With this script, you're not just a music lover; you're a holiday audio engineer!
Happy Holidays and Happy Burning! đđļ
Note: Always ensure you have the rights to the music you're burning, and keep the holiday spirit legal and respectful!