new script to generate mp3s

This commit is contained in:
Clément Le Bihan
2024-01-08 22:50:20 +01:00
parent c5fd4aa7d5
commit 9012a6a9d8

View File

@@ -3,14 +3,15 @@
# Iterate through subfolders # Iterate through subfolders
find . -type d | while read -r dir; do find . -type d | while read -r dir; do
# Check if .midi file exists in the subfolder # Check if .midi file exists in the subfolder
midi_file=$(find "$dir" -maxdepth 1 -type f -name '*.midi' -o -name '*.mid' | head -n 1) midi_file=$(find "$dir" -maxdepth 1 -type f -name '*.midi' | head -n 1)
if [ -n "$midi_file" ]; then if [ -n "$midi_file" ]; then
# Create output file name (melody.mp3) in the same subfolder # Create output file name (melody.mp3) in the same subfolder
output_file="${dir}/melody.mp3" output_file="${dir}/melody.mp3"
# Run the given command # Run the given command
timidity "$midi_file" -Ow -o - | ffmpeg -i - -acodec libmp3lame -ab 64k "$output_file" #timidity "$midi_file" -Ow -o - | ffmpeg -i - -acodec libmp3lame -ab 64k "$output_file"
fluidsynth -a alsa -T raw -F - "$midi_file" | ffmpeg -f s32le -i - "$output_file"
echo "Converted: $midi_file to $output_file" echo "Converted: $midi_file to $output_file"
fi fi