3 # Calcualte the CoG and convert to Pitch object
4 # Silence the start (<-35 dB) and the end (<20 dB)
6 procedure CoGcalculation
10 To TextGrid (silences)... 100 0 -35 0.1 0.1 silent sounding
13 To TextGrid (silences)... 100 0 -20 0.1 0.1 silent sounding
17 noprogress To Spectrogram... 0.025 8000 0.005 10 Gaussian
18 select Spectrogram PCM
21 select Spectrogram PCM
27 Formula... if(row>1) then self*y+self[row-1,col] else self*y fi
28 To Sound (slice)... -1
33 Formula... if(row>1) then self+self[row-1,col] else self fi
34 To Sound (slice)... -1
40 # Formula... 12*log2(self/Sound_E[col])
41 Formula... (self/Sound_E[col])
49 # Remove silent parts: Initial Low Noise
50 select TextGrid LowNoise
51 numberOfSoundIntervals = Get number of intervals... 1
52 for int from 1 to numberOfSoundIntervals
53 select TextGrid LowNoise
54 starttime = Get starting point... 1 'int'
55 endtime = Get end point... 1 'int'
56 soundValue$ = Get label of interval... 1 'int'
57 if soundValue$ = "silent"
59 Formula... if x >= 'starttime' and x < 'endtime' then 0 else self endif
63 # Remove silent parts: Final High Noise
65 durationCoG = Get total duration
66 endDurationCoG = durationCoG * 0.75
67 select TextGrid HighNoise
68 numberOfSoundIntervals = Get number of intervals... 1
69 for int from 1 to numberOfSoundIntervals
70 select TextGrid HighNoise
71 starttime = Get starting point... 1 'int'
72 endtime = Get end point... 1 'int'
73 soundValue$ = Get label of interval... 1 'int'
74 if soundValue$ = "silent" and endtime > endDurationCoG
76 Formula... if x >= 'starttime' and x < 'endtime' then 0 else self endif
84 plus TextGrid LowNoise
85 plus TextGrid HighNoise