You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
709 B

#!/bin/bash
IFS=$'\n'
filename_stripped=""
stop_playback () {
aplaymidi -p 24:0 ./stopm.mid
exit
}
record () {
while ! $(ps a | grep '[a]playmidi' > /dev/null)
do
:
done
parec -d alsa_input.pci-0000_00_1b.0.analog-stereo > "$filename_stripped.raw" &
}
trap stop_playback INT
for file in $(find "$1" -maxdepth 1 -iname "*.mid" | sort)
do
filename_stripped=$(echo $file | sed -r "s/.+\/(.+)\..+/\1/")
echo "Playing $filename_stripped"
record &
aplaymidi -p 24:0 $file
aplaymidi -p 24:0 ./stopm.mid
kill -INT $(pidof parec)
flac -f --delete-input-file --endian little --sign signed --channels 2 --bps 16 --sample-rate 44100 "$filename_stripped.raw"
done