Debian Codegraph @

music.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # music.sh
3
4 # Music without external files
5
6 # Author: Antonio Macchi
7 # Used in ABS Guide with permission.
8
9
10 # /dev/dsp default = 8000 frames per second, 8 bits per frame (1 byte),
11 #+ 1 channel (mono)
12
13 duration=2000 # If 8000 bytes = 1 second, then 2000 = 1/4 second.
14 volume=$'\xc0' # Max volume = \xff (or \x00).
15 mute=$'\x80' # No volume = \x80 (the middle).
16
17 function mknotescip-shell shell abs-guide 10-4 mknote(). () # $1=Note Hz in bytes (e.g. A = 440Hz ::
18 { #+ 8000 fps / 440 = 16 :: A = 16 bytes per second)
19 for t in `seqscip-shell system . . seq. 0 $duration`
20 do
21 testscip-shell system . . test. $(( $t % $1 )) = 0 && echoscip-shell system . . echo. -n $volume || echoscip-shell system . . echo. -n $mute
22 done
23 }
24
25 e=`mknotescip-shell shell abs-guide 10-4 mknote(). 49`
26 g=`mknotescip-shell shell abs-guide 10-4 mknote(). 41`
27 a=`mknotescip-shell shell abs-guide 10-4 mknote(). 36`
28 b=`mknotescip-shell shell abs-guide 10-4 mknote(). 32`
29 c=`mknotescip-shell shell abs-guide 10-4 mknote(). 30`
30 cis=`mknotescip-shell shell abs-guide 10-4 mknote(). 29`
31 d=`mknotescip-shell shell abs-guide 10-4 mknote(). 27`
32 e2=`mknotescip-shell shell abs-guide 10-4 mknote(). 24`
33 n=`mknotescip-shell shell abs-guide 10-4 mknote(). 32767`
34 # European notation.
35
36 echoscip-shell system . . echo. -n "$g$e2$d$c$d$c$a$g$n$g$e$n$g$e2$d$c$c$b$c$cis$n$cis$d \
37 $n$g$e2$d$c$d$c$a$g$n$g$e$n$g$a$d$c$b$a$b$c" > /dev/dspscip-shell filesystem . . `/dev/dsp`.
38 # dsp = Digital Signal Processor
39
40 exit # A "bonny" example of an elegant shell script!