| 1 |
sound = Create Sound from formula: "sineWithNoise", 1, 0, 1, 44100, "1/2 * sin(2*pi*377*x) + randomGauss(0,0.1)" |
| 2 |
textgrid = To TextGrid: "sentences words bell", "bell" |
| 3 |
plusObject: sound |
| 4 |
View & Edit |
| 5 |
editor: textgrid |
| 6 |
a$ = Editor info |
| 7 |
writeInfoLine: a$ |
| 8 |
b$ = Sound info |
| 9 |
appendInfoLine: b$ |
| 10 |
c$ = info$ () |
| 11 |
assert index (c$, "Editor type: TextGridEditor" + newline$) |
| 12 |
assert index (c$, "Editor name: ") |
| 13 |
assert index (c$, ". TextGrid sineWithNoise" + newline$) |
| 14 |
assert index (c$, "Editor end: 1 seconds" + newline$) |
| 15 |
assert index (c$, "Selection start: 0.5 seconds" + newline$) |
| 16 |
assert index (c$, "Selection end: 0.5 seconds" + newline$) |
| 17 |
assert index (c$, "Pitch (raw autocorrelation) octave jump cost: ") |
| 18 |
assert index (c$, " per octave" + newline$) |
| 19 |
assert index (c$, "Number of channels: 1 (mono)" + newline$) |
| 20 |
assert index (c$, "Time domain:" + newline$) |
| 21 |
assert index (c$, "Object type: Sound" + newline$) |
| 22 |
assert index (c$, "Object name: sineWithNoise" + newline$) |
| 23 |
assert index (c$, " End time: 1 seconds" + newline$) |
| 24 |
assert index (c$, " Number of samples: 44100" + newline$) |
| 25 |
assert index (c$, " Joule/m²)" + newline$) |
| 26 |
assert index (c$, " Watt/m² = ") |
| 27 |
|
| 28 |
# |
| 29 |
# FunctionEditor properties. |
| 30 |
# |
| 31 |
a = Get start of selection |
| 32 |
assert a = 0.5 |
| 33 |
Move cursor to: 0.567 |
| 34 |
a = Get cursor |
| 35 |
assert a = 0.567 |
| 36 |
|
| 37 |
# |
| 38 |
# SoundAnalysisArea properties. |
| 39 |
# |
| 40 |
|
| 41 |
# |
| 42 |
# Save old settings. |
| 43 |
# |
| 44 |
showSpectrogram = extractNumber (c$, "Spectrogram show: ") |
| 45 |
showPitch = extractNumber (c$, "Pitch show: ") |
| 46 |
showIntensity = extractNumber (c$, "Intensity show: ") |
| 47 |
showFormants = extractNumber (c$, "Formant show: ") |
| 48 |
showPulses = extractNumber (c$, "Pulses show: ") |
| 49 |
longestAnalysis = extractNumber (c$, "Longest analysis: ") |
| 50 |
assert longestAnalysis > 0.0 |
| 51 |
# |
| 52 |
# Show everything. |
| 53 |
# |
| 54 |
Show analyses: "yes", "yes", "yes", "yes", "yes", 10.0 |
| 55 |
# |
| 56 |
# Query spectral properties. |
| 57 |
# |
| 58 |
a = Get frequency at frequency cursor |
| 59 |
a = Get spectral power at cursor cross |
| 60 |
# |
| 61 |
# Query pitch properties. |
| 62 |
# |
| 63 |
asserterror The command "Pitch listing" returns a string; not assigned to the numeric variable "a". |
| 64 |
a = Pitch listing |
| 65 |
a = Get pitch |
| 66 |
asserterror Make a selection first. |
| 67 |
a = Get minimum pitch |
| 68 |
asserterror Make a selection first. |
| 69 |
a = Get maximum pitch |
| 70 |
# |
| 71 |
# Query intensity properties. |
| 72 |
# |
| 73 |
asserterror The command "Intensity listing" returns a string; not assigned to the numeric variable "a". |
| 74 |
a = Intensity listing |
| 75 |
a = Get intensity |
| 76 |
asserterror Make a selection first. |
| 77 |
a = Get minimum intensity |
| 78 |
asserterror Make a selection first. |
| 79 |
a = Get maximum intensity |
| 80 |
# |
| 81 |
# Query pulses properties. |
| 82 |
# |
| 83 |
asserterror Make a selection first. |
| 84 |
report$ = Voice report |
| 85 |
Select: 0.5, 0.567 |
| 86 |
report$ = Voice report |
| 87 |
writeInfoLine: "Voice report>>>", report$, "<<<Voice report" |
| 88 |
assert index (report$, " Jitter (local): ") |
| 89 |
listing$ = Pulse listing |
| 90 |
assert index (listing$, "Time_s") |
| 91 |
# |
| 92 |
# Query formant properties. |
| 93 |
# |
| 94 |
f1 = Get first formant |
| 95 |
assert f1 > 0.0 |
| 96 |
b4 = Get bandwidth: 4 |
| 97 |
assert b4 > 0.0 |
| 98 |
|
| 99 |
# |
| 100 |
# Restore old settings. |
| 101 |
# |
| 102 |
Show analyses: showSpectrogram, showPitch, showIntensity, showFormants, showPulses, longestAnalysis |
| 103 |
|
| 104 |
# |
| 105 |
# Query TextGrid properties. |
| 106 |
# |
| 107 |
Move cursor to: 0.3 |
| 108 |
Add on selected tier |
| 109 |
t2 = Get starting point of interval |
| 110 |
assert t2 = 0.3 |
| 111 |
t3 = Get end point of interval |
| 112 |
assert t3 = 1.0 |
| 113 |
|
| 114 |
Close |
| 115 |
endeditor |
| 116 |
selectObject: textgrid |
| 117 |
Set interval text: 1, 1, "This is the first interval" |
| 118 |
Set interval text: 1, 2, "This is the second interval" |
| 119 |
plusObject: sound |
| 120 |
View & Edit |
| 121 |
editor: textgrid |
| 122 |
Move cursor to: 0.1 |
| 123 |
text1$ = Get label of interval |
| 124 |
assert text1$ = "This is the first interval" |
| 125 |
Move cursor to: 0.9 |
| 126 |
text2$ = Get label of interval |
| 127 |
assert text2$ = "This is the second interval" |
| 128 |
Close |
| 129 |
endeditor |
| 130 |
|
| 131 |
Remove |