| 1 |
# test/manually/Sound_to_LPC.praat |
| 2 |
# Paul Boersma, 31 December 2025 |
| 3 |
|
| 4 |
Debug multi-threading: "yes", 0, 7, "no" |
| 5 |
|
| 6 |
timeStep = 0.001 ; seconds |
| 7 |
samplingFrequency = 11000 |
| 8 |
sound1000 = Create Sound from formula: "sineWithNoise", 1, 0, 1000, samplingFrequency, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 9 |
stopwatch |
| 10 |
formant1000 = noprogress To LPC (burg): 10, 0.025, timeStep, 50.0 |
| 11 |
writeInfoLine: stopwatch |
| 12 |
sound100 = Create Sound from formula: "sineWithNoise", 1, 0, 100, samplingFrequency, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 13 |
stopwatch |
| 14 |
formant100 = noprogress To LPC (burg): 10, 0.025, timeStep, 50.0 |
| 15 |
appendInfoLine: stopwatch |
| 16 |
sound10 = Create Sound from formula: "sineWithNoise", 1, 0, 10, samplingFrequency, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 17 |
stopwatch |
| 18 |
formant10 = noprogress To LPC (burg): 10, 0.025, timeStep, 50.0 |
| 19 |
appendInfoLine: stopwatch |
| 20 |
sound1 = Create Sound from formula: "sineWithNoise", 1, 0, 1, samplingFrequency, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 21 |
stopwatch |
| 22 |
formant1 = noprogress To LPC (burg): 10, 0.025, timeStep, 50.0 |
| 23 |
appendInfoLine: stopwatch |
| 24 |
sound01 = Create Sound from formula: "sineWithNoise", 1, 0, 0.1, samplingFrequency, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 25 |
stopwatch |
| 26 |
formant01 = noprogress To LPC (burg): 10, 0.025, timeStep, 50.0 |
| 27 |
appendInfoLine: stopwatch |
| 28 |
|
| 29 |
removeObject: sound01, sound1, sound10, sound100, sound1000, formant01, formant1, formant10, formant100, formant1000 |
| 30 |
|
| 31 |
margin = 0.0495 ; seconds |
| 32 |
numberOfReplications = 100 |
| 33 |
maximumNumberOfFrames = 100 |
| 34 |
numberOfTimings = numberOfReplications * maximumNumberOfFrames |
| 35 |
time# = zero# (maximumNumberOfFrames) |
| 36 |
numbersOfFrames# = shuffle#: repeat# (to# (maximumNumberOfFrames), numberOfReplications) |
| 37 |
for timing to numberOfTimings |
| 38 |
desiredNumberOfFrames = numbersOfFrames# [timing] |
| 39 |
durationOfFrames = desiredNumberOfFrames * timeStep |
| 40 |
durationOfSound = durationOfFrames + margin |
| 41 |
sound = Create Sound from formula: "sineWithNoise", 1, 0, durationOfSound, samplingFrequency, "1/2 * sin(2*pi*377*x) + randomGauss(0,1)" |
| 42 |
stopwatch |
| 43 |
lpc = noprogress To LPC (burg): 10, 0.025, timeStep, 50.0 |
| 44 |
time# [desiredNumberOfFrames] += stopwatch |
| 45 |
resultingNumberOfFrames = Get number of frames |
| 46 |
assert resultingNumberOfFrames = desiredNumberOfFrames ; 'desiredNumberOfFrames' 'resultingNumberOfFrames' |
| 47 |
removeObject: sound, lpc |
| 48 |
endfor |
| 49 |
|
| 50 |
for numberOfFrames from 1 to maximumNumberOfFrames |
| 51 |
appendInfoLine: numberOfFrames, " ", round (time# [numberOfFrames] / numberOfReplications * 1e6), "μ" |
| 52 |
endfor |
| 53 |
|
| 54 |
appendInfoLine: "Mean: ", round (mean (time#) / numberOfReplications * 1e6), "μ" |