#!/bin/sh # icon from: # https://vectorified.com/images/guitar-tuner-icon-28.jpg # ...installed via: # convert guitar-tuner-icon-28.jpg .local/share/icons/hicolor/256x256/apps/ztunekey.png if [ "$1" = "--help" ]; then cat < $tunefile & find_key -q "$tmpfile" > $keyfile & wait ) | zenity --progress --no-cancel $ZOPT --icon-name=ztunekey --text="$bn" --pulsate --auto-close TUNING="$( cat $tunefile )" KEY="$( cat $keyfile )" rm -f $keyfile $tunefile zenity --question $ZOPT --icon-name=ztunekey --text="$bn\\nTuning: $TUNING cents\\nKey: $KEY )\\n\\nRetune to standard?" [ "$?" = 1 ] && exit 1 zenity --scale $ZOPT --icon-name=ztunekey --text="Semitones to transpose?\\n0 = original key." --min-value=-12 --max-value=12 --value=0 > /tmp/semi.$$ S="$( cat /tmp/semi.$$ )" rm -f /tmp/semi.$$ P="$( perl -MPOSIX=round -e "printf '%+2.2f', round(100 * ($S - $TUNING / 100)) / 100" )" newfile="$( echo "$bn" | sed 's,\.[^.]*$,'$P'.wav,' )" mkdir -p ~/retuned cd ~/retuned rubberband --pitch $P $tmpfile "$newfile" | zenity --progress --no-cancel $ZOPT --icon-name=ztunekey --text "Retuning $bn by $P semitones." --pulsate --auto-close flacfile="$( basename "$newfile" .wav )".flac flac -f --delete-input-file -o "$flacfile" "$newfile" | zenity --progress --no-cancel $ZOPT --icon-name=ztunekey --text "Encoding $flacfile" --pulsate --auto-close id3cp "$file" "$flacfile" id3 -2 -t "%|%t||%_f|? (Retuned $P)" "$flacfile" audtool --playlist-addurl-to-new-playlist ~/retuned/"$flacfile"