praat_TextGrid_init.cpp 77 KB

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