| 1 |
# test_TextGrid_and_DurationTier.praat |
| 2 |
|
| 3 |
# check the interface |
| 4 |
|
| 5 |
# Create a TextGrid |
| 6 |
|
| 7 |
appendInfoLine: "test_TextGrid_and_DurationTier.praat" |
| 8 |
|
| 9 |
for i to 10 |
| 10 |
f = randomUniform (100, 400) |
| 11 |
sound[i] = Create Sound as pure tone: string$ (f), 1, 0, 0.4, 44100, f, 0.2, 0.01, 0.01 |
| 12 |
endfor |
| 13 |
|
| 14 |
selectObject: sound[1] |
| 15 |
for i from 2 to 10 |
| 16 |
plusObject: sound[i] |
| 17 |
endfor |
| 18 |
|
| 19 |
Concatenate recoverably |
| 20 |
sound = selected ("Sound") |
| 21 |
textgrid = selected ("TextGrid") |
| 22 |
|
| 23 |
for i to 10 |
| 24 |
removeObject: sound[i] |
| 25 |
endfor |
| 26 |
|
| 27 |
# some duration manipulations |
| 28 |
selectObject: sound |
| 29 |
duration = Get total duration |
| 30 |
durationTier = Create DurationTier: "chain", 0, duration |
| 31 |
|
| 32 |
selectObject: textgrid |
| 33 |
numberOfIntervals = Get number of intervals: 1 |
| 34 |
|
| 35 |
deltaTime = 0.0000001 |
| 36 |
for i to numberOfIntervals |
| 37 |
if i mod 2 = 0 |
| 38 |
selectObject: textgrid |
| 39 |
t1 = Get start time of interval: 1, i |
| 40 |
t2 = Get end time of interval: 1, i |
| 41 |
selectObject: durationTier |
| 42 |
Add point: t1, 1 |
| 43 |
Add point: t1+deltaTime, 1.9 |
| 44 |
Add point: t2-deltaTime, 1.9 |
| 45 |
Add point: t2, 1 |
| 46 |
endif |
| 47 |
endfor |
| 48 |
|
| 49 |
selectObject: durationTier, textgrid |
| 50 |
textgrid2 = To TextGrid (scale times) |
| 51 |
|
| 52 |
selectObject: sound |
| 53 |
manipulation = To Manipulation: 0.01, 75, 600 |
| 54 |
plusObject: durationTier |
| 55 |
Replace duration tier |
| 56 |
selectObject: manipulation |
| 57 |
sound2 = Get resynthesis (overlap-add) |
| 58 |
|
| 59 |
removeObject: sound, sound2, textgrid, textgrid2, manipulation, durationTier |
| 60 |
|
| 61 |
appendInfoLine: "test_TextGrid_and_DurationTier.praat OK" |