Debian Codegraph @

dwtest/test_Sound_draw_where.praat

raw
1 # test_Sound_draw_where.praat
2 # djmw 20091031,20100912, 20110524
3
4 appendInfoLine: "test_Sound_draw_where.praat"
5
6 Erase all
7
8 Select outer viewport: 0, 6, 0, 3
9 @sawtooth
10 Select outer viewport: 0, 6, 3, 6
11 @three_samples
12 Select outer viewport: 0, 6, 6, 9
13 @three_samples_stereo
14 Select outer viewport: 0, 6, 9, 12
15 @randomAmplitudes
16
17 procedure sawtooth
18 appendInfoLine: "test_Sound_draw_where.praat"
19 # maximally steep
20 appendInfoLine: tab$, "Top: sawtooth in black with parts above 0.5 in red"
21 s = Create Sound from formula: "s", 1, 0, 1, 44100, "20*((x mod 0.1) - 0.05)"
22 ymin = -1.1
23 ymax = 1.1
24 Colour: "Red"
25 Draw where: 0, 0.4, ymin, ymax, "no", "Curve", "self>0.5"
26 Colour: "Black"
27 Draw where: 0, 0.4, ymin, ymax, "no", "Curve", "self<=0.5"
28 One mark left: 0.5, "yes", "yes", "yes", ""
29 Draw inner box
30 Text top: "no", "sawtooth in black with parts above 0.5 in red"
31 removeObject: s
32 endproc
33
34 procedure three_samples
35 appendInfoLine: tab$, "Interpolation between 3 sample points: parts above 0.5 in red"
36 s = Create Sound from formula: "s", 1, 0, 0.0003, 10000, "0"
37 Colour: "Red"
38 Formula: "if col=2 then -1 else 1 fi"
39 Draw where: 0, 0, ymin, ymax, "no", "Curve", "self>0.5"
40 Colour: "Black"
41 Draw where: 0, 0, ymin, ymax, "no", "Curve", "self<=0.5"
42 One mark left: 0.5, "yes", "yes", "yes", ""
43
44 Formula: "if col=2 then 1 else -1 fi"
45 Colour: "Red"
46 Draw where: 0, 0, ymin, ymax, "no", "Curve", "self>0.5"
47 Colour: "Black"
48 Draw where: 0, 0, ymin, ymax, "no", "Curve", "self<=0.5"
49 Draw inner box
50 Text top: "no", "Interpolation between 3 sample points: parts above 0.5 in red"
51 removeObject: s
52 endproc
53
54 procedure three_samples_stereo
55 appendInfoLine: tab$, "Stereo, interpolation between sample points: three sample points, parts above 0.5 in Red"
56 s = Create Sound from formula: "s", 2, 0, 0.0003, 10000, "0"
57 Formula: "if row = 1 then if col=2 then -1 else 1 fi else self fi"
58 Formula: "if row = 2 then if col=2 then 1 else -1 fi else self fi"
59 Colour: "Red"
60 Draw where: 0, 0, ymin, ymax, "no", "Curve", "self>0.5"
61 Colour: "Black"
62 Draw where: 0, 0, ymin, ymax, "yes", "Curve", "self<=0.5"
63 Formula: "0.6"
64 Colour: "Red"
65 Draw where: 0, 0, ymin, ymax, "no", "Curve", "1"
66 Colour: "Black"
67 Draw where: 0, 0, ymin, ymax, "no", "Curve", "0"
68 Text top: "no", "Parts above 0.5 in red. One line at 0.6"
69 removeObject: s
70 endproc
71
72 procedure randomAmplitudes
73 s = Create Sound from formula: "s", 1, 0, 0.01, 10000, "randomUniform (-1, 1)"
74 appendInfoLine: tab$, "Random amplitudes: parts > 0.5 in red only in the first half of every 0.001 s"
75 Select outer viewport: 0, 6, 9, 12
76 Colour: "Red"
77 Draw where: 0.001, 0.01, ymin, ymax, "no", "Curve", "(self>0.5 and x mod 0.001 < 0.0005)"
78 Colour: "Black"
79 Draw where: 0.001, 0.01, ymin, ymax, "no", "Curve", "not (self>0.5 and x mod 0.001 < 0.0005)"
80 One mark left: 0.5, "yes", "yes", "yes", ""
81 Marks bottom every: 1, 0.0005, "no", "yes", "yes"
82 Marks bottom every: 1, 0.001, "yes", "yes", "yes"
83 Draw inner box
84 Text top: "no", "Random amplitudes: parts > 0.5 red in the first half of every 0.001 s"
85 Colour: "Black"
86 removeObject: s
87 endproc
88
89 appendInfoLine: "test_Sound_draw_where.praat End"
90