misc/scripts/beep

24 lines
450 B
Plaintext
Raw Permalink Normal View History

2022-02-14 13:00:26 +01:00
#!/bin/sh
n=3
case "$5" in
2022-06-29 12:11:06 +02:00
LOW) n=1 ;;
NORMAL) n=3 ;;
CRITICAL) n=5 ;;
2022-02-14 13:00:26 +01:00
esac
lock=/tmp/.beep-lock
test -f $lock && exit 1
touch $lock
python -c "
import sys, numpy as np
t = np.arange(0, 0.25, 1/48000)
for i in range($n):
tone = np.random.choice([0,3,5,6,7,10,12])
2022-06-29 12:11:06 +02:00
note = 0.8 * np.sin(np.pi * 650 * 2**(tone/12) * t)
2022-02-14 13:00:26 +01:00
sys.stdout.buffer.write(np.int32(2**31 * note).tobytes())
" | aplay -c 1 -f S32_LE -r 48000 -Dbeep
rm -f $lock