-
Notifications
You must be signed in to change notification settings - Fork 0
/
CloneIntensityProc.praat
64 lines (57 loc) · 2.06 KB
/
CloneIntensityProc.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
####
#### Praat script CloneIntensityProc
#### Version 1.0
#### Version date: 3/29/15
#### Dan Villarreal
####
#### Hosts a procedure, cloneIntensity, that makes the intensity contour
#### of soundNew match that of soundOrig. First flattens the intensity
#### of soundNew by multiplying it by the difference of a maximum pitch
#### and its original intensity contour, then multiplies soundNew by the
#### time-transformed IntensityTier of soundOrig.
####
##Default values
# minPitch = 100
# step = 0.005
# maxIntensity = 100
procedure cloneIntensity: soundOrig, soundNew, minPitch, step, maxIntensity
##Get info on soundNew
selectObject: soundNew
soundNewName$ = selected$("Sound")
startNew = Get start time
endNew = Get end time
durNew = endNew - startNew
meas = durNew div step
##Get IntensityTier of soundNew and clear all points
intensityNew = To Intensity: minPitch, step, "yes"
intensityTierNew = Down to IntensityTier
Remove points between: startNew, endNew
##Add difference points to intensityTierNew
.time = startNew
for counter from 0 to meas
selectObject: intensityNew
intensity = Get value at time: .time, "Cubic"
if intensity != undefined
selectObject: intensityTierNew
scale = maxIntensity - intensity
Add point: .time, scale
endif
.time += step
endfor
##Multiply soundNew by intensityTierNew to flatten intensities
selectObject: soundNew, intensityTierNew
newSound = Multiply: "yes"
##Get IntensityTier of soundOrig and time-scale it to match soundNew
selectObject: soundOrig
meanOrig = Get intensity (dB)
intensityOrig = To Intensity: minPitch, step, "yes"
intensityTierOrig = Down to IntensityTier
Scale times to: startNew, endNew
##Multiply soundNew by intensityTierOrig to clone intensities, and scale mean
selectObject: newSound, intensityTierOrig
endSound = Multiply: "yes"
Scale intensity: meanOrig
meanNew = Get intensity (dB)
Rename: soundNewName$ + "_intensityCloned"
removeObject: intensityNew, intensityTierNew, intensityOrig, intensityTierOrig, newSound
endproc