| 1 |
# test/manually/Sound_to_Pitch.praat |
| 2 |
# Paul Boersma, 13 August 2025 |
| 3 |
|
| 4 |
timeStep = 0.001 ; seconds |
| 5 |
|
| 6 |
sound1000 = Create Sound from formula: "sineWithNoise", 1, 0, 1000, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 7 |
stopwatch |
| 8 |
pitch1000 = noprogress To Pitch (raw autocorrelation): timeStep, 75, 600, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14 |
| 9 |
writeInfoLine: stopwatch |
| 10 |
sound100 = Create Sound from formula: "sineWithNoise", 1, 0, 100, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 11 |
stopwatch |
| 12 |
pitch100 = noprogress To Pitch (raw autocorrelation): timeStep, 75, 600, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14 |
| 13 |
appendInfoLine: stopwatch |
| 14 |
sound10 = Create Sound from formula: "sineWithNoise", 1, 0, 10, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 15 |
stopwatch |
| 16 |
pitch10 = noprogress To Pitch (raw autocorrelation): timeStep, 75, 600, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14 |
| 17 |
appendInfoLine: stopwatch |
| 18 |
sound1 = Create Sound from formula: "sineWithNoise", 1, 0, 1, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 19 |
stopwatch |
| 20 |
pitch1 = noprogress To Pitch (raw autocorrelation): timeStep, 75, 600, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14 |
| 21 |
appendInfoLine: stopwatch |
| 22 |
sound01 = Create Sound from formula: "sineWithNoise", 1, 0, 0.1, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 23 |
stopwatch |
| 24 |
pitch01 = noprogress To Pitch (raw autocorrelation): timeStep, 75, 600, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14 |
| 25 |
appendInfoLine: stopwatch |
| 26 |
|
| 27 |
removeObject: sound01, sound1, sound10, sound100, sound1000, pitch01, pitch1, pitch10, pitch100, pitch1000 |
| 28 |
|
| 29 |
margin = 0.0399 ; seconds |
| 30 |
numberOfReplications = 100 |
| 31 |
maximumNumberOfFrames = 100 |
| 32 |
numberOfTimings = numberOfReplications * maximumNumberOfFrames |
| 33 |
time# = zero# (maximumNumberOfFrames) |
| 34 |
numbersOfFrames# = shuffle#: repeat# (to# (maximumNumberOfFrames), numberOfReplications) |
| 35 |
for timing to numberOfTimings |
| 36 |
desiredNumberOfFrames = numbersOfFrames# [timing] |
| 37 |
durationOfFrames = desiredNumberOfFrames * timeStep |
| 38 |
durationOfSound = durationOfFrames + margin |
| 39 |
sound = Create Sound from formula: "sineWithNoise", 1, 0, durationOfSound, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 40 |
stopwatch |
| 41 |
pitch = noprogress To Pitch (raw autocorrelation): timeStep, 75, 600, 15, "no", 0.03, 0.45, 0.01, 0.35, 0.14 |
| 42 |
time# [desiredNumberOfFrames] += stopwatch |
| 43 |
resultingNumberOfFrames = Get number of frames |
| 44 |
assert resultingNumberOfFrames = desiredNumberOfFrames ; 'desiredNumberOfFrames' 'resultingNumberOfFrames' |
| 45 |
removeObject: sound, pitch |
| 46 |
endfor |
| 47 |
|
| 48 |
for numberOfFrames from 1 to maximumNumberOfFrames |
| 49 |
appendInfoLine: numberOfFrames, " ", round (time# [numberOfFrames] / numberOfReplications * 1e6), "μ" |
| 50 |
endfor |
| 51 |
|
| 52 |
appendInfoLine: "Mean: ", round (mean (time#) / numberOfReplications * 1e6), "μ" |