Hello,
I am publishing a script that convert a batch of audio samples to be “polyend play/play+” compatible.
I know that this script is similar to another script posted on this forum ( Bash script to convert samples to 16bit 44.1kHz mono with ffmpeg ) but mine is a bit different
let me explain:
- I have a polyend play+
- I bought some sample packs and I have my own samples/loops
- Those samples are STEREO, 24 bits, 48khz, etc. I have folders, sub-folders…
- If you try to import the samples that are 24 bits / stereo … I got errors as my polyend play/Play+ is 16 bits/Mono compatible.
- The script proposed on this forum ( Bash script to convert samples to 16bit 44.1kHz mono with ffmpeg ) convert only one folder whereas I want to convert all the files/samples that are included in folders and sub-folders.
So my script take the root folder of my Polyend Play/Play+ Micro SDCARD and process files that are in folders/sub-folders and recreate on my computer the same structure:
-
The script looks at the folders and sub-fodlers, process each sample file from 24 bits to 16 bits/mono and copy it to the same original folders/sub-folders.
-
Once my script has finished the process, I just have to remove on my sdcard my original samples and copy back the folder my script as created on my computer.
Note that the script uses SOX opensource program (like ableton live!), so you will need to install SOX before.
Here is the script :
#!/bin/bash
# Check that we have 2 arguments : source folder and destination
if [ $# -ne 2 ]; then
echo "Usage: $0 <source_folder> <destination_folder>"
exit 1
fi
SRC_DIR="$1"
DEST_DIR="$2"
# WAV MP3 FLAC... that can be processed
EXTENSIONS=("wav" "WAV" "mp3" "MP3" "flac" "FLAC" "aiff" "AIFF")
# For loop :-)
for ext in "${EXTENSIONS[@]}"; do
# Get all the files that should be processed according to their extension
find "$SRC_DIR" -type f -name "*.${ext}" | while read -r file; do
# Build the relative path - Source -
rel_path="${file#$SRC_DIR/}"
# Build the relative path - Dzstination - DEST_DIR
out_path="$DEST_DIR/$rel_path"
# Create the destination folder
mkdir -p "$(dirname "$out_path")"
# Conversion in 16 bits (using SOX program)
echo "[sox] Processing: $file → $out_path"
sox "$file" -b 16 "$out_path"
done
done
echo "Process done."
Don’t hesitate to send me your feedbacks, questions, etc.
Regards