Debian Codegraph @

fon/praat_TextGrid_init.cpp

raw symbols SCIP
1 /* praat_TextGrid_init.cpp
2 *
3 * Copyright (C) 1992-2026 Paul Boersma, 2025-2026 Anastasia Shchupak
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Pitch_AnyTier_to_PitchTier.h"
20 #include "SpectrumEditor.h"
21 #include "SpeechSynthesizer.h"
22 #include "SpeechRecognizer.h"
23 #include "SpellingChecker.h"
24 #include "Strings_extensions.h"
25 #include "TextGridEditor.h"
26 #include "TextGrid_extensions.h"
27 #include "TextGrid_Sound.h"
28 #include "WordList.h"
29
30 #include "praat_TimeTier.h"
31 #include "praat_uvafon_init.h"
32
33 static const conststring32 STRING_FROM_FREQUENCY_HZ = U"left Frequency range (Hz)";
34 static const conststring32 STRING_TO_FREQUENCY_HZ = U"right Frequency range (Hz)";
35 static const conststring32 STRING_TIER_NUMBER = U"Tier number";
36 static const conststring32 STRING_INTERVAL_NUMBER = U"Interval number";
37 static const conststring32 STRING_POINT_NUMBER = U"Point number";
38
39 // MARK: - ANYTIER (generic)
40
41 DIRECT (NEW1_AnyTier_into_TextGrid) {
42 COMBINE_ALL_TO_ONE (Function)
43 autoTextGrid result = TextGrid_createWithoutTiers (1e308, -1e308);
44 for (integer i = 1; i <= list.size; i ++)
45 TextGrid_addTier_copy (result.get(), list.at [i]);
46 COMBINE_ALL_TO_ONE_END (U"grid")
47 }
48
49 // MARK: - INTERVALTIER
50
51 FORM (NEW_IntervalTier_downto_TableOfReal, U"IntervalTier: Down to TableOfReal", nullptr) {
52 SENTENCE (label, U"Label", U"")
53 OK
54 DO
55 CONVERT_EACH_TO_ONE (IntervalTier)
56 autoTableOfReal result = IntervalTier_downto_TableOfReal (me, label);
57 CONVERT_EACH_TO_ONE_END (my name.get())
58 }
59
60 DIRECT (NEW_IntervalTier_downto_TableOfReal_any) {
61 CONVERT_EACH_TO_ONE (IntervalTier)
62 autoTableOfReal result = IntervalTier_downto_TableOfReal_any (me);
63 CONVERT_EACH_TO_ONE_END (my name.get())
64 }
65
66 FORM (NEW_IntervalTier_getCentrePoints, U"IntervalTier: Get centre points", nullptr) {
67 SENTENCE (text, U"Text", U"")
68 OK
69 DO
70 CONVERT_EACH_TO_ONE (IntervalTier)
71 autoPointProcess result = IntervalTier_getCentrePoints (me, text);
72 CONVERT_EACH_TO_ONE_END (text)
73 }
74
75 FORM (NEW_IntervalTier_getEndPoints, U"IntervalTier: Get end points", nullptr) {
76 SENTENCE (text, U"Text", U"")
77 OK
78 DO
79 CONVERT_EACH_TO_ONE (IntervalTier)
80 autoPointProcess result = IntervalTier_getEndPoints (me, text);
81 CONVERT_EACH_TO_ONE_END (text)
82 }
83
84 FORM (NEW_IntervalTier_getStartingPoints, U"IntervalTier: Get starting points", nullptr) {
85 SENTENCE (text, U"Text", U"")
86 OK
87 DO
88 CONVERT_EACH_TO_ONE (IntervalTier)
89 autoPointProcess result = IntervalTier_getStartingPoints (me, text);
90 CONVERT_EACH_TO_ONE_END (text)
91 }
92
93 DIRECT (HELP_IntervalTier_help) {
94 HELP (U"IntervalTier")
95 }
96
97 FORM_SAVE (SAVE_IntervalTier_writeToXwaves, U"Xwaves label file", nullptr, nullptr) {
98 SAVE_ONE (IntervalTier, U"save the selected IntervalTier object to the Xwaves label file")
99 IntervalTier_writeToXwaves (me, file);
100 SAVE_ONE_END
101 }
102
103 // MARK: - INTERVALTIER & POINTPROCESS
104
105 FORM (NEW1_IntervalTier_PointProcess_startToCentre, U"From start to centre", U"IntervalTier & PointProcess: Start to centre...") {
106 REAL (phase, U"Phase (0-1)", U"0.5")
107 OK
108 DO
109 CONVERT_ONE_AND_ONE_TO_ONE (IntervalTier, PointProcess)
110 autoPointProcess result = IntervalTier_PointProcess_startToCentre (me, you, phase);
111 CONVERT_ONE_AND_ONE_TO_ONE_END (my name.get(), U"_", your name.get(), U"_", Melder_iround (100.0 * phase));
112 }
113
114 FORM (NEW1_IntervalTier_PointProcess_endToCentre, U"From end to centre", U"IntervalTier & PointProcess: End to centre...") {
115 REAL (phase, U"Phase (0-1)", U"0.5")
116 OK
117 DO
118 CONVERT_ONE_AND_ONE_TO_ONE (IntervalTier, PointProcess)
119 autoPointProcess result = IntervalTier_PointProcess_endToCentre (me, you, phase);
120 CONVERT_ONE_AND_ONE_TO_ONE_END (my name.get(), U"_", your name.get(), U"_", Melder_iround (100.0 * phase));
121 }
122
123 // MARK: - LABEL (obsolete)
124
125 DIRECT (NEW1_Label_Sound_to_TextGrid) {
126 CONVERT_ONE_AND_ONE_TO_ONE (Label, Sound)
127 autoTextGrid result = Label_Function_to_TextGrid (me, you);
128 CONVERT_ONE_AND_ONE_TO_ONE_END (your name.get())
129 }
130
131 DIRECT (HINT_Label_Sound_to_TextGrid) {
132 INFO_NONE
133 Melder_information (U"This is an old-style Label object. To turn it into a TextGrid, U"
134 "select it together with a Sound of the appropriate duration, and click \"To TextGrid\".");
135 INFO_NONE_END
136 }
137
138 // MARK: - PITCH & TEXTGRID
139
140 FORM (GRAPHICS_TextGrid_Pitch_draw, U"TextGrid & Pitch: Draw", nullptr) {
141 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
142 praat_TimeFunction_RANGE (fromTime, toTime)
143 REAL (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"0.0")
144 POSITIVE (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
145 POSITIVE (fontSize, U"Font size (points)", U"18")
146 BOOLEAN (useTextStyles, U"Use text styles", true)
147 OPTIONMENUx (textAlignment, U"Text alignment", 2, 0) OPTION (U"left") OPTION (U"centre") OPTION (U"right")
148 BOOLEAN (garnish, U"Garnish", true)
149 OK
150 DO
151 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
152 TextGrid_Pitch_draw (me, you, GRAPHICS, tierNumber, fromTime, toTime, fromFrequency, toFrequency,
153 fontSize, useTextStyles, textAlignment, garnish, Pitch_speckle_NO, kPitch_unit::HERTZ);
154 GRAPHICS_ONE_AND_ONE_END
155 }
156
157 FORM (GRAPHICS_TextGrid_Pitch_drawErb, U"TextGrid & Pitch: Draw erb", nullptr) {
158 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
159 praat_TimeFunction_RANGE (fromTime, toTime)
160 REAL (fromFrequency, U"left Frequency range (ERB)", U"0.0")
161 REAL (toFrequency, U"right Frequency range (ERB)", U"10.0")
162 POSITIVE (fontSize, U"Font size (points)", U"18")
163 BOOLEAN (useTextStyles, U"Use text styles", true)
164 OPTIONMENUx (textAlignment, U"Text alignment", 2, 0) OPTION (U"left") OPTION (U"centre") OPTION (U"right")
165 BOOLEAN (garnish, U"Garnish", true)
166 OK
167 DO
168 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
169 TextGrid_Pitch_draw (me, you, GRAPHICS, tierNumber, fromTime, toTime, fromFrequency, toFrequency,
170 fontSize, useTextStyles, textAlignment, garnish, Pitch_speckle_NO, kPitch_unit::ERB);
171 GRAPHICS_ONE_AND_ONE_END
172 }
173
174 FORM (GRAPHICS_TextGrid_Pitch_drawLogarithmic, U"TextGrid & Pitch: Draw logarithmic", nullptr) {
175 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
176 praat_TimeFunction_RANGE (fromTime, toTime)
177 POSITIVE (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"50.0")
178 POSITIVE (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
179 POSITIVE (fontSize, U"Font size (points)", U"18")
180 BOOLEAN (useTextStyles, U"Use text styles", true)
181 OPTIONMENUx (textAlignment, U"Text alignment", 2, 0) OPTION (U"left") OPTION (U"centre") OPTION (U"right")
182 BOOLEAN (garnish, U"Garnish", true)
183 OK
184 DO
185 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
186 TextGrid_Pitch_draw (me, you, GRAPHICS, tierNumber, fromTime, toTime, fromFrequency, toFrequency,
187 fontSize, useTextStyles, textAlignment, garnish, Pitch_speckle_NO, kPitch_unit::HERTZ_LOGARITHMIC);
188 GRAPHICS_ONE_AND_ONE_END
189 }
190
191 FORM (GRAPHICS_TextGrid_Pitch_drawMel, U"TextGrid & Pitch: Draw mel", nullptr) {
192 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
193 praat_TimeFunction_RANGE (fromTime, toTime)
194 REAL (fromFrequency, U"left Frequency range (mel)", U"0.0")
195 REAL (toFrequency, U"right Frequency range (mel)", U"500.0")
196 POSITIVE (fontSize, U"Font size (points)", U"18")
197 BOOLEAN (useTextStyles, U"Use text styles", true)
198 OPTIONMENUx (textAlignment, U"Text alignment", 2, 0) OPTION (U"left") OPTION (U"centre") OPTION (U"right")
199 BOOLEAN (garnish, U"Garnish", true)
200 OK
201 DO
202 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
203 TextGrid_Pitch_draw (me, you, GRAPHICS, tierNumber, fromTime, toTime, fromFrequency, toFrequency,
204 fontSize, useTextStyles, textAlignment, garnish, Pitch_speckle_NO, kPitch_unit::MEL);
205 GRAPHICS_ONE_AND_ONE_END
206 }
207
208 FORM (GRAPHICS_TextGrid_Pitch_drawSemitones, U"TextGrid & Pitch: Draw semitones", nullptr) {
209 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
210 praat_TimeFunction_RANGE (fromTime, toTime)
211 COMMENT (U"Range in semitones re 100 hertz:")
212 REAL (fromFrequency, U"left Frequency range (st)", U"-12.0")
213 REAL (toFrequency, U"right Frequency range (st)", U"30.0")
214 POSITIVE (fontSize, U"Font size (points)", U"18")
215 BOOLEAN (useTextStyles, U"Use text styles", true)
216 OPTIONMENUx (textAlignment, U"Text alignment", 2, 0) OPTION (U"left") OPTION (U"centre") OPTION (U"right")
217 BOOLEAN (garnish, U"Garnish", true)
218 OK
219 DO
220 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
221 TextGrid_Pitch_draw (me, you, GRAPHICS, tierNumber, fromTime, toTime, fromFrequency, toFrequency,
222 fontSize, useTextStyles, textAlignment, garnish, Pitch_speckle_NO, kPitch_unit::SEMITONES_100);
223 GRAPHICS_ONE_AND_ONE_END
224 }
225
226 FORM (GRAPHICS_TextGrid_Pitch_drawSeparately, U"TextGrid & Pitch: Draw separately", nullptr) {
227 praat_TimeFunction_RANGE (fromTime, toTime)
228 REAL (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"0.0")
229 REAL (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
230 BOOLEAN (showBoundaries, U"Show boundaries", true)
231 BOOLEAN (useTextStyles, U"Use text styles", true)
232 BOOLEAN (garnish, U"Garnish", true)
233 OK
234 DO
235 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
236 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
237 showBoundaries, useTextStyles, garnish, Pitch_speckle_NO, kPitch_unit::HERTZ);
238 GRAPHICS_ONE_AND_ONE_END
239 }
240
241 FORM (GRAPHICS_TextGrid_Pitch_drawSeparatelyErb, U"TextGrid & Pitch: Draw separately erb", nullptr) {
242 praat_TimeFunction_RANGE (fromTime, toTime)
243 REAL (fromFrequency, U"left Frequency range (ERB)", U"0.0")
244 REAL (toFrequency, U"right Frequency range (ERB)", U"10.0")
245 BOOLEAN (showBoundaries, U"Show boundaries", true)
246 BOOLEAN (useTextStyles, U"Use text styles", true)
247 BOOLEAN (garnish, U"Garnish", true)
248 OK
249 DO
250 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
251 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
252 showBoundaries, useTextStyles, garnish, Pitch_speckle_NO, kPitch_unit::ERB);
253 GRAPHICS_ONE_AND_ONE_END
254 }
255
256 FORM (GRAPHICS_TextGrid_Pitch_drawSeparatelyLogarithmic, U"TextGrid & Pitch: Draw separately logarithmic", nullptr) {
257 praat_TimeFunction_RANGE (fromTime, toTime)
258 POSITIVE (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"50.0")
259 POSITIVE (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
260 BOOLEAN (showBoundaries, U"Show boundaries", true)
261 BOOLEAN (useTextStyles, U"Use text styles", true)
262 BOOLEAN (garnish, U"Garnish", true)
263 OK
264 DO
265 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
266 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
267 showBoundaries, useTextStyles, garnish, Pitch_speckle_NO, kPitch_unit::HERTZ_LOGARITHMIC);
268 GRAPHICS_ONE_AND_ONE_END
269 }
270
271 FORM (GRAPHICS_TextGrid_Pitch_drawSeparatelyMel, U"TextGrid & Pitch: Draw separately mel", nullptr) {
272 praat_TimeFunction_RANGE (fromTime, toTime)
273 REAL (fromFrequency, U"left Frequency range (mel)", U"0.0")
274 REAL (toFrequency, U"right Frequency range (mel)", U"500.0")
275 BOOLEAN (showBoundaries, U"Show boundaries", true)
276 BOOLEAN (useTextStyles, U"Use text styles", true)
277 BOOLEAN (garnish, U"Garnish", true)
278 OK
279 DO
280 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
281 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
282 showBoundaries, useTextStyles, garnish, Pitch_speckle_NO, kPitch_unit::MEL);
283 GRAPHICS_ONE_AND_ONE_END
284 }
285
286 FORM (GRAPHICS_TextGrid_Pitch_drawSeparatelySemitones, U"TextGrid & Pitch: Draw separately semitones", nullptr) {
287 praat_TimeFunction_RANGE (fromTime, toTime)
288 COMMENT (U"Range in semitones re 100 hertz:")
289 REAL (fromFrequency, U"left Frequency range (st)", U"-12.0")
290 REAL (toFrequency, U"right Frequency range (st)", U"30.0")
291 BOOLEAN (showBoundaries, U"Show boundaries", true)
292 BOOLEAN (useTextStyles, U"Use text styles", true)
293 BOOLEAN (garnish, U"Garnish", true)
294 OK
295 DO
296 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
297 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
298 showBoundaries, useTextStyles, garnish, Pitch_speckle_NO, kPitch_unit::SEMITONES_100);
299 GRAPHICS_ONE_AND_ONE_END
300 }
301
302 FORM (GRAPHICS_TextGrid_Pitch_speckle, U"TextGrid & Pitch: Speckle", nullptr) {
303 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
304 praat_TimeFunction_RANGE (fromTime, toTime)
305 REAL (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"0.0")
306 POSITIVE (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
307 BOOLEAN (showBoundaries, U"Show boundaries", true)
308 BOOLEAN (useTextStyles, U"Use text styles", true)
309 BOOLEAN (garnish, U"Garnish", true)
310 OK
311 DO
312 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
313 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
314 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::HERTZ);
315 GRAPHICS_ONE_AND_ONE_END
316 }
317
318 FORM (GRAPHICS_TextGrid_Pitch_speckleErb, U"TextGrid & Pitch: Speckle erb", nullptr) {
319 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
320 praat_TimeFunction_RANGE (fromTime, toTime)
321 REAL (fromFrequency, U"left Frequency range (ERB)", U"0.0")
322 REAL (toFrequency, U"right Frequency range (ERB)", U"10.0")
323 BOOLEAN (showBoundaries, U"Show boundaries", true)
324 BOOLEAN (useTextStyles, U"Use text styles", true)
325 BOOLEAN (garnish, U"Garnish", true)
326 OK
327 DO
328 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
329 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
330 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::ERB);
331 GRAPHICS_ONE_AND_ONE_END
332 }
333
334 FORM (GRAPHICS_TextGrid_Pitch_speckleLogarithmic, U"TextGrid & Pitch: Speckle logarithmic", nullptr) {
335 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
336 praat_TimeFunction_RANGE (fromTime, toTime)
337 POSITIVE (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"50.0")
338 POSITIVE (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
339 BOOLEAN (showBoundaries, U"Show boundaries", true)
340 BOOLEAN (useTextStyles, U"Use text styles", true)
341 BOOLEAN (garnish, U"Garnish", true)
342 OK
343 DO
344 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
345 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
346 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::HERTZ_LOGARITHMIC);
347 GRAPHICS_ONE_AND_ONE_END
348 }
349
350 FORM (GRAPHICS_TextGrid_Pitch_speckleMel, U"TextGrid & Pitch: Speckle mel", nullptr) {
351 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
352 praat_TimeFunction_RANGE (fromTime, toTime)
353 REAL (fromFrequency, U"left Frequency range (mel)", U"0.0")
354 REAL (toFrequency, U"right Frequency range (mel)", U"500.0")
355 BOOLEAN (showBoundaries, U"Show boundaries", true)
356 BOOLEAN (useTextStyles, U"Use text styles", true)
357 BOOLEAN (garnish, U"Garnish", true)
358 OK
359 DO
360 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
361 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
362 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::MEL);
363 GRAPHICS_ONE_AND_ONE_END
364 }
365
366 FORM (GRAPHICS_TextGrid_Pitch_speckleSemitones, U"TextGrid & Pitch: Speckle semitones", nullptr) {
367 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
368 praat_TimeFunction_RANGE (fromTime, toTime)
369 COMMENT (U"Range in semitones re 100 hertz:")
370 REAL (fromFrequency, U"left Frequency range (st)", U"-12.0")
371 REAL (toFrequency, U"right Frequency range (st)", U"30.0")
372 BOOLEAN (showBoundaries, U"Show boundaries", true)
373 BOOLEAN (useTextStyles, U"Use text styles", true)
374 BOOLEAN (garnish, U"Garnish", true)
375 OK
376 DO
377 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
378 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
379 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::SEMITONES_100);
380 GRAPHICS_ONE_AND_ONE_END
381 }
382
383 FORM (GRAPHICS_TextGrid_Pitch_speckleSeparately, U"TextGrid & Pitch: Speckle separately", nullptr) {
384 praat_TimeFunction_RANGE (fromTime, toTime)
385 REAL (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"0.0")
386 REAL (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
387 BOOLEAN (showBoundaries, U"Show boundaries", true)
388 BOOLEAN (useTextStyles, U"Use text styles", true)
389 BOOLEAN (garnish, U"Garnish", true)
390 OK
391 DO
392 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
393 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
394 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::HERTZ);
395 GRAPHICS_ONE_AND_ONE_END
396 }
397
398 FORM (GRAPHICS_TextGrid_Pitch_speckleSeparatelyErb, U"TextGrid & Pitch: Speckle separately erb", nullptr) {
399 praat_TimeFunction_RANGE (fromTime, toTime)
400 REAL (fromFrequency, U"left Frequency range (ERB)", U"0.0")
401 REAL (toFrequency, U"right Frequency range (ERB)", U"10.0")
402 BOOLEAN (showBoundaries, U"Show boundaries", true)
403 BOOLEAN (useTextStyles, U"Use text styles", true)
404 BOOLEAN (garnish, U"Garnish", true)
405 OK
406 DO
407 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
408 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
409 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::ERB);
410 GRAPHICS_ONE_AND_ONE_END
411 }
412
413 FORM (GRAPHICS_TextGrid_Pitch_speckleSeparatelyLogarithmic, U"TextGrid & Pitch: Speckle separately logarithmic", nullptr) {
414 praat_TimeFunction_RANGE (fromTime, toTime)
415 POSITIVE (fromFrequency, STRING_FROM_FREQUENCY_HZ, U"50.0")
416 POSITIVE (toFrequency, STRING_TO_FREQUENCY_HZ, U"500.0")
417 BOOLEAN (showBoundaries, U"Show boundaries", true)
418 BOOLEAN (useTextStyles, U"Use text styles", true)
419 BOOLEAN (garnish, U"Garnish", true)
420 OK
421 DO
422 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
423 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
424 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::HERTZ_LOGARITHMIC);
425 GRAPHICS_ONE_AND_ONE_END
426 }
427
428 FORM (GRAPHICS_TextGrid_Pitch_speckleSeparatelyMel, U"TextGrid & Pitch: Speckle separately mel", nullptr) {
429 praat_TimeFunction_RANGE (fromTime, toTime)
430 REAL (fromFrequency, U"left Frequency range (mel)", U"0.0")
431 REAL (toFrequency, U"right Frequency range (mel)", U"500.0")
432 BOOLEAN (showBoundaries, U"Show boundaries", true)
433 BOOLEAN (useTextStyles, U"Use text styles", true)
434 BOOLEAN (garnish, U"Garnish", true)
435 OK
436 DO
437 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
438 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
439 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::MEL);
440 GRAPHICS_ONE_AND_ONE_END
441 }
442
443 FORM (GRAPHICS_TextGrid_Pitch_speckleSeparatelySemitones, U"TextGrid & Pitch: Speckle separately semitones", nullptr) {
444 praat_TimeFunction_RANGE (fromTime, toTime)
445 COMMENT (U"Range in semitones re 100 hertz:")
446 REAL (fromFrequency, U"left Frequency range (st)", U"-12.0")
447 REAL (toFrequency, U"right Frequency range (st)", U"30.0")
448 BOOLEAN (showBoundaries, U"Show boundaries", true)
449 BOOLEAN (useTextStyles, U"Use text styles", true)
450 BOOLEAN (garnish, U"Garnish", true)
451 OK
452 DO
453 GRAPHICS_ONE_AND_ONE (TextGrid, Pitch)
454 TextGrid_Pitch_drawSeparately (me, you, GRAPHICS, fromTime, toTime, fromFrequency, toFrequency,
455 showBoundaries, useTextStyles, garnish, Pitch_speckle_YES, kPitch_unit::MEL);
456 GRAPHICS_ONE_AND_ONE_END
457 }
458
459 // MARK: - PITCH & TEXTTIER
460
461 FORM (NEW1_Pitch_TextTier_to_PitchTier, U"Pitch & TextTier to PitchTier", U"Pitch & TextTier: To PitchTier...") {
462 CHOICEx (unvoicedStrategy, U"Unvoiced strategy", 3, 0)
463 OPTION (U"zero")
464 OPTION (U"error")
465 OPTION (U"interpolate")
466 OK
467 DO
468 CONVERT_ONE_AND_ONE_TO_ONE (Pitch, TextTier)
469 autoPitchTier result = Pitch_AnyTier_to_PitchTier (me, you->asAnyTier(), unvoicedStrategy);
470 CONVERT_ONE_AND_ONE_TO_ONE_END (my name.get())
471 }
472
473 // MARK: - SOUND & TEXTGRID
474
475 FORM (GRAPHICS_TextGrid_Sound_draw, U"TextGrid & Sound: Draw...", nullptr) {
476 praat_TimeFunction_RANGE (fromTime, toTime)
477 BOOLEAN (showBoundaries, U"Show boundaries", true)
478 BOOLEAN (useTextStyles, U"Use text styles", true)
479 BOOLEAN (garnish, U"Garnish", true)
480 OK
481 DO
482 GRAPHICS_ONE_AND_ONE (TextGrid, Sound)
483 TextGrid_Sound_draw (me, you, GRAPHICS, fromTime, toTime, showBoundaries, useTextStyles, garnish);
484 GRAPHICS_ONE_AND_ONE_END
485 }
486
487 FORM (NEW1_TextGrid_Sound_extractAllIntervals, U"TextGrid & Sound: Extract all intervals", nullptr) {
488 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
489 BOOLEAN (preserveTimes, U"Preserve times", false)
490 OK
491 DO
492 CONVERT_ONE_AND_ONE_TO_ONE (TextGrid, Sound)
493 autoSoundList result = TextGrid_Sound_extractAllIntervals (me, you, tierNumber, preserveTimes);
494 result -> classInfo = classCollection; // YUCK, in order to force automatic unpacking
495 CONVERT_ONE_AND_ONE_TO_ONE_END (U"dummy")
496 }
497
498 FORM (NEW1_TextGrid_Sound_extractNonemptyIntervals, U"TextGrid & Sound: Extract non-empty intervals", nullptr) {
499 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
500 BOOLEAN (preserveTimes, U"Preserve times", false)
501 OK
502 DO
503 CONVERT_ONE_AND_ONE_TO_ONE (TextGrid, Sound)
504 autoSoundList result = TextGrid_Sound_extractNonemptyIntervals (me, you, tierNumber, preserveTimes);
505 result -> classInfo = classCollection; // YUCK, in order to force automatic unpacking
506 CONVERT_ONE_AND_ONE_TO_ONE_END (U"dummy")
507 }
508
509 FORM (NEW1_TextGrid_Sound_extractIntervals, U"TextGrid & Sound: Extract intervals", nullptr) {
510 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
511 BOOLEAN (preserveTimes, U"Preserve times", false)
512 SENTENCE (labelText, U"Label text", U"")
513 OK
514 DO
515 CONVERT_ONE_AND_ONE_TO_ONE (TextGrid, Sound)
516 autoSoundList result = TextGrid_Sound_extractIntervalsWhere (me, you,
517 tierNumber, kMelder_string::EQUAL_TO, labelText, preserveTimes);
518 result -> classInfo = classCollection; // YUCK, in order to force automatic unpacking
519 CONVERT_ONE_AND_ONE_TO_ONE_END (U"dummy")
520 }
521
522 FORM (NEW1_TextGrid_Sound_extractIntervalsWhere, U"TextGrid & Sound: Extract intervals", nullptr) {
523 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
524 BOOLEAN (preserveTimes, U"Preserve times", false)
525 OPTIONMENU_ENUM (kMelder_string, extractEveryIntervalWhoseLabel___,
526 U"Extract every interval whose label...", kMelder_string::DEFAULT)
527 SENTENCE (__theText, U"...the text", U"")
528 OK
529 DO
530 CONVERT_ONE_AND_ONE_TO_ONE (TextGrid, Sound)
531 autoSoundList result = TextGrid_Sound_extractIntervalsWhere (me, you, tierNumber,
532 extractEveryIntervalWhoseLabel___, __theText, preserveTimes);
533 result -> classInfo = classCollection; // YUCK, in order to force automatic unpacking
534 CONVERT_ONE_AND_ONE_TO_ONE_END (U"dummy")
535 }
536
537 FORM (MODIFY_TextGrid_Sound_alignInterval, U"TextGrid & Sound: Align interval", nullptr) {
538 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
539 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
540 OPTIONMENUSTR (language, U"Language", (int) NUMfindFirst (theSpeechSynthesizerLanguageNames, U"English (Great Britain)"))
541 for (integer i = 1; i <= theSpeechSynthesizerLanguageNames.size; i ++)
542 OPTION (theSpeechSynthesizerLanguageNames [i]);
543 BOOLEAN (includeWords, U"Include words", true)
544 BOOLEAN (includePhonemes, U"Include phonemes", true)
545 OK
546 DO
547 MODIFY_FIRST_OF_ONE_AND_ONE (TextGrid, Sound)
548 TextGrid_anySound_alignInterval (me, you, tierNumber, intervalNumber, language, includeWords, includePhonemes);
549 MODIFY_FIRST_OF_ONE_AND_ONE_END
550 }
551
552 DIRECT (MODIFY_TextGrid_Sound_scaleTimes) {
553 MODIFY_FIRST_OF_ONE_AND_ONE (TextGrid, Sound)
554 Function_scaleXTo (me, your xmin, your xmax);
555 MODIFY_FIRST_OF_ONE_AND_ONE_END
556 }
557
558 FORM (MODIFY_TextGrid_Sound_transcribeInterval, U"TextGrid & Sound: Transcribe interval", U"TextGrid & Sound: Transcribe interval...") {
559 HEADING (U"TextGrid...")
560 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
561 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
562 HEADING (U"Transcription...")
563 LISTNUMSTR (modelIndex, modelName, U"Whisper model", constSTRVEC(), 1)
564 OPTIONMENUSTR (languageName, U"Language",
565 (int) NUMfindFirst (theSpeechRecognizerLanguageNames(), TranscriptionDefaults::languageName))
566 for (integer i = 1; i <= theSpeechRecognizerLanguageNames().size; i ++)
567 OPTION (theSpeechRecognizerLanguageNames() [i])
568 BOOLEAN (includeWords, U"Include words", TranscriptionDefaults::includeWords)
569 HEADING (U"Non-speech detection...")
570 BOOLEAN (useVad, U"Detect non-speech", TranscriptionDefaults::useVad)
571 NONNEGATIVE (speechProbabilityThreshold, U"Speech probability threshold (0-1)", VadDefaults::speechThreshold)
572 NONNEGATIVE (minNonSpeechDuration, U"Min. gap between speech segments (s)", VadDefaults::minNonSpeechDuration)
573 NONNEGATIVE (minSpeechDuration, U"Min. speech segment (s)", VadDefaults::minSpeechDuration)
574 NONNEGATIVE (speechPad, U"Padding around speech segments (s)", VadDefaults::speechPad)
575 HEADING (U"Diarization...")
576 BOOLEAN (includeDiarization, U"Include diarization", TranscriptionDefaults::includeDiarization)
577 NATURAL (maxNumSpeakers, U"Max. number of speakers (≥ 2)", DiarizationDefaults::maxNumSpeakers)
578 BOOLEAN (allowSpeakersOverlap, U"Allow speakers to overlap", DiarizationDefaults::allowOverlap)
579 POSITIVE (clusterThreshold, U"Clustering threshold (0-2)", DiarizationDefaults::clusterThreshold)
580 POSITIVE (segmentationStep, U"Segmentation step (0-1)", DiarizationDefaults::segmentationStep)
581 OK
582 static autoSTRVEC modelNames;
583 modelNames = copy_STRVEC (theCurrentSpeechRecognizerModelNames()); // cannot be called twice in the same scope
584
585 Melder_require (modelNames.size > 0,
586 U"Found no Whisper-cpp models to do speech recognition with.\n"
587 U"You can install them into the subfolders “whispercpp” of the folder “models” in the Praat preferences folder."
588 );
589
590 SET_LIST (modelIndex, modelName, modelNames.get (), NUMfindFirst (modelNames.get (), TranscriptionDefaults::modelName))
591 DO
592 MODIFY_FIRST_OF_ONE_AND_ONE (TextGrid, Sound)
593 TextGrid_Sound_transcribeInterval (me, you, tierNumber, intervalNumber, modelName, languageName, includeWords,
594 useVad, speechProbabilityThreshold, minNonSpeechDuration, minSpeechDuration, speechPad,
595 includeDiarization, maxNumSpeakers, allowSpeakersOverlap, clusterThreshold, segmentationStep);
596 MODIFY_FIRST_OF_ONE_AND_ONE_END
597 }
598
599 FORM (MODIFY_TextGrid_Sound_diarizeInterval, U"TextGrid & Sound: Diarize interval", U"TextGrid & Sound: Diarize interval...") {
600 HEADING (U"TextGrid...")
601 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
602 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
603 HEADING (U"Diarization...")
604 NATURAL (maxNumSpeakers, U"Max. number of speakers (≥ 2)", DiarizationDefaults::maxNumSpeakers)
605 BOOLEAN (allowSpeakersOverlap, U"Allow speakers to overlap", DiarizationDefaults::allowOverlap)
606 WORD (nonSpeechLabel, U"Non-speech interval label", DiarizationDefaults::nonSpeechLabel)
607 WORD (speechLabel, U"Speech interval label", DiarizationDefaults::speechLabel)
608 POSITIVE (clusterThreshold, U"Clustering threshold (0-2)", DiarizationDefaults::clusterThreshold)
609 POSITIVE (segmentationStep, U"Segmentation step (0-1)", DiarizationDefaults::segmentationStep)
610 OK
611 DO
612 MODIFY_FIRST_OF_ONE_AND_ONE (TextGrid, Sound)
613 TextGrid_Sound_diarizeInterval (me, you, tierNumber, intervalNumber,
614 maxNumSpeakers, allowSpeakersOverlap, nonSpeechLabel, speechLabel,
615 clusterThreshold, segmentationStep);
616 MODIFY_FIRST_OF_ONE_AND_ONE_END
617 }
618
619 DIRECT (MODIFY_TextGrid_Sound_cloneTimeDomain) {
620 MODIFY_FIRST_OF_ONE_AND_ONE (Sound, TextGrid)
621 my x1 += your xmin - your xmin;
622 my xmin = your xmin;
623 my xmax = your xmax;
624 MODIFY_FIRST_OF_ONE_AND_ONE_END
625 }
626
627 // MARK: - SPELLINGCHECKER
628
629 FORM (MODIFY_SpellingChecker_addNewWord, U"Add word to user dictionary", U"SpellingChecker") {
630 SENTENCE (newWord, U"New word", U"")
631 OK
632 DO
633 MODIFY_EACH (SpellingChecker)
634 SpellingChecker_addNewWord (me, newWord);
635 MODIFY_EACH_END
636 }
637
638 FORM (WINDOW_SpellingChecker_viewAndEdit, U"Edit spelling checker", U"SpellingChecker") {
639 COMMENT (U"-- Syntax --")
640 SENTENCE (forbiddenStrings, U"Forbidden strings", U"")
641 BOOLEAN (checkMatchingParentheses, U"Check matching parentheses", false)
642 SENTENCE (separatingCharacters, U"Separating characters", U"")
643 BOOLEAN (allowAllParenthesized, U"Allow all parenthesized", false)
644 COMMENT (U"-- Capitals --")
645 BOOLEAN (allowAllNames, U"Allow all names", false)
646 SENTENCE (namePrefixes, U"Name prefixes", U"")
647 BOOLEAN (allowAllAbbreviations, U"Allow all abbreviations", false)
648 COMMENT (U"-- Capitalization --")
649 BOOLEAN (allowCapsSentenceInitially, U"Allow caps sentence-initially", false)
650 BOOLEAN (allowCapsAfterColon, U"Allow caps after colon", false)
651 COMMENT (U"-- Word parts --")
652 SENTENCE (allowAllWordsContaining, U"Allow all words containing", U"")
653 SENTENCE (allowAllWordsStartingWith, U"Allow all words starting with", U"")
654 SENTENCE (allowAllWordsEndingIn, U"Allow all words ending in", U"")
655 OK
656 FIND_ONE (SpellingChecker)
657 SET_STRING (forbiddenStrings, my forbiddenStrings.get())
658 SET_BOOLEAN (checkMatchingParentheses, my checkMatchingParentheses)
659 SET_STRING (separatingCharacters, my separatingCharacters.get())
660 SET_BOOLEAN (allowAllParenthesized, my allowAllParenthesized)
661 SET_BOOLEAN (allowAllNames, my allowAllNames)
662 SET_STRING (namePrefixes, my namePrefixes.get())
663 SET_BOOLEAN (allowAllAbbreviations, my allowAllAbbreviations)
664 SET_BOOLEAN (allowCapsSentenceInitially, my allowCapsSentenceInitially)
665 SET_BOOLEAN (allowCapsAfterColon, my allowCapsAfterColon)
666 SET_STRING (allowAllWordsContaining, my allowAllWordsContaining.get())
667 SET_STRING (allowAllWordsStartingWith, my allowAllWordsStartingWith.get())
668 SET_STRING (allowAllWordsEndingIn, my allowAllWordsEndingIn.get())
669 DO
670 MODIFY_EACH (SpellingChecker)
671 my forbiddenStrings = Melder_dup (forbiddenStrings);
672 my checkMatchingParentheses = checkMatchingParentheses;
673 my separatingCharacters = Melder_dup (separatingCharacters);
674 my allowAllParenthesized = allowAllParenthesized;
675 my allowAllNames = allowAllNames;
676 my namePrefixes = Melder_dup (namePrefixes);
677 my allowAllAbbreviations = allowAllAbbreviations;
678 my allowCapsSentenceInitially = allowCapsSentenceInitially;
679 my allowCapsAfterColon = allowCapsAfterColon;
680 my allowAllWordsContaining = Melder_dup (allowAllWordsContaining);
681 my allowAllWordsStartingWith = Melder_dup (allowAllWordsStartingWith);
682 my allowAllWordsEndingIn = Melder_dup (allowAllWordsEndingIn);
683 MODIFY_EACH_END
684 }
685
686 DIRECT (NEW_SpellingChecker_extractWordList) {
687 CONVERT_EACH_TO_ONE (SpellingChecker)
688 autoWordList result = SpellingChecker_extractWordList (me);
689 CONVERT_EACH_TO_ONE_END (my name.get())
690 }
691
692 DIRECT (NEW_SpellingChecker_extractUserDictionary) {
693 CONVERT_EACH_TO_ONE (SpellingChecker)
694 autoStringSet result = SpellingChecker_extractUserDictionary (me);
695 CONVERT_EACH_TO_ONE_END (my name.get())
696 }
697
698 FORM (BOOLEAN_SpellingChecker_isWordAllowed, U"Is word allowed?", U"SpellingChecker") {
699 SENTENCE (word, U"Word", U"")
700 OK
701 DO
702 QUERY_ONE_FOR_REAL (SpellingChecker)
703 integer result = SpellingChecker_isWordAllowed (me, word);
704 QUERY_ONE_FOR_REAL_END (result ? U" (allowed)" : U" (not allowed)")
705 }
706
707 FORM (STRING_SpellingChecker_nextNotAllowedWord, U"Next not allowed word?", U"SpellingChecker") {
708 TEXTFIELD (sentence, U"Sentence", U"", 10)
709 INTEGER (startingCharacter, U"Starting character", U"0")
710 OK
711 DO
712 QUERY_ONE_FOR_STRING (SpellingChecker)
713 if (startingCharacter < 0)
714 Melder_throw (U"Your starting character should be 0 or positive.");
715 if (startingCharacter > Melder_length (sentence))
716 Melder_throw (U"Your starting character should not exceed the end of the sentence.");
717 conststring32 result = SpellingChecker_nextNotAllowedWord (me, sentence, & startingCharacter);
718 QUERY_ONE_FOR_STRING_END
719 }
720
721 DIRECT (MODIFY_SpellingChecker_replaceWordList) {
722 MODIFY_FIRST_OF_ONE_AND_ONE (SpellingChecker, WordList)
723 SpellingChecker_replaceWordList (me, you);
724 MODIFY_FIRST_OF_ONE_AND_ONE_END
725 }
726
727 DIRECT (HINT_SpellingChecker_replaceWordList_help) {
728 INFO_NONE
729 Melder_information (U"To replace the checker's word list\nby the contents of a Strings object:\n"
730 U"1. select the Strings;\n2. convert to a WordList object;\n3. select the SpellingChecker and the WordList;\n"
731 U"4. choose Replace.");
732 INFO_NONE_END
733 }
734
735 DIRECT (MODIFY_SpellingChecker_replaceUserDictionary) {
736 MODIFY_FIRST_OF_ONE_AND_ONE (SpellingChecker, StringSet)
737 SpellingChecker_replaceUserDictionary (me, you);
738 MODIFY_FIRST_OF_ONE_AND_ONE_END
739 }
740
741 // MARK: - TEXTGRID
742
743 // MARK: Save
744
745 FORM_SAVE (SAVE_TextGrid_writeToChronologicalTextFile, U"Text file", nullptr, nullptr) {
746 SAVE_ONE (TextGrid, U"save the selected TextGrid object to the chronological text file")
747 TextGrid_writeToChronologicalTextFile (me, file);
748 SAVE_ONE_END
749 }
750
751 // MARK: Help
752
753 DIRECT (HELP_TextGrid_help) {
754 HELP (U"TextGrid")
755 }
756
757 // MARK: View & Edit
758
759 static void cb_TextGridEditor_publication (Editor /* editor */, autoDaata publication) {
760 /*
761 Keep the gate for error handling.
762 */
763 try {
764 bool isaSpectralSlice = Thing_isa (publication.get(), classSpectrum) && str32equ (Thing_getName (publication.get()), U"slice");
765 praat_new (publication.move());
766 praat_updateSelection ();
767 if (isaSpectralSlice) {
768 integer IOBJECT;
769 FIND_ONE_WITH_IOBJECT (Spectrum)
770 autoSpectrumEditor editor2 = SpectrumEditor_create (ID_AND_FULL_NAME, me);
771 praat_installEditor (editor2.get(), IOBJECT);
772 editor2.releaseToUser();
773 }
774 } catch (MelderError) {
775 Melder_flushError ();
776 }
777 }
778 DIRECT (EDITOR_ONE_WITH_ONE_TextGrid_viewAndEdit) {
779 EDITOR_ONE_WITH_ONE (a,TextGrid, Sound) // Sound may be null
780 autoTextGridEditor editor = TextGridEditor_create (ID_AND_FULL_NAME, me, you, nullptr, nullptr);
781 Editor_setPublicationCallback (editor.get(), cb_TextGridEditor_publication);
782 EDITOR_ONE_WITH_ONE_END
783 }
784
785 FORM (EDITOR_ONE_WITH_ONE_TextGrid_viewAndEditWithCallback, U"TextGrid: View & Edit with callback", nullptr) {
786 SENTENCE (callbackText, U"Callback text", U"r1")
787 OK
788 DO
789 EDITOR_ONE_WITH_ONE (a,TextGrid, Sound) // Sound may be null
790 autoTextGridEditor editor = TextGridEditor_create (ID_AND_FULL_NAME, me, you, nullptr, callbackText);
791 Editor_setPublicationCallback (editor.get(), cb_TextGridEditor_publication);
792 EDITOR_ONE_WITH_ONE_END
793 }
794
795 DIRECT (WINDOW_TextGrid_LongSound_viewAndEdit) {
796 if (theCurrentPraatApplication -> batch)
797 Melder_throw (U"Cannot view or edit a TextGrid from batch.");
798 LongSound longSound = nullptr;
799 integer ilongSound = 0;
800 LOOP {
801 if (CLASS == classLongSound)
802 longSound = (LongSound) OBJECT, ilongSound = IOBJECT;
803 }
804 Melder_assert (ilongSound != 0);
805 LOOP if (CLASS == classTextGrid) {
806 iam_LOOP (TextGrid);
807 autoTextGridEditor editor = TextGridEditor_create (ID_AND_FULL_NAME, me, longSound, nullptr, nullptr);
808 Editor_setPublicationCallback (editor.get(), cb_TextGridEditor_publication);
809 praat_installEditor (editor.get(), IOBJECT);
810 editor.releaseToUser();
811 }
812 END_NO_NEW_DATA
813 }
814
815 DIRECT (WINDOW_TextGrid_SpellingChecker_viewAndEdit) {
816 if (theCurrentPraatApplication -> batch)
817 Melder_throw (U"Cannot view or edit a TextGrid from batch.");
818 SpellingChecker spellingChecker = nullptr;
819 integer ispellingChecker = 0;
820 Sound sound = nullptr;
821 LOOP {
822 if (CLASS == classSpellingChecker)
823 spellingChecker = (SpellingChecker) OBJECT, ispellingChecker = IOBJECT;
824 if (CLASS == classSound)
825 sound = (Sound) OBJECT; // may stay null
826 }
827 Melder_assert (ispellingChecker != 0);
828 LOOP if (CLASS == classTextGrid) {
829 iam_LOOP (TextGrid);
830 autoTextGridEditor editor = TextGridEditor_create (ID_AND_FULL_NAME, me, sound, spellingChecker, nullptr);
831 praat_installEditor2 (editor.get(), IOBJECT, ispellingChecker);
832 editor.releaseToUser();
833 }
834 END_NO_NEW_DATA
835 }
836
837 DIRECT (WINDOW_TextGrid_LongSound_SpellingChecker_viewAndEdit) {
838 if (theCurrentPraatApplication -> batch)
839 Melder_throw (U"Cannot view or edit a TextGrid from batch.");
840 LongSound longSound = nullptr;
841 SpellingChecker spellingChecker = nullptr;
842 integer ilongSound = 0, ispellingChecker = 0;
843 LOOP {
844 if (CLASS == classLongSound)
845 longSound = (LongSound) OBJECT, ilongSound = IOBJECT;
846 if (CLASS == classSpellingChecker)
847 spellingChecker = (SpellingChecker) OBJECT, ispellingChecker = IOBJECT;
848 }
849 Melder_assert (ilongSound != 0 && ispellingChecker != 0);
850 LOOP if (CLASS == classTextGrid) {
851 iam_LOOP (TextGrid);
852 autoTextGridEditor editor = TextGridEditor_create (ID_AND_FULL_NAME, me, longSound, spellingChecker, nullptr);
853 praat_installEditor2 (editor.get(), IOBJECT, ispellingChecker);
854 editor.releaseToUser();
855 }
856 END_NO_NEW_DATA
857 }
858
859 DIRECT (HINT_TextGrid_Sound_viewAndEdit) {
860 INFO_NONE
861 Melder_information (U"To include a copy of a Sound in your TextGrid window:\n"
862 U" select a TextGrid and a Sound, and click \"View & Edit\".");
863 INFO_NONE_END
864 }
865
866 // MARK: Draw
867
868 FORM (GRAPHICS_TextGrid_draw, U"TextGrid: Draw", nullptr) {
869 praat_TimeFunction_RANGE (fromTime, toTime)
870 BOOLEAN (showBoundaries, U"Show boundaries", true)
871 BOOLEAN (useTextStyles, U"Use text styles", true)
872 BOOLEAN (garnish, U"Garnish", true)
873 OK
874 DO
875 GRAPHICS_EACH (TextGrid)
876 TextGrid_Sound_draw (me, nullptr, GRAPHICS, fromTime, toTime, showBoundaries, useTextStyles, garnish);
877 GRAPHICS_EACH_END
878 }
879
880 DIRECT (HINT_TextGrid_Sound_draw) {
881 INFO_NONE
882 Melder_information (U"You can draw a TextGrid together with a Sound after selecting them both.");
883 INFO_NONE_END
884 }
885
886 DIRECT (HINT_TextGrid_Pitch_draw) {
887 INFO_NONE
888 Melder_information (U"You can draw a TextGrid together with a Pitch after selecting them both.");
889 INFO_NONE_END
890 }
891
892 // MARK: Tabulate
893
894 FORM (LIST_TextGrid_list, U"TextGrid: List", nullptr) {
895 BOOLEAN (includeLineNumber, U"Include line number", false)
896 NATURAL (timeDecimals, U"Time decimals", U"6")
897 BOOLEAN (includeTierNames, U"Include tier names", true)
898 BOOLEAN (includeEmptyIntervals, U"Include empty intervals", false)
899 OK
900 DO
901 INFO_ONE (TextGrid)
902 TextGrid_list (me, includeLineNumber, timeDecimals, includeTierNames, includeEmptyIntervals);
903 INFO_ONE_END
904 }
905
906 FORM (NEW_TextGrid_downto_Table, U"TextGrid: Down to Table", nullptr) {
907 BOOLEAN (includeLineNumber, U"Include line number", false)
908 NATURAL (timeDecimals, U"Time decimals", U"6")
909 BOOLEAN (includeTierNames, U"Include tier names", true)
910 BOOLEAN (includeEmptyIntervals, U"Include empty intervals", false)
911 OK
912 DO
913 CONVERT_EACH_TO_ONE (TextGrid)
914 autoTable result = TextGrid_downto_Table (me, includeLineNumber, timeDecimals,
915 includeTierNames, includeEmptyIntervals);
916 CONVERT_EACH_TO_ONE_END (my name.get())
917 }
918
919 FORM (NEW_TextGrid_tabulateOccurrences, U"TextGrid: Tabulate occurrences", nullptr) {
920 REALVECTOR (searchTiers, U"Search tiers", WHITESPACE_SEPARATED_, U"1 2")
921 OPTIONMENU_ENUM (kMelder_string, listEveryLabelThat___,
922 U"List every label that...", kMelder_string::DEFAULT)
923 SENTENCE (___theText, U"...the text", U"hello")
924 BOOLEAN (caseSensitive, U"Case-sensitive", false)
925 OK
926 DO
927 CONVERT_EACH_TO_ONE (TextGrid)
928 autoTable result = TextGrid_tabulateOccurrences (me, searchTiers, listEveryLabelThat___, ___theText, caseSensitive);
929 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
930 }
931
932
933 // MARK: Query
934
935 DIRECT (INTEGER_TextGrid_getNumberOfTiers) {
936 QUERY_ONE_FOR_REAL (TextGrid)
937 integer result = my tiers->size;
938 QUERY_ONE_FOR_REAL_END (U" tiers")
939 }
940
941 inline static void pr_TextGrid_checkTierNumber (TextGrid me, integer tierNumber) {
942 if (tierNumber > my tiers->size)
943 Melder_throw (U"Your tier number (", tierNumber,
944 U") should not be greater than the number of tiers (", my tiers->size, U").");
945 }
946
947 inline static Function pr_TextGrid_peekTier (TextGrid me, integer tierNumber) {
948 pr_TextGrid_checkTierNumber (me, tierNumber);
949 return my tiers->at [tierNumber];
950 }
951
952 FORM (STRING_TextGrid_getTierName, U"TextGrid: Get tier name", nullptr) {
953 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
954 OK
955 DO
956 QUERY_ONE_FOR_STRING (TextGrid)
957 Function tier = pr_TextGrid_peekTier (me, tierNumber);
958 conststring32 result = tier -> name.get();
959 QUERY_ONE_FOR_STRING_END
960 }
961
962 FORM (BOOLEAN_TextGrid_isIntervalTier, U"TextGrid: Is interval tier?", nullptr) {
963 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
964 OK
965 DO
966 QUERY_ONE_FOR_REAL (TextGrid)
967 Function tier = pr_TextGrid_peekTier (me, tierNumber);
968 integer result = ( tier -> classInfo == classIntervalTier );
969 QUERY_ONE_FOR_REAL_END (result ? U" (yes, tier " : U" (no, tier ", tierNumber,
970 result ? U" is an interval tier)" : U" is a point tier)")
971 }
972
973 static IntervalTier pr_TextGrid_peekIntervalTier (TextGrid me, integer tierNumber) {
974 Function tier = pr_TextGrid_peekTier (me, tierNumber);
975 if (tier -> classInfo != classIntervalTier)
976 Melder_throw (U"Your tier should be an interval tier.");
977 return (IntervalTier) tier;
978 }
979
980 FORM (INTEGER_TextGrid_getNumberOfIntervals, U"TextGrid: Get number of intervals", nullptr) {
981 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
982 OK
983 DO
984 QUERY_ONE_FOR_REAL (TextGrid)
985 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
986 integer result = intervalTier -> intervals.size;
987 QUERY_ONE_FOR_REAL_END (U" intervals")
988 }
989
990 static TextInterval pr_TextGrid_peekInterval (TextGrid me, integer tierNumber, integer intervalNumber) {
991 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
992 if (intervalNumber > intervalTier -> intervals.size) Melder_throw (U"Interval number too large.");
993 return intervalTier -> intervals.at [intervalNumber];
994 }
995
996 FORM (REAL_TextGrid_getStartTimeOfInterval, U"TextGrid: Get start time of interval", nullptr) {
997 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
998 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
999 OK
1000 DO
1001 QUERY_ONE_FOR_REAL (TextGrid)
1002 TextInterval interval = pr_TextGrid_peekInterval (me, tierNumber, intervalNumber);
1003 double result = interval -> xmin;
1004 QUERY_ONE_FOR_REAL_END (U" seconds")
1005 }
1006
1007 FORM (REAL_TextGrid_getEndTimeOfInterval, U"TextGrid: Get end time of interval", nullptr) {
1008 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1009 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
1010 OK
1011 DO
1012 QUERY_ONE_FOR_REAL (TextGrid)
1013 TextInterval interval = pr_TextGrid_peekInterval (me, tierNumber, intervalNumber);
1014 double result = interval -> xmax;
1015 QUERY_ONE_FOR_REAL_END (U" seconds")
1016 }
1017
1018 FORM (STRING_TextGrid_getLabelOfInterval, U"TextGrid: Get label of interval", nullptr) {
1019 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1020 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
1021 OK
1022 DO
1023 QUERY_ONE_FOR_STRING (TextGrid)
1024 TextInterval interval = pr_TextGrid_peekInterval (me, tierNumber, intervalNumber);
1025 conststring32 result = interval -> text.get();
1026 QUERY_ONE_FOR_STRING_END
1027 }
1028
1029 FORM (INTEGER_TextGrid_getIntervalAtTime, U"TextGrid: Get interval at time", nullptr) {
1030 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1031 REAL (time, U"Time (s)", U"0.5")
1032 OK
1033 DO
1034 QUERY_ONE_FOR_REAL (TextGrid)
1035 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
1036 integer result = IntervalTier_timeToIndex (intervalTier, time);
1037 QUERY_ONE_FOR_REAL_END (U" (interval number)")
1038 }
1039
1040 FORM (INTEGER_TextGrid_getLowIntervalAtTime, U"TextGrid: Get low interval at time", nullptr) {
1041 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1042 REAL (time, U"Time (s)", U"0.5")
1043 OK
1044 DO
1045 QUERY_ONE_FOR_REAL (TextGrid)
1046 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
1047 integer result = IntervalTier_timeToHighIndex (intervalTier, time);
1048 QUERY_ONE_FOR_REAL_END (U" (low interval)")
1049 }
1050
1051 FORM (INTEGER_TextGrid_getHighIntervalAtTime, U"TextGrid: Get high interval at time", nullptr) {
1052 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1053 REAL (time, U"Time (s)", U"0.5")
1054 OK
1055 DO
1056 QUERY_ONE_FOR_REAL (TextGrid)
1057 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
1058 integer result = IntervalTier_timeToLowIndex (intervalTier, time);
1059 QUERY_ONE_FOR_REAL_END (U" (high interval)")
1060 }
1061
1062 FORM (INTEGER_TextGrid_getIntervalEdgeFromTime, U"TextGrid: Get interval edge from time", nullptr) {
1063 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1064 REAL (time, U"Time (s)", U"0.5")
1065 OK
1066 DO
1067 QUERY_ONE_FOR_REAL (TextGrid)
1068 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
1069 integer result = IntervalTier_hasTime (intervalTier, time);
1070 QUERY_ONE_FOR_REAL_END (U" (interval edge)")
1071 }
1072
1073 FORM (INTEGER_TextGrid_getIntervalBoundaryFromTime, U"TextGrid: Get interval boundary from time", nullptr) {
1074 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1075 REAL (time, U"Time (s)", U"0.5")
1076 OK
1077 DO
1078 QUERY_ONE_FOR_REAL (TextGrid)
1079 IntervalTier intervalTier = pr_TextGrid_peekIntervalTier (me, tierNumber);
1080 integer result = IntervalTier_hasBoundary (intervalTier, time);
1081 QUERY_ONE_FOR_REAL_END (U" (interval boundary)")
1082 }
1083
1084 FORM (INTEGER_TextGrid_countIntervalsWhere, U"Count intervals", U"TextGrid: Count intervals where...") {
1085 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
1086 OPTIONMENU_ENUM (kMelder_string, countIntervalsWhoseLabel___,
1087 U"Count intervals whose label...", kMelder_string::DEFAULT)
1088 SENTENCE (___theText, U"...the text", U"hi")
1089 OK
1090 DO
1091 QUERY_ONE_FOR_REAL (TextGrid)
1092 integer result = TextGrid_countIntervalsWhere (me, tierNumber, countIntervalsWhoseLabel___, ___theText);
1093 QUERY_ONE_FOR_REAL_END (U" intervals containing ", ___theText);
1094 }
1095
1096 static TextTier pr_TextGrid_peekTextTier (TextGrid me, integer tierNumber) {
1097 Function tier = pr_TextGrid_peekTier (me, tierNumber);
1098 if (! tier) return nullptr;
1099 if (tier -> classInfo != classTextTier) Melder_throw (U"Your tier should be a point tier (TextTier).");
1100 return (TextTier) tier;
1101 }
1102
1103 FORM (INTEGER_TextGrid_getNumberOfPoints, U"TextGrid: Get number of points", nullptr) {
1104 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1105 OK
1106 DO
1107 QUERY_ONE_FOR_REAL (TextGrid)
1108 TextTier textTier = pr_TextGrid_peekTextTier (me, tierNumber);
1109 integer result = textTier -> points.size;
1110 QUERY_ONE_FOR_REAL_END (U" (points")
1111 }
1112
1113 static TextPoint pr_TextGrid_peekPoint (TextGrid me, integer tierNumber, integer pointNumber) {
1114 TextTier textTier = pr_TextGrid_peekTextTier (me, tierNumber);
1115 if (pointNumber > textTier -> points.size) Melder_throw (U"Point number too large.");
1116 return textTier -> points.at [pointNumber];
1117 }
1118
1119 FORM (REAL_TextGrid_getTimeOfPoint, U"TextGrid: Get time of point", nullptr) {
1120 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1121 NATURAL (pointNumber, STRING_POINT_NUMBER, U"1")
1122 OK
1123 DO
1124 QUERY_ONE_FOR_REAL (TextGrid)
1125 TextPoint point = pr_TextGrid_peekPoint (me, tierNumber, pointNumber);
1126 double result = point -> number;
1127 QUERY_ONE_FOR_REAL_END (U" seconds")
1128 }
1129
1130 FORM (STRING_TextGrid_getLabelOfPoint, U"TextGrid: Get label of point", nullptr) {
1131 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1132 NATURAL (pointNumber, STRING_POINT_NUMBER, U"1")
1133 OK
1134 DO
1135 QUERY_ONE_FOR_STRING (TextGrid)
1136 TextPoint point = pr_TextGrid_peekPoint (me, tierNumber, pointNumber);
1137 conststring32 result = point -> mark.get();
1138 QUERY_ONE_FOR_STRING_END
1139 }
1140
1141 FORM (INTEGER_TextGrid_getLowIndexFromTime, U"Get low index", U"AnyTier: Get low index from time...") {
1142 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1143 REAL (time, U"Time (s)", U"0.5")
1144 OK
1145 DO
1146 QUERY_ONE_FOR_REAL (TextGrid)
1147 TextTier textTier = pr_TextGrid_peekTextTier (me, tierNumber);
1148 integer result = AnyTier_timeToLowIndex (textTier->asAnyTier(), time);
1149 QUERY_ONE_FOR_REAL_END (U" (low index)")
1150 }
1151
1152 FORM (INTEGER_TextGrid_getHighIndexFromTime, U"Get high index", U"AnyTier: Get high index from time...") {
1153 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1154 REAL (time, U"Time (s)", U"0.5")
1155 OK
1156 DO
1157 QUERY_ONE_FOR_REAL (TextGrid)
1158 TextTier textTier = pr_TextGrid_peekTextTier (me, tierNumber);
1159 integer result = AnyTier_timeToHighIndex (textTier->asAnyTier(), time);
1160 QUERY_ONE_FOR_REAL_END (U" (high index)")
1161 }
1162
1163 FORM (INTEGER_TextGrid_getNearestIndexFromTime, U"Get nearest index", U"AnyTier: Get nearest index from time...") {
1164 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1165 REAL (time, U"Time (s)", U"0.5")
1166 OK
1167 DO
1168 QUERY_ONE_FOR_REAL (TextGrid)
1169 TextTier textTier = pr_TextGrid_peekTextTier (me, tierNumber);
1170 integer result = AnyTier_timeToNearestIndex (textTier->asAnyTier(), time);
1171 QUERY_ONE_FOR_REAL_END (U" (nearest index)")
1172 }
1173
1174 FORM (INTEGER_TextGrid_countPointsWhere, U"Count points", U"TextGrid: Count points where...") {
1175 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
1176 OPTIONMENU_ENUM (kMelder_string, countPointsWhoseLabel___,
1177 U"Count points whose label...", kMelder_string::DEFAULT)
1178 SENTENCE (___theText, U"...the text", U"hi")
1179 OK
1180 DO
1181 QUERY_ONE_FOR_REAL (TextGrid)
1182 integer result = TextGrid_countPointsWhere (me, tierNumber, countPointsWhoseLabel___, ___theText);
1183 QUERY_ONE_FOR_REAL_END (U" points containing ", ___theText);
1184 }
1185
1186 FORM (INTEGER_TextGrid_countLabels, U"Count labels", U"TextGrid: Count labels...") {
1187 INTEGER (tierNumber, STRING_TIER_NUMBER, U"1")
1188 SENTENCE (labelText, U"Label text", U"a")
1189 OK
1190 DO
1191 QUERY_ONE_FOR_REAL (TextGrid)
1192 integer result = TextGrid_countLabels (me, tierNumber, labelText);
1193 QUERY_ONE_FOR_REAL_END (U" labels ", labelText)
1194 }
1195
1196 // MARK: Modify
1197
1198 DIRECT (MODIFY_TextGrid_convertToBackslashTrigraphs) {
1199 MODIFY_EACH (TextGrid)
1200 TextGrid_convertToBackslashTrigraphs (me);
1201 MODIFY_EACH_END
1202 }
1203
1204 DIRECT (MODIFY_TextGrid_convertToUnicode) {
1205 MODIFY_EACH (TextGrid)
1206 TextGrid_convertToUnicode (me);
1207 MODIFY_EACH_END
1208 }
1209
1210 FORM (MODIFY_TextGrid_insertIntervalTier, U"TextGrid: Insert interval tier", nullptr) {
1211 NATURAL (position, U"Position", U"1 (= at top)")
1212 WORD (name, U"Name", U"")
1213 OK
1214 DO
1215 MODIFY_EACH (TextGrid)
1216 {// scope
1217 autoIntervalTier tier = IntervalTier_create (my xmin, my xmax);
1218 Melder_clipRight (& position, my tiers->size + 1);
1219 Thing_setName (tier.get(), name);
1220 my tiers -> addItemAtPosition_move (tier.move(), position);
1221 }
1222 MODIFY_EACH_END
1223 }
1224
1225 FORM (MODIFY_TextGrid_insertPointTier, U"TextGrid: Insert point tier", nullptr) {
1226 NATURAL (position, U"Position", U"1 (= at top)")
1227 WORD (name, U"Name", U"")
1228 OK
1229 DO
1230 MODIFY_EACH (TextGrid)
1231 {// scope
1232 autoTextTier tier = TextTier_create (my xmin, my xmax);
1233 Melder_clipRight (& position, my tiers->size + 1);
1234 Thing_setName (tier.get(), name);
1235 my tiers -> addItemAtPosition_move (tier.move(), position);
1236 }
1237 MODIFY_EACH_END
1238 }
1239
1240 FORM (MODIFY_TextGrid_duplicateTier, U"TextGrid: Duplicate tier", nullptr) {
1241 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1242 NATURAL (position, U"Position", U"1 (= at top)")
1243 WORD (name, U"Name", U"")
1244 OK
1245 DO
1246 MODIFY_EACH (TextGrid)
1247 Melder_clipRight (& tierNumber, my tiers->size);
1248 {// scope
1249 autoFunction newTier = Data_copy (my tiers->at [tierNumber]);
1250 Thing_setName (newTier.get(), name);
1251 my tiers -> addItemAtPosition_move (newTier.move(), position);
1252 }
1253 MODIFY_EACH_END
1254 }
1255
1256 FORM (MODIFY_TextGrid_removeTier, U"TextGrid: Remove tier", nullptr) {
1257 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1258 OK
1259 DO
1260 MODIFY_EACH (TextGrid)
1261 if (my tiers->size <= 1)
1262 Melder_throw (U"Sorry, I refuse to remove the last tier.");
1263 Melder_clipRight (& tierNumber, my tiers->size);
1264 my tiers -> removeItem (tierNumber);
1265 MODIFY_EACH_END
1266 }
1267
1268 FORM (MODIFY_TextGrid_insertBoundary, U"TextGrid: Insert boundary", nullptr) {
1269 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1270 REAL (time, U"Time (s)", U"0.5")
1271 OK
1272 DO
1273 MODIFY_EACH (TextGrid)
1274 TextGrid_insertBoundary (me, tierNumber, time);
1275 MODIFY_EACH_END
1276 }
1277
1278 FORM (MODIFY_TextGrid_removeLeftBoundary, U"TextGrid: Remove left boundary", nullptr) {
1279 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1280 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"2")
1281 OK
1282 DO
1283 MODIFY_EACH (TextGrid)
1284 IntervalTier intervalTier;
1285 if (tierNumber > my tiers->size)
1286 Melder_throw (U"You cannot remove a boundary from tier ", tierNumber, U" of ", me,
1287 U", because that TextGrid has only ", my tiers->size, U" tiers.");
1288 intervalTier = (IntervalTier) my tiers->at [tierNumber];
1289 if (intervalTier -> classInfo != classIntervalTier)
1290 Melder_throw (U"You cannot remove a boundary from tier ", tierNumber, U" of ", me,
1291 U", because that tier is a point tier instead of an interval tier.");
1292 if (intervalNumber > intervalTier -> intervals.size)
1293 Melder_throw (U"You cannot remove a boundary from interval ", intervalNumber, U" of tier ", tierNumber, U" of ", me,
1294 U", because that tier has only ", intervalTier -> intervals.size, U" intervals.");
1295 if (intervalNumber == 1)
1296 Melder_throw (U"You cannot remove the left boundary from interval 1 of tier ", tierNumber, U" of ", me,
1297 U", because this is at the left edge of the tier.");
1298 IntervalTier_removeLeftBoundary (intervalTier, intervalNumber);
1299 MODIFY_EACH_END
1300 }
1301
1302 FORM (MODIFY_TextGrid_removeRightBoundary, U"TextGrid: Remove right boundary", nullptr) {
1303 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1304 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"2")
1305 OK
1306 DO
1307 MODIFY_EACH (TextGrid)
1308 IntervalTier intervalTier;
1309 if (tierNumber > my tiers->size)
1310 Melder_throw (U"You cannot remove a boundary from tier ", tierNumber, U" of ", me,
1311 U", because that TextGrid has only ", my tiers->size, U" tiers.");
1312 intervalTier = (IntervalTier) my tiers->at [tierNumber];
1313 if (intervalTier -> classInfo != classIntervalTier)
1314 Melder_throw (U"You cannot remove a boundary from tier ", tierNumber, U" of ", me,
1315 U", because that tier is a point tier instead of an interval tier.");
1316 if (intervalNumber > intervalTier -> intervals.size)
1317 Melder_throw (U"You cannot remove a boundary from interval ", intervalNumber, U" of tier ", tierNumber, U" of ", me,
1318 U", because that tier has only ", intervalTier -> intervals.size, U" intervals.");
1319 if (intervalNumber == intervalTier -> intervals.size)
1320 Melder_throw (U"You cannot remove the right boundary from interval ", intervalNumber, U" of tier ", tierNumber, U" of ", me,
1321 U", because this is at the right edge of the tier.");
1322 IntervalTier_removeLeftBoundary (intervalTier, intervalNumber + 1);
1323 MODIFY_EACH_END
1324 }
1325
1326 FORM (MODIFY_TextGrid_removeBoundaryAtTime, U"TextGrid: Remove boundary at time", nullptr) {
1327 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1328 REAL (time, U"Time (s)", U"0.5")
1329 OK
1330 DO
1331 MODIFY_EACH (TextGrid)
1332 TextGrid_removeBoundaryAtTime (me, tierNumber, time);
1333 MODIFY_EACH_END
1334 }
1335
1336 FORM (MODIFY_TextGrid_setIntervalText, U"TextGrid: Set interval text", nullptr) {
1337 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1338 NATURAL (intervalNumber, STRING_INTERVAL_NUMBER, U"1")
1339 TEXTFIELD (text, U"Text", U"", 10)
1340 OK
1341 DO
1342 MODIFY_EACH (TextGrid)
1343 TextGrid_setIntervalText (me, tierNumber, intervalNumber, text);
1344 MODIFY_EACH_END
1345 }
1346
1347 FORM (MODIFY_TextGrid_insertPoint, U"TextGrid: Insert point", nullptr) {
1348 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1349 REAL (time, U"Time (s)", U"0.5")
1350 TEXTFIELD (text, U"Text", U"", 10)
1351 OK
1352 DO
1353 MODIFY_EACH (TextGrid)
1354 TextGrid_insertPoint (me, tierNumber, time, text);
1355 MODIFY_EACH_END
1356 }
1357
1358 FORM (MODIFY_TextGrid_removePoint, U"TextGrid: Remove point", nullptr) {
1359 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1360 NATURAL (pointNumber, STRING_POINT_NUMBER, U"2")
1361 OK
1362 DO
1363 MODIFY_EACH (TextGrid)
1364 TextTier pointTier;
1365 if (tierNumber > my tiers->size)
1366 Melder_throw (U"You cannot remove a point from tier ", tierNumber, U" of ", me,
1367 U", because that TextGrid has only ", my tiers->size, U" tiers.");
1368 pointTier = (TextTier) my tiers->at [tierNumber];
1369 if (pointTier -> classInfo != classTextTier)
1370 Melder_throw (U"You cannot remove a point from tier ", tierNumber, U" of ", me,
1371 U", because that tier is an interval tier instead of a point tier.");
1372 if (pointNumber > pointTier -> points.size)
1373 Melder_throw (U"You cannot remove point ", pointNumber, U" from tier ", tierNumber, U" of ", me,
1374 U", because that tier has only ", pointTier -> points.size, U" points.");
1375 TextTier_removePoint (pointTier, pointNumber);
1376 MODIFY_EACH_END
1377 }
1378
1379 FORM (MODIFY_TextGrid_removePoints, U"Remove points", nullptr) {
1380 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1381 OPTIONMENU_ENUM (kMelder_string, removeEveryPointWhoseLabel___,
1382 U"Remove every point whose label...", kMelder_string::DEFAULT)
1383 SENTENCE (___theText, U"...the text", U"hi")
1384 OK
1385 DO
1386 MODIFY_EACH (TextGrid)
1387 TextGrid_removePoints (me, tierNumber, removeEveryPointWhoseLabel___, ___theText);
1388 MODIFY_EACH_END
1389 }
1390
1391 FORM (MODIFY_TextGrid_setPointText, U"TextGrid: Set point text", nullptr) {
1392 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1393 NATURAL (pointNumber, STRING_POINT_NUMBER, U"1")
1394 TEXTFIELD (text, U"Text", U"", 10)
1395 OK
1396 DO
1397 MODIFY_EACH (TextGrid)
1398 TextGrid_setPointText (me, tierNumber, pointNumber, text);
1399 MODIFY_EACH_END
1400 }
1401
1402 // MARK: Analyse
1403
1404 FORM (NEW1_TextGrid_extractOneTier, U"TextGrid: Extract one tier", nullptr) {
1405 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1406 OK
1407 DO
1408 CONVERT_EACH_TO_ONE (TextGrid)
1409 Function tier = pr_TextGrid_peekTier (me, tierNumber);
1410 autoTextGrid result = TextGrid_createWithoutTiers (1e308, -1e308);
1411 TextGrid_addTier_copy (result.get(), tier); // no transfer of tier ownership, because a copy is made
1412 CONVERT_EACH_TO_ONE_END (tier -> name.get())
1413 }
1414
1415 FORM (NEW1_TextGrid_extractTier, U"TextGrid: Extract tier", nullptr) {
1416 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1417 OK
1418 DO
1419 CONVERT_EACH_TO_ONE (TextGrid)
1420 Function tier = pr_TextGrid_peekTier (me, tierNumber);
1421 autoFunction result = Data_copy (tier);
1422 CONVERT_EACH_TO_ONE_END (tier -> name.get())
1423 }
1424
1425 FORM (NEW_TextGrid_extractPart, U"TextGrid: Extract part", nullptr) {
1426 REAL (fromTime, U"left Time range (s)", U"0.0")
1427 REAL (toTime, U"right Time range (s)", U"1.0")
1428 BOOLEAN (preserveTimes, U"Preserve times", false)
1429 OK
1430 DO
1431 CONVERT_EACH_TO_ONE (TextGrid)
1432 autoTextGrid result = TextGrid_extractPart (me, fromTime, toTime, preserveTimes);
1433 CONVERT_EACH_TO_ONE_END (my name.get(), U"_part")
1434 }
1435
1436 FORM (NEW_TextGrid_getStartingPoints, U"TextGrid: Get starting points", nullptr) {
1437 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1438 OPTIONMENU_ENUM (kMelder_string, getStartingPointsWhoseLabel___,
1439 U"Get starting points whose label...", kMelder_string::DEFAULT)
1440 SENTENCE (___theText, U"...the text", U"hi")
1441 OK
1442 DO
1443 CONVERT_EACH_TO_ONE (TextGrid)
1444 autoPointProcess result = TextGrid_getStartingPoints (me, tierNumber, getStartingPointsWhoseLabel___, ___theText);
1445 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
1446 }
1447
1448 FORM (NEW_TextGrid_getEndPoints, U"TextGrid: Get end points", nullptr) {
1449 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1450 OPTIONMENU_ENUM (kMelder_string, getEndPointsWhoseLabel___,
1451 U"Get end points whose label", kMelder_string::DEFAULT)
1452 SENTENCE (___theText, U"...the text", U"hi")
1453 OK
1454 DO
1455 CONVERT_EACH_TO_ONE (TextGrid)
1456 autoPointProcess result = TextGrid_getEndPoints (me, tierNumber, getEndPointsWhoseLabel___, ___theText);
1457 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
1458 }
1459
1460 FORM (NEW_TextGrid_getCentrePoints, U"TextGrid: Get centre points", nullptr) {
1461 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1462 OPTIONMENU_ENUM (kMelder_string, getCentrePointsWhoseLabel___,
1463 U"Get centre points whose label", kMelder_string::DEFAULT)
1464 SENTENCE (___theText, U"...the text", U"hi")
1465 OK
1466 DO
1467 CONVERT_EACH_TO_ONE (TextGrid)
1468 autoPointProcess result = TextGrid_getCentrePoints (me, tierNumber, getCentrePointsWhoseLabel___, ___theText);
1469 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
1470 }
1471
1472 FORM (NEW_TextGrid_getPoints, U"Get points", nullptr) {
1473 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1474 OPTIONMENU_ENUM (kMelder_string, getPointsWhoseLabel___,
1475 U"Get points whose label...", kMelder_string::DEFAULT)
1476 SENTENCE (___theText, U"...the text", U"hi")
1477 OK
1478 DO
1479 CONVERT_EACH_TO_ONE (TextGrid)
1480 autoPointProcess result = TextGrid_getPoints (me, tierNumber, getPointsWhoseLabel___, ___theText);
1481 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
1482 }
1483
1484 FORM (NEW_TextGrid_getPoints_preceded, U"Get points (preceded)", nullptr) {
1485 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1486 OPTIONMENU_ENUM (kMelder_string, getPointsWhoseLabel___,
1487 U"Get points whose label...", kMelder_string::DEFAULT)
1488 SENTENCE (___theText, U"...the text", U"there")
1489 OPTIONMENU_ENUM (kMelder_string, ___precededByALabelThat___,
1490 U"...preceded by a label that...", kMelder_string::DEFAULT)
1491 SENTENCE (____theText, U" ...the text", U"hi")
1492 OK
1493 DO
1494 CONVERT_EACH_TO_ONE (TextGrid)
1495 autoPointProcess result = TextGrid_getPoints_preceded (me, tierNumber,
1496 (kMelder_string) getPointsWhoseLabel___, ___theText, ___precededByALabelThat___, ____theText);
1497 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
1498 }
1499
1500 FORM (NEW_TextGrid_getPoints_followed, U"Get points (followed)", nullptr) {
1501 NATURAL (tierNumber, STRING_TIER_NUMBER, U"1")
1502 OPTIONMENU_ENUM (kMelder_string, getPointsWhoseLabel___,
1503 U"Get points whose label...", kMelder_string::DEFAULT)
1504 SENTENCE (___theText, U"...the text", U"hi")
1505 OPTIONMENU_ENUM (kMelder_string, ___followedByALabelThat___,
1506 U"...followed by a label that...", kMelder_string::DEFAULT)
1507 SENTENCE (____theText, U" ...the text", U"there")
1508 OK
1509 DO
1510 CONVERT_EACH_TO_ONE (TextGrid)
1511 autoPointProcess result = TextGrid_getPoints_followed (me, tierNumber,
1512 (kMelder_string) getPointsWhoseLabel___, ___theText, ___followedByALabelThat___, ____theText);
1513 CONVERT_EACH_TO_ONE_END (my name.get(), U"_", ___theText)
1514 }
1515
1516 // MARK: Synthesize
1517
1518 DIRECT (NEW1_TextGrids_merge_OLD) {
1519 COMBINE_ALL_TO_ONE (TextGrid)
1520 autoTextGrid result = TextGrids_merge (& list, false);
1521 COMBINE_ALL_TO_ONE_END (U"merged")
1522 }
1523 FORM (NEW1_TextGrids_merge, U"TextGrids: Merge", U"TextGrids: Merge...") {
1524 BOOLEAN (equalizeDomains, U"Equalize domains", 1)
1525 OK
1526 DO
1527 COMBINE_ALL_TO_ONE (TextGrid)
1528 autoTextGrid result = TextGrids_merge (& list, equalizeDomains);
1529 COMBINE_ALL_TO_ONE_END (U"merged")
1530 }
1531
1532 DIRECT (NEW1_TextGrids_concatenate) {
1533 COMBINE_ALL_TO_ONE (TextGrid)
1534 autoTextGrid result = TextGrids_concatenate (& list);
1535 COMBINE_ALL_TO_ONE_END (U"chain")
1536 }
1537
1538 // MARK: - TEXTGRID & ANYTIER
1539
1540 DIRECT (NEW1_TextGrid_IntervalTier_append) {
1541 CONVERT_ONE_AND_ONE_TO_ONE (TextGrid, IntervalTier)
1542 autoTextGrid result = Data_copy (me);
1543 TextGrid_addTier_copy (result.get(), you);
1544 CONVERT_ONE_AND_ONE_TO_ONE_END (my name.get())
1545 }
1546
1547 DIRECT (NEW1_TextGrid_TextTier_append) {
1548 CONVERT_ONE_AND_ONE_TO_ONE (TextGrid, TextTier)
1549 autoTextGrid result = Data_copy (me);
1550 TextGrid_addTier_copy (result.get(), you);
1551 CONVERT_ONE_AND_ONE_TO_ONE_END (my name.get())
1552 }
1553
1554 // MARK: - TEXTGRID & LONGSOUND
1555
1556 DIRECT (MODIFY_TextGrid_LongSound_scaleTimes) {
1557 MODIFY_FIRST_OF_ONE_AND_ONE (TextGrid, LongSound)
1558 Function_scaleXTo (me, your xmin, your xmax);
1559 MODIFY_FIRST_OF_ONE_AND_ONE_END
1560 }
1561
1562 // MARK: - TEXTTIER
1563
1564 FORM (MODIFY_TextTier_addPoint, U"TextTier: Add point", U"TextTier: Add point...") {
1565 REAL (time, U"Time (s)", U"0.5")
1566 SENTENCE (text, U"Text", U"")
1567 OK
1568 DO
1569 MODIFY_EACH (TextTier)
1570 TextTier_addPoint (me, time, text);
1571 MODIFY_EACH_END
1572 }
1573
1574 DIRECT (NEW_TextTier_downto_PointProcess) {
1575 CONVERT_EACH_TO_ONE (TextTier)
1576 autoPointProcess result = AnyTier_downto_PointProcess (me->asAnyTier());
1577 CONVERT_EACH_TO_ONE_END (my name.get())
1578 }
1579
1580 FORM (NEW_TextTier_downto_TableOfReal, U"TextTier: Down to TableOfReal", nullptr) {
1581 SENTENCE (label, U"Label", U"")
1582 OK
1583 DO
1584 CONVERT_EACH_TO_ONE (TextTier)
1585 autoTableOfReal result = TextTier_downto_TableOfReal (me, label);
1586 CONVERT_EACH_TO_ONE_END (my name.get())
1587 }
1588
1589 DIRECT (NEW_TextTier_downto_TableOfReal_any) {
1590 CONVERT_EACH_TO_ONE (TextTier)
1591 autoTableOfReal result = TextTier_downto_TableOfReal_any (me);
1592 CONVERT_EACH_TO_ONE_END (my name.get())
1593 }
1594
1595 FORM (STRING_TextTier_getLabelOfPoint, U"Get label of point", nullptr) {
1596 NATURAL (pointNumber, U"Point number", U"1")
1597 OK
1598 DO
1599 QUERY_ONE_FOR_STRING (TextTier)
1600 if (pointNumber > my points.size)
1601 Melder_throw (U"No such point.");
1602 TextPoint point = my points.at [pointNumber];
1603 conststring32 result = point -> mark.get();
1604 QUERY_ONE_FOR_STRING_END
1605 }
1606
1607 FORM (NEW_TextTier_getPoints, U"Get points", nullptr) {
1608 SENTENCE (text, U"Text", U"")
1609 OK
1610 DO
1611 CONVERT_EACH_TO_ONE (TextTier)
1612 autoPointProcess result = TextTier_getPoints (me, text);
1613 CONVERT_EACH_TO_ONE_END (text)
1614 }
1615
1616 DIRECT (HELP_TextTier_help) {
1617 HELP (U"TextTier")
1618 }
1619
1620 // MARK: - WORDLIST
1621
1622 FORM (BOOLEAN_WordList_hasWord, U"Does word occur in list?", U"WordList") {
1623 SENTENCE (word, U"Word", U"")
1624 OK
1625 DO
1626 QUERY_ONE_FOR_REAL (WordList)
1627 integer result = WordList_hasWord (me, word);
1628 QUERY_ONE_FOR_REAL_END (result ? U" (present)" : U" (absent)")
1629 }
1630
1631 DIRECT (NEW_WordList_to_Strings) {
1632 CONVERT_EACH_TO_ONE (WordList)
1633 autoStrings result = WordList_to_Strings (me);
1634 CONVERT_EACH_TO_ONE_END (my name.get())
1635 }
1636
1637 DIRECT (NEW_WordList_upto_SpellingChecker) {
1638 CONVERT_EACH_TO_ONE (WordList)
1639 autoSpellingChecker result = WordList_upto_SpellingChecker (me);
1640 CONVERT_EACH_TO_ONE_END (my name.get())
1641 }
1642
1643 /***** buttons *****/
1644
1645 void praat_uvafon_TextGrid_init () {
1646 Thing_recognizeClassByOtherName (classTextTier, U"MarkTier");
1647
1648 structTextGridArea :: f_preferences ();
1649
1650 structTextGridEditor :: f_preferences ();
1651
1652 praat_addAction1 (classIntervalTier, 1, U"Save as Xwaves label file... || Write to Xwaves label file...", nullptr, 0, SAVE_IntervalTier_writeToXwaves);
1653 // alternative COMPATIBILITY <= 2011
1654 praat_addAction1 (classIntervalTier, 0, U"IntervalTier help", nullptr, 0, HELP_IntervalTier_help);
1655 praat_addAction1 (classIntervalTier, 0, U"Collect", nullptr, 0, nullptr);
1656 praat_addAction1 (classIntervalTier, 0, U"Into TextGrid", nullptr, 0, NEW1_AnyTier_into_TextGrid);
1657 praat_addAction1 (classIntervalTier, 0, U"Analyse", nullptr, 0, nullptr);
1658 praat_addAction1 (classIntervalTier, 0, U"Get starting points...", nullptr, 0, NEW_IntervalTier_getStartingPoints);
1659 praat_addAction1 (classIntervalTier, 0, U"Get centre points...", nullptr, 0, NEW_IntervalTier_getCentrePoints);
1660 praat_addAction1 (classIntervalTier, 0, U"Get end points...", nullptr, 0, NEW_IntervalTier_getEndPoints);
1661 praat_addAction1 (classIntervalTier, 0, U"Convert", nullptr, 0, nullptr);
1662 praat_addAction1 (classIntervalTier, 0, U"Down to TableOfReal (any)", nullptr, 0, NEW_IntervalTier_downto_TableOfReal_any);
1663 praat_addAction1 (classIntervalTier, 0, U"Down to TableOfReal...", nullptr, 0, NEW_IntervalTier_downto_TableOfReal);
1664
1665 praat_addAction1 (classLabel, 0, U"& Sound: To TextGrid?", nullptr, 0, HINT_Label_Sound_to_TextGrid);
1666
1667 praat_addAction1 (classSpellingChecker, 1, U"View & Edit... || Edit...", nullptr, GuiMenu_ATTRACTIVE, WINDOW_SpellingChecker_viewAndEdit);
1668 // alternative COMPATIBILITY <= 2011
1669 praat_addAction1 (classSpellingChecker, 0, U"Query", nullptr, 0, nullptr);
1670 praat_addAction1 (classSpellingChecker, 1, U"Is word allowed...", nullptr, 0, BOOLEAN_SpellingChecker_isWordAllowed);
1671 praat_addAction1 (classSpellingChecker, 1, U"Next not allowed word...", nullptr, 0, STRING_SpellingChecker_nextNotAllowedWord);
1672 praat_addAction1 (classSpellingChecker, 0, U"Modify", nullptr, 0, nullptr);
1673 praat_addAction1 (classSpellingChecker, 0, U"Add new word...", nullptr, 0, MODIFY_SpellingChecker_addNewWord);
1674 praat_addAction1 (classSpellingChecker, 0, U"Analyze", nullptr, 0, nullptr);
1675 praat_addAction1 (classSpellingChecker, 0, U"Extract WordList", nullptr, 0, NEW_SpellingChecker_extractWordList);
1676 praat_addAction1 (classSpellingChecker, 0, U"Extract user dictionary", nullptr, 0, NEW_SpellingChecker_extractUserDictionary);
1677
1678 praat_addAction1 (classTextGrid, 1, U"Save as chronological text file...", nullptr, 0, SAVE_TextGrid_writeToChronologicalTextFile);
1679 praat_addAction1 (classTextGrid, 1, U"Write to chronological text file...", nullptr, GuiMenu_HIDDEN, SAVE_TextGrid_writeToChronologicalTextFile);
1680 praat_addAction1 (classTextGrid, 0, U"TextGrid help", nullptr, 0, HELP_TextGrid_help);
1681 praat_addAction1 (classTextGrid, 1, U"View & Edit alone || View & Edit || Edit", nullptr, 0, EDITOR_ONE_WITH_ONE_TextGrid_viewAndEdit);
1682 // alternative COMPATIBILITY <= 2011
1683 praat_addAction1 (classTextGrid, 1, U"View & Edit with Sound?", nullptr, GuiMenu_ATTRACTIVE | GuiMenu_NO_API, HINT_TextGrid_Sound_viewAndEdit);
1684 praat_addAction1 (classTextGrid, 0, U"Draw -", nullptr, 0, nullptr);
1685 praat_addAction1 (classTextGrid, 0, U"Draw...", nullptr, 1, GRAPHICS_TextGrid_draw);
1686 praat_addAction1 (classTextGrid, 1, U"Draw with Sound?", nullptr, 1, HINT_TextGrid_Sound_draw);
1687 praat_addAction1 (classTextGrid, 1, U"Draw with Pitch?", nullptr, 1, HINT_TextGrid_Pitch_draw);
1688 praat_addAction1 (classTextGrid, 1, U"Tabulate -", nullptr, 0, nullptr);
1689 praat_addAction1 (classTextGrid, 0, U"Down to Table...", nullptr, 1, NEW_TextGrid_downto_Table);
1690 praat_addAction1 (classTextGrid, 1, U"List...", nullptr, 1, LIST_TextGrid_list);
1691 praat_addAction1 (classTextGrid, 0, U"Tabulate occurrences...", nullptr, 1, NEW_TextGrid_tabulateOccurrences);
1692 praat_addAction1 (classTextGrid, 0, U"Query -", nullptr, 0, nullptr);
1693 praat_TimeFunction_query_init (classTextGrid);
1694 praat_addAction1 (classTextGrid, 1, U"-- query textgrid --", nullptr, 1, nullptr);
1695 praat_addAction1 (classTextGrid, 1, U"Get number of tiers", nullptr, 1, INTEGER_TextGrid_getNumberOfTiers);
1696 praat_addAction1 (classTextGrid, 1, U"Get tier name...", nullptr, 1, STRING_TextGrid_getTierName);
1697 praat_addAction1 (classTextGrid, 1, U"Is interval tier...", nullptr, 1, BOOLEAN_TextGrid_isIntervalTier);
1698 praat_addAction1 (classTextGrid, 1, U"-- query tier --", nullptr, 1, nullptr);
1699 praat_addAction1 (classTextGrid, 1, U"Query interval tier", nullptr, 1, nullptr);
1700 praat_addAction1 (classTextGrid, 1, U"Get number of intervals...", nullptr, GuiMenu_DEPTH_2, INTEGER_TextGrid_getNumberOfIntervals);
1701 praat_addAction1 (classTextGrid, 1, U"Get start time of interval... || Get starting point... || Get start point...", nullptr, GuiMenu_DEPTH_2,
1702 REAL_TextGrid_getStartTimeOfInterval); // alternatives COMPATIBLITY < 2016
1703 praat_addAction1 (classTextGrid, 1, U"Get end time of interval... || Get end point...", nullptr, GuiMenu_DEPTH_2,
1704 REAL_TextGrid_getEndTimeOfInterval); // alternatives COMPATIBLITY < 2016
1705 praat_addAction1 (classTextGrid, 1, U"Get label of interval...", nullptr, GuiMenu_DEPTH_2, STRING_TextGrid_getLabelOfInterval);
1706 praat_addAction1 (classTextGrid, 1, U"-- query interval from time --", nullptr, GuiMenu_DEPTH_2, nullptr);
1707 praat_addAction1 (classTextGrid, 1, U"Get interval at time...", nullptr, 2, INTEGER_TextGrid_getIntervalAtTime);
1708 praat_addAction1 (classTextGrid, 1, U"Get low interval at time...", nullptr, 2, INTEGER_TextGrid_getLowIntervalAtTime);
1709 praat_addAction1 (classTextGrid, 1, U"Get high interval at time...", nullptr, 2, INTEGER_TextGrid_getHighIntervalAtTime);
1710 praat_addAction1 (classTextGrid, 1, U"Get interval edge from time...", nullptr, 2, INTEGER_TextGrid_getIntervalEdgeFromTime);
1711 praat_addAction1 (classTextGrid, 1, U"Get interval boundary from time...", nullptr, 2, INTEGER_TextGrid_getIntervalBoundaryFromTime);
1712 praat_addAction1 (classTextGrid, 1, U"-- query interval labels --", nullptr, 2, nullptr);
1713 praat_addAction1 (classTextGrid, 1, U"Count intervals where...", nullptr, 2, INTEGER_TextGrid_countIntervalsWhere);
1714 praat_addAction1 (classTextGrid, 1, U"Query point tier", nullptr, 1, nullptr);
1715 praat_addAction1 (classTextGrid, 1, U"Get number of points...", nullptr, 2, INTEGER_TextGrid_getNumberOfPoints);
1716 praat_addAction1 (classTextGrid, 1, U"Get time of point...", nullptr, 2, REAL_TextGrid_getTimeOfPoint);
1717 praat_addAction1 (classTextGrid, 1, U"Get label of point...", nullptr, 2, STRING_TextGrid_getLabelOfPoint);
1718 praat_addAction1 (classTextGrid, 1, U"-- query point from time --", nullptr, 2, nullptr);
1719 praat_addAction1 (classTextGrid, 1, U"Get low index from time...", nullptr, 2, INTEGER_TextGrid_getLowIndexFromTime);
1720 praat_addAction1 (classTextGrid, 1, U"Get high index from time...", nullptr, 2, INTEGER_TextGrid_getHighIndexFromTime);
1721 praat_addAction1 (classTextGrid, 1, U"Get nearest index from time...", nullptr, 2, INTEGER_TextGrid_getNearestIndexFromTime);
1722 praat_addAction1 (classTextGrid, 1, U"-- query point labels --", nullptr, 2, nullptr);
1723 praat_addAction1 (classTextGrid, 1, U"Count points where...", nullptr, 2, INTEGER_TextGrid_countPointsWhere);
1724 praat_addAction1 (classTextGrid, 1, U"-- query labels --", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2015, nullptr);
1725 praat_addAction1 (classTextGrid, 1, U"Count labels...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2015, INTEGER_TextGrid_countLabels);
1726 // replace with Count intervals where... or Count points where...
1727 praat_addAction1 (classTextGrid, 0, U"Modify -", nullptr, 0, nullptr);
1728 praat_addAction1 (classTextGrid, 0, U"Convert to backslash trigraphs", nullptr, 1, MODIFY_TextGrid_convertToBackslashTrigraphs);
1729 praat_addAction1 (classTextGrid, 0, U"Convert to Unicode", nullptr, 1, MODIFY_TextGrid_convertToUnicode);
1730 praat_TimeFunction_modify_init (classTextGrid);
1731 praat_addAction1 (classTextGrid, 0, U"-- modify tiers --", nullptr, 1, nullptr);
1732 praat_addAction1 (classTextGrid, 0, U"Insert interval tier...", nullptr, 1, MODIFY_TextGrid_insertIntervalTier);
1733 praat_addAction1 (classTextGrid, 0, U"Insert point tier...", nullptr, 1, MODIFY_TextGrid_insertPointTier);
1734 praat_addAction1 (classTextGrid, 0, U"Duplicate tier...", nullptr, 1, MODIFY_TextGrid_duplicateTier);
1735 praat_addAction1 (classTextGrid, 0, U"Remove tier...", nullptr, 1, MODIFY_TextGrid_removeTier);
1736 praat_addAction1 (classTextGrid, 1, U"-- modify tier --", nullptr, 1, nullptr);
1737 praat_addAction1 (classTextGrid, 0, U"Modify interval tier", nullptr, 1, nullptr);
1738 praat_addAction1 (classTextGrid, 0, U"Insert boundary...", nullptr, 2, MODIFY_TextGrid_insertBoundary);
1739 praat_addAction1 (classTextGrid, 0, U"Remove left boundary...", nullptr, 2, MODIFY_TextGrid_removeLeftBoundary);
1740 praat_addAction1 (classTextGrid, 0, U"Remove right boundary...", nullptr, 2, MODIFY_TextGrid_removeRightBoundary);
1741 praat_addAction1 (classTextGrid, 0, U"Remove boundary at time...", nullptr, 2, MODIFY_TextGrid_removeBoundaryAtTime);
1742 praat_addAction1 (classTextGrid, 0, U"Set interval text...", nullptr, 2, MODIFY_TextGrid_setIntervalText);
1743 praat_addAction1 (classTextGrid, 0, U"Modify point tier", nullptr, 1, nullptr);
1744 praat_addAction1 (classTextGrid, 0, U"Insert point...", nullptr, 2, MODIFY_TextGrid_insertPoint);
1745 praat_addAction1 (classTextGrid, 0, U"Remove point...", nullptr, 2, MODIFY_TextGrid_removePoint);
1746 praat_addAction1 (classTextGrid, 0, U"Remove points...", nullptr, 2, MODIFY_TextGrid_removePoints);
1747 praat_addAction1 (classTextGrid, 0, U"Set point text...", nullptr, 2, MODIFY_TextGrid_setPointText);
1748 praat_addAction1 (classTextGrid, 0, U"Analyse", nullptr, 0, nullptr);
1749 praat_addAction1 (classTextGrid, 0, U"Extract one tier...", nullptr, 0, NEW1_TextGrid_extractOneTier);
1750 praat_addAction1 (classTextGrid, 0, U"Extract tier...", nullptr, GuiMenu_DEPRECATED_2010,
1751 NEW1_TextGrid_extractTier); // replace imprecisely with Extract one tier...
1752 praat_addAction1 (classTextGrid, 0, U"Extract part...", nullptr, 0, NEW_TextGrid_extractPart);
1753 praat_addAction1 (classTextGrid, 0, U"Analyse interval tier -", nullptr, 0, nullptr);
1754 praat_addAction1 (classTextGrid, 0, U"Get starting points...", nullptr, 1, NEW_TextGrid_getStartingPoints);
1755 praat_addAction1 (classTextGrid, 0, U"Get end points...", nullptr, 1, NEW_TextGrid_getEndPoints);
1756 praat_addAction1 (classTextGrid, 0, U"Get centre points...", nullptr, 1, NEW_TextGrid_getCentrePoints);
1757 praat_addAction1 (classTextGrid, 0, U"Analyse point tier -", nullptr, 0, nullptr);
1758 praat_addAction1 (classTextGrid, 0, U"Get points...", nullptr, 1, NEW_TextGrid_getPoints);
1759 praat_addAction1 (classTextGrid, 0, U"Get points (preceded)...", nullptr, 1, NEW_TextGrid_getPoints_preceded);
1760 praat_addAction1 (classTextGrid, 0, U"Get points (followed)...", nullptr, 1, NEW_TextGrid_getPoints_followed);
1761 praat_addAction1 (classTextGrid, 0, U"Synthesize", nullptr, 0, nullptr);
1762 praat_addAction1 (classTextGrid, 0, U"Merge", nullptr, GuiMenu_DEPRECATED_2025, NEW1_TextGrids_merge_OLD);
1763 praat_addAction1 (classTextGrid, 0, U"Merge...", nullptr, 0, NEW1_TextGrids_merge);
1764 praat_addAction1 (classTextGrid, 0, U"Concatenate", nullptr, 0, NEW1_TextGrids_concatenate);
1765
1766 praat_addAction1 (classTextTier, 0, U"TextTier help", nullptr, 0, HELP_TextTier_help);
1767 praat_addAction1 (classTextTier, 0, U"Query -", nullptr, 0, nullptr);
1768 praat_TimeTier_query_init (classTextTier);
1769 praat_addAction1 (classTextTier, 0, U"Get label of point...", nullptr, 1, STRING_TextTier_getLabelOfPoint);
1770 praat_addAction1 (classTextTier, 0, U"Modify -", nullptr, 0, nullptr);
1771 praat_TimeTier_modify_init (classTextTier);
1772 praat_addAction1 (classTextTier, 0, U"Add point...", nullptr, 1, MODIFY_TextTier_addPoint);
1773 praat_addAction1 (classTextTier, 0, U"Analyse", nullptr, 0, nullptr);
1774 praat_addAction1 (classTextTier, 0, U"Get points...", nullptr, 0, NEW_TextTier_getPoints);
1775 praat_addAction1 (classTextTier, 0, U"Collect", nullptr, 0, nullptr);
1776 praat_addAction1 (classTextTier, 0, U"Into TextGrid", nullptr, 0, NEW1_AnyTier_into_TextGrid);
1777 praat_addAction1 (classTextTier, 0, U"Convert", nullptr, 0, nullptr);
1778 praat_addAction1 (classTextTier, 0, U"Down to PointProcess", nullptr, 0, NEW_TextTier_downto_PointProcess);
1779 praat_addAction1 (classTextTier, 0, U"Down to TableOfReal (any)", nullptr, 0, NEW_TextTier_downto_TableOfReal_any);
1780 praat_addAction1 (classTextTier, 0, U"Down to TableOfReal...", nullptr, 0, NEW_TextTier_downto_TableOfReal);
1781
1782 praat_addAction1 (classWordList, 0, U"Query", nullptr, 0, nullptr);
1783 praat_addAction1 (classWordList, 1, U"Has word...", nullptr, 0, BOOLEAN_WordList_hasWord);
1784 praat_addAction1 (classWordList, 0, U"Analyze", nullptr, 0, nullptr);
1785 praat_addAction1 (classWordList, 0, U"To Strings", nullptr, 0, NEW_WordList_to_Strings);
1786 praat_addAction1 (classWordList, 0, U"Synthesize", nullptr, 0, nullptr);
1787 praat_addAction1 (classWordList, 0, U"Up to SpellingChecker", nullptr, 0, NEW_WordList_upto_SpellingChecker);
1788
1789 praat_addAction2 (classIntervalTier, 1, classPointProcess, 1, U"Start to centre...", nullptr, 0, NEW1_IntervalTier_PointProcess_startToCentre);
1790 praat_addAction2 (classIntervalTier, 1, classPointProcess, 1, U"End to centre...", nullptr, 0, NEW1_IntervalTier_PointProcess_endToCentre);
1791 praat_addAction2 (classIntervalTier, 0, classTextTier, 0, U"Collect", nullptr, 0, nullptr);
1792 praat_addAction2 (classIntervalTier, 0, classTextTier, 0, U"Into TextGrid", nullptr, 0, NEW1_AnyTier_into_TextGrid);
1793 praat_addAction2 (classLabel, 1, classSound, 1, U"To TextGrid", nullptr, 0, NEW1_Label_Sound_to_TextGrid);
1794 praat_addAction2 (classLongSound, 1, classTextGrid, 1, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE,
1795 WINDOW_TextGrid_LongSound_viewAndEdit); // alternative COMPATIBILITY <= 2011
1796 praat_addAction2 (classLongSound, 1, classTextGrid, 1, U"Scale times", nullptr, 0, MODIFY_TextGrid_LongSound_scaleTimes);
1797 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw -", nullptr, 0, nullptr);
1798 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw...", nullptr, 1, GRAPHICS_TextGrid_Pitch_draw);
1799 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw logarithmic...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawLogarithmic);
1800 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw semitones...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawSemitones);
1801 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw mel...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawMel);
1802 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw erb...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawErb);
1803 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckle);
1804 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle logarithmic...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleLogarithmic);
1805 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle semitones...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleSemitones);
1806 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle mel...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleMel);
1807 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle erb...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleErb);
1808 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"-- draw separately --", nullptr, 1, nullptr);
1809 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw separately...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawSeparately);
1810 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw separately (logarithmic)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawSeparatelyLogarithmic);
1811 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw separately (semitones)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawSeparatelySemitones);
1812 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw separately (mel)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawSeparatelyMel);
1813 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Draw separately (erb)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_drawSeparatelyErb);
1814 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle separately...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleSeparately);
1815 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle separately (logarithmic)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleSeparatelyLogarithmic);
1816 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle separately (semitones)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleSeparatelySemitones);
1817 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle separately (mel)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleSeparatelyMel);
1818 praat_addAction2 (classPitch, 1, classTextGrid, 1, U"Speckle separately (erb)...", nullptr, 1, GRAPHICS_TextGrid_Pitch_speckleSeparatelyErb);
1819 praat_addAction2 (classPitch, 1, classTextTier, 1, U"To PitchTier...", nullptr, 0, NEW1_Pitch_TextTier_to_PitchTier);
1820 praat_addAction2 (classSound, 1, classTextGrid, 1, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE,
1821 EDITOR_ONE_WITH_ONE_TextGrid_viewAndEdit); // alternative COMPATIBILITY <= 2011
1822 praat_addAction2 (classSound, 1, classTextGrid, 1, U"View & Edit with callback...", nullptr, GuiMenu_HIDDEN, EDITOR_ONE_WITH_ONE_TextGrid_viewAndEditWithCallback);
1823 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Draw...", nullptr, 0, GRAPHICS_TextGrid_Sound_draw);
1824 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Extract -", nullptr, 0, nullptr);
1825 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Extract all intervals...", nullptr, GuiMenu_DEPTH_1, NEW1_TextGrid_Sound_extractAllIntervals);
1826 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Extract non-empty intervals...", nullptr, GuiMenu_DEPTH_1, NEW1_TextGrid_Sound_extractNonemptyIntervals);
1827 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Extract intervals where...", nullptr, GuiMenu_DEPTH_1,
1828 NEW1_TextGrid_Sound_extractIntervalsWhere);
1829 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Extract intervals...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2005,
1830 NEW1_TextGrid_Sound_extractIntervals); // replace with Extract intervals where: arg1, arg2, "is equal to", arg3
1831 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Modify TextGrid", nullptr, 0, nullptr);
1832 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Align interval...", nullptr, 0, MODIFY_TextGrid_Sound_alignInterval);
1833 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Scale times", nullptr, 0, MODIFY_TextGrid_Sound_scaleTimes);
1834 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Transcribe interval...", nullptr, 0, MODIFY_TextGrid_Sound_transcribeInterval);
1835 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Diarize interval...", nullptr, 0, MODIFY_TextGrid_Sound_diarizeInterval);
1836 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Modify Sound", nullptr, 0, nullptr);
1837 praat_addAction2 (classSound, 1, classTextGrid, 1, U"Clone time domain", nullptr, 0, MODIFY_TextGrid_Sound_cloneTimeDomain);
1838 praat_addAction2 (classSpellingChecker, 1, classWordList, 1, U"Replace WordList", nullptr, 0, MODIFY_SpellingChecker_replaceWordList);
1839 praat_addAction2 (classSpellingChecker, 1, classStringSet, 1, U"Replace user dictionary", nullptr, 0, MODIFY_SpellingChecker_replaceUserDictionary);
1840 praat_addAction2 (classSpellingChecker, 1, classStrings, 1, U"Replace word list?", nullptr, 0, HINT_SpellingChecker_replaceWordList_help);
1841 praat_addAction2 (classSpellingChecker, 1, classTextGrid, 1, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE,
1842 WINDOW_TextGrid_SpellingChecker_viewAndEdit); // alternative COMPATIBILITY <= 2011
1843 praat_addAction2 (classTextGrid, 1, classIntervalTier, 1, U"Append", nullptr, 0, NEW1_TextGrid_IntervalTier_append);
1844 praat_addAction2 (classTextGrid, 1, classTextTier, 1, U"Append", nullptr, 0, NEW1_TextGrid_TextTier_append);
1845
1846 praat_addAction3 (classLongSound, 1, classSpellingChecker, 1, classTextGrid, 1, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE,
1847 WINDOW_TextGrid_LongSound_SpellingChecker_viewAndEdit); // alternative COMPATIBILITY <= 2011
1848 praat_addAction3 (classSound, 1, classSpellingChecker, 1, classTextGrid, 1, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE,
1849 WINDOW_TextGrid_SpellingChecker_viewAndEdit); // alternative COMPATIBILITY <= 2011
1850 }
1851
1852 /* End of file praat_TextGrid_init.cpp */