-
Notifications
You must be signed in to change notification settings - Fork 0
/
sine_wave_shannon.praat
64 lines (56 loc) · 1.89 KB
/
sine_wave_shannon.praat
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
#produces Shannon-type AM noise from single selected Sound file using 4 bands
#can be easily tweaked to give other bands
fname$ = selected$ ("Sound", 1 )
#cut-off frequencies for (contiguous with hi/10 transition) four bands
b1 = 50
b2 = 800
b3 = 1500
b4 = 2500
b5 = 4000
#smoothing parameter for AM: minimum fo Hz (to get rid of Fo ripple)
minfo = 50
#produce the noise bands
call modnoise 'fname$' 'b1' 'b2'
call modnoise 'fname$' 'b2' 'b3'
call modnoise 'fname$' 'b3' 'b4'
call modnoise 'fname$' 'b4' 'b5'
#add up the separate bands
select Sound 'fname$'_'b1'_'b2'
plus Sound 'fname$'_'b2'_'b3'
plus Sound 'fname$'_'b3'_'b4'
plus Sound 'fname$'_'b4'_'b5'
execute "cjdisk:Applications (Mac OS 9):Sound:speech:Praat:scripts:Add_dynamic" no 1 Point-by-point values
#=======================
procedure modnoise nwave$ flo fhi
#=======================
#modnoise produces a band-pass noise between flo and fhi Hz, amplitude modulated to have same energy as original has in that band
select Sound 'nwave$'
durn = Get duration
sr = Get sample rate
Filter (pass Hann band)... 'flo' 'fhi' 'fhi'/10
Extract part... 0 'durn' Rectangular 1 no
opwr = Get power... 0 0
To Intensity... 'minfo' 0 yes
Down to IntensityTier
#make white noise
Create Sound... Noise 0 'durn' 'sr' randomGauss(0,0.1)
De-emphasize (in-line)... 50
Filter (pass Hann band)... 'flo' 'fhi' 'fhi'/10
Extract part... 0 'durn' Rectangular 1 no
plus IntensityTier 'nwave$'_band_part
Multiply
#NB Multiply scales to maximum of 0.9, so rescale to get same power as original
fpwr = Get power... 0 0
fmax = Get maximum... 0 0 None
Scale... fmax*sqrt(opwr/fpwr)
Rename... 'nwave$'_'flo'_'fhi'
#tidy-up
select Sound Noise
plus Sound Noise_band
plus Sound Noise_band_part
plus Sound 'nwave$'_band
plus Sound 'nwave$'_band_part
plus Intensity 'nwave$'_band_part
plus IntensityTier 'nwave$'_band_part
Remove
endproc