Author: Adam <git@apiote.xyz>
add whistle script
.local/bin/whistle | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/.local/bin/whistle b/.local/bin/whistle new file mode 100755 index 0000000000000000000000000000000000000000..ebe77a0f4031cbbd0b2bbd525bf45b1e6d6331b2 --- /dev/null +++ b/.local/bin/whistle @@ -0,0 +1,55 @@ +#!/bin/sh +set -x + +canonical() { + file=$1 + sed -i -E 's/%.*//g' "$file" + sed -i -E 's/\\break//g' "$file" + sed -i 's/\[//g' "$file" + sed -i 's/\]//g' "$file" + sed -i -E 's/\\barNumberCheck #[0-9]+//g' "$file" + sed -i 's/autoBeaming = ##f//g' "$file" + sed -i 's/\\header[ \t]*{/\\header {\n tagline = ""/' "$file" + sed -i -E 's/(\\version "[0-9.]+")/\1\n\\include "tinwhistle.ly"/' "$file" + sed -i 's/\\stemUp//g' "$file" + sed -i 's/\\stemDown//g' "$file" + sed -i 's/\\set Staff.instrumentName.*//' "$file" + sed -i 's/\\set Staff.shortInstrumentName.*//' "$file" + sed -i -E 's/[ ]+$//g' "$file" + sed -i 's/PartPOneVoiceOne =[ \t]*{/PartPOneVoiceOne = \\withTW {/' "$file" + sed -i -E 's/(repeat volta [0-9] )/\1\\withTW /' "$file" + sed -i -E 's/\\alternative \{ \{/\\alternative { \\withTW {/' "$file" + sed -i -E 's/\\acciaccatura \{/\\acciaccatura \\withTW {/' "$file" + sed -i -E 's/(^[ \t]*)\{$/\1\\withTW {/' "$file" + tr '\n' '@' < "$file" > "$file.tr" + sed -i -E 's/~( |@|\|)*([^ ]+)/~\1{\2}/g' "$file.tr" + tr '@' '\n' < "$file.tr" > "$file" + rm "$file.tr" +} + +if [ "$(basename "$0")" = 'whistle' ] +then + cd ~/Music/ly || exit 1 + + if ls ./*.mxl >/dev/null 2>&1 + then + for mxml in *.mxl + do + sheet="${mxml%.*}" + musicxml2ly -a -o "$sheet.ly" "$mxml" || continue + canonical "$sheet.ly" + lilypond "$sheet.ly" + done + fi + + if ls ./*.musicxml >/dev/null 2>&1 + then + for mxml in *.musicxml + do + sheet="${mxml%.*}_musicxml" + musicxml2ly -a -o "$sheet.ly" "$mxml" || continue + canonical "$sheet.ly" + lilypond "$sheet.ly" + done + fi +fi