-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelax
More file actions
executable file
·65 lines (57 loc) · 1.52 KB
/
relax
File metadata and controls
executable file
·65 lines (57 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
help() {
cat - >&2 <<EOF
relax - plays some relaxing noise
relax [--ffplay|--mpv|--ffmpeg|--sox]
Plays brown noise that fades in at the start, then continues with a
couple of slow, shallow, tremolo filters that are slightly offset from
each other to give the appearance of random/subtle "waves"
If a backend isn't specified then one will be automatically selected
in the same order as below:
--ffplay (requires ffmpeg compiled with SDL)
--mpv (requires mpv)
--ffmpeg (requires ffmpeg, only plays into alsa)
--sox (requires sox)
EOF
}
lavfifilter="anoisesrc=color=brown,afade=type=in:duration=90,tremolo=f=0.1:d=0.1,tremolo=f=0.16:d=0.2"
case "$1" in
--ffplay) backend=ffplay ;;
--mpv) backend=mpv ;;
--sox) backend=sox ;;
--ffmpeg) backend=ffmpeg ;;
--help|-h) help; exit 0;;
*)
if command -v ffplay > /dev/null 2>&1; then
backend=ffplay
elif command -v mpv > /dev/null 2>&1; then
backend=mpv
elif command -v ffmpeg > /dev/null 2>&1; then
backend=ffmpeg
elif command -v play > /dev/null 2>&1; then
backend=sox
else
printf '%s\n' "error: couldn't find a suitable backend. please install one of the following:" \
'mpv' 'ffmpeg' 'sox' >&2
exit 1
fi
;;
esac
case "$backend" in
ffplay)
exec ffplay -nodisp -f lavfi -i "$lavfifilter"
;;
mpv)
exec mpv --no-config av://lavfi:"$lavfifilter"
;;
ffmpeg)
exec ffmpeg -f lavfi -i "$lavfifilter" -f alsa default
;;
sox)
exec play -Gn \
synth brownnoise \
tremolo 0.10 10 \
tremolo 0.16 20 \
fade t 90
;;
esac