cli-games/soxsynth/soxsynth
2018-05-12 17:47:37 -04:00

270 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
#This project inspired by a tweet from @climagic
#The original text of the tweet is:
#n=CDEFGAB;l=asdfghj;while read -n1 k;do x=$(tr $l $n<<<$k);play -qn synth pl ${x}3 fade 0 .7 & >/dev/null;done # Polyphonic by .@sentibryan
# https://twitter.com/climagic/statuses/149581073263771649
#Keyboard synthesizer by @stormdragon2976
#License WTFPL https://en.wikipedia.org/wiki/WTFPL
#Sunday, October 21, 2012
#Initial variable settings
effect=""
instrument="pl"
octave="2"
volume="0.8"
noteLength="0.75"
while read -sn1 key ; do
case $key in
"z")
note="C"
octave=2
;;
"x")
note="D"
octave=2
;;
"c")
note="E"
octave=2
;;
"v")
note="F"
octave=2
;;
"b")
note="G"
octave=2
;;
"n")
note="A"
octave=2
;;
"m")
note="B"
octave=2
;;
",")
note="C"
octave=3
;;
"Z")
note="C#"
octave=2
;;
"X")
note="D#"
octave=2
;;
"C")
note="E#"
octave=2
;;
"V")
note="F#"
octave=2
;;
"B")
note="G#"
octave=2
;;
"N")
note="A#"
octave=2
;;
"M")
note="B#"
octave=2
;;
"a")
note="C"
octave=3
;;
"s")
note="D"
octave=3
;;
"d")
note="E"
octave=3
;;
"f")
note="F"
octave=3
;;
"g")
note="G"
octave=3
;;
"h")
note="A"
octave=3
;;
"j")
note="B"
octave=3
;;
"k")
note="C"
octave=4
;;
"A")
note="C#"
octave=3
;;
"S")
note="D#"
octave=3
;;
"D")
note="E#"
octave=3
;;
"F")
note="F#"
octave=3
;;
"G")
note="G#"
octave=3
;;
"H")
note="A#"
octave=3
;;
"J")
note="B#"
octave=3
;;
"q")
note="C"
octave=4
;;
"w")
note="D"
octave=4
;;
"e")
note="E"
octave=4
;;
"r")
note="F"
octave=4
;;
"t")
note="G"
octave=4
;;
"y")
note="A"
octave=4
;;
"u")
note="B"
octave=4
;;
"i")
note="C"
octave=5
;;
"Q")
note="C#"
octave=4
;;
"W")
note="D#"
octave=4
;;
"E")
note="E#"
octave=4
;;
"R")
note="F#"
octave=4
;;
"T")
note="G#"
octave=4
;;
"Y")
note="A#"
octave=4
;;
"U")
note="B#"
octave=4
;;
"1")
instrument="pl"
volume="0.8"
;;
"2")
instrument="sin"
volume="0.6"
;;
"3")
instrument="sq"
volume="0.2"
;;
"4")
instrument="exp"
volume="0.6"
;;
"5")
instrument="tri"
volume="0.6"
;;
"6")
instrument="12"
volume="0.8"
;;
"!")
effect=""
;;
"@")
if [[ $(echo "$effect" | grep -i "flanger") ]] ; then
effect="$(echo "$effect" | sed 's/flanger //g')"
else
effect="${effect}flanger "
fi
;;
"#")
if [[ $(echo "$effect" | grep -i "phaser") ]] ; then
effect="$(echo "$effect" | sed 's/phaser //g')"
else
effect="${effect}phaser "
fi
;;
"$")
if [[ $(echo "$effect" | grep -i "overdrive") ]] ; then
effect="$(echo "$effect" | sed 's/overdrive 100 20 //g')"
else
effect="${effect}overdrive 100 20 "
fi
;;
"/")
noteLength="0.25"
;;
"'")
noteLength="0.50"
;;
"]")
noteLength="0.75"
;;
"=")
noteLength="1.00"
;;
$'\e')
exit 0
esac
if [ "$instrument" == "12" ] ; then
play -qn -V0 synth pl ${note}$(($octave + 1)) pl ${note}${octave} delay 0 0.02 remix - $effect fade 0 $noteLength vol $volume &> /dev/null &
else
play -qn -V0 synth $instrument ${note}${octave} $effect fade 0 $noteLength vol $volume &> /dev/null &
fi
echo -n "$note"
done
exit 0