2017-03-07 17:53:19 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-08 00:28:26 +01:00
|
|
|
echo "Pritisni ? za navodila (kadarkoli)"
|
2017-03-07 22:23:42 +01:00
|
|
|
|
2017-03-08 00:28:26 +01:00
|
|
|
# Osnova za frekvenco
|
|
|
|
osnova=300
|
|
|
|
|
|
|
|
# Razlika (v Hz) med crkami
|
|
|
|
razlika=20
|
|
|
|
|
|
|
|
# Seznam uporabljenih instrumentov
|
|
|
|
instrumenti=("triangle" "pluck" "sine" "square" "sawtooth" "trapezium" "exp" "noise" "tpdfnoise" "pinknoise" "brownnoise")
|
|
|
|
|
|
|
|
# Zacni pri prvem instrumentu
|
2017-03-07 22:23:42 +01:00
|
|
|
trenutni_instrument=0
|
|
|
|
|
2017-03-08 00:28:26 +01:00
|
|
|
# In ga izpisi
|
|
|
|
echo "Trenutni instrument: $trenutni_instrument (${instrumenti[$trenutni_instrument]})"
|
|
|
|
|
|
|
|
# Ponavljaj skoz
|
2017-03-07 17:53:19 +01:00
|
|
|
while [ true ]; do
|
2017-03-08 00:28:26 +01:00
|
|
|
# Preberi tipko
|
|
|
|
read -s -n 1 tipka
|
|
|
|
|
|
|
|
# Znak ? izpise navodila
|
|
|
|
if [ $tipka = "?" ]; then
|
|
|
|
echo "Pritiskaj na tipkovnico za igranje tonov"
|
|
|
|
echo "Frekvence se vrstijo po abecednem redu"
|
|
|
|
echo
|
|
|
|
echo "Ukazi:"
|
|
|
|
echo "\t1\tPrejsnji instrument"
|
|
|
|
echo "\t2\tNaslednji instrument"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $tipka = "2" ]; then
|
|
|
|
# Izberi naslednji instrument
|
|
|
|
trenutni_instrument=$(( ($trenutni_instrument + 1) % ${#instrumenti[@]}))
|
|
|
|
|
|
|
|
# In ga izpisi
|
|
|
|
echo "Trenutni instrument: $trenutni_instrument (${instrumenti[$trenutni_instrument]})"
|
|
|
|
continue
|
|
|
|
fi
|
2017-03-07 22:23:42 +01:00
|
|
|
|
|
|
|
if [ $tipka = "1" ]; then
|
2017-03-08 00:28:26 +01:00
|
|
|
# Izberi prejsnji instrument
|
|
|
|
trenutni_instrument=$(( (${#instrumenti[@]} + $trenutni_instrument - 1) % ${#instrumenti[@]}))
|
|
|
|
|
|
|
|
# In ga izpisi
|
|
|
|
echo "Trenutni instrument: $trenutni_instrument (${instrumenti[$trenutni_instrument]})"
|
|
|
|
continue
|
2017-03-07 22:23:42 +01:00
|
|
|
fi
|
|
|
|
|
2017-03-08 00:28:26 +01:00
|
|
|
# Pretvori crko v ASCII kodo in pomnozi s 15 za visino frekvence
|
|
|
|
koda=$(perl -e "print ord(\"$tipka\") - 97")
|
|
|
|
|
|
|
|
# Izracunaj frekvenco
|
|
|
|
frekvenca=$(( $osnova + $koda * $razlika ))
|
|
|
|
|
|
|
|
# Zaigraj ton
|
|
|
|
play -n synth 1 ${instrumenti[$trenutni_instrument]} $frekvenca &>/dev/null &
|
2017-03-07 22:23:42 +01:00
|
|
|
|
2017-03-08 00:28:26 +01:00
|
|
|
# Izpisi frekvenco
|
|
|
|
#echo "frekvenca: $koda"
|
2017-03-07 17:53:19 +01:00
|
|
|
done
|