praat_Matrix.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. /* praat_Matrix.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 "Cochleagram.h"
  19. #include "Excitation.h"
  20. #include "Harmonicity.h"
  21. #include "Intensity.h"
  22. #include "Ltas.h"
  23. #include "Matrix_and_PointProcess.h"
  24. #include "Matrix_and_Polygon.h"
  25. #include "Matrix_and_Pitch.h"
  26. #include "MovieWindow.h"
  27. #include "ParamCurve.h"
  28. #include "Photo.h"
  29. #include "Spectrogram.h"
  30. #include "Spectrum.h"
  31. #include "Transition.h"
  32. #include "VocalTract.h"
  33. #include "praat_Matrix.h"
  34. #undef iam
  35. #define iam iam_LOOP
  36. // MARK: - MATRIX
  37. // MARK: New
  38. FORM (NEW1_Matrix_create, U"Create Matrix", U"Create Matrix...") {
  39. WORD (name, U"Name", U"xy")
  40. REAL (xmin, U"xmin", U"1.0")
  41. REAL (xmax, U"xmax", U"1.0")
  42. NATURAL (numberOfColumns, U"Number of columns", U"1")
  43. POSITIVE (dx, U"dx", U"1.0")
  44. REAL (x1, U"x1", U"1.0")
  45. REAL (ymin, U"ymin", U"1.0")
  46. REAL (ymax, U"ymax", U"1.0")
  47. NATURAL (numberOfRows, U"Number of rows", U"1")
  48. POSITIVE (dy, U"dy", U"1.0")
  49. REAL (y1, U"y1", U"1.0")
  50. TEXTFIELD (formula, U"Formula:", U"x*y")
  51. OK
  52. DO
  53. if (xmax < xmin) Melder_throw (U"Your xmax (", Melder_single (xmax), U") should not be less than your xmin (", Melder_single (xmin), U").");
  54. if (ymax < ymin) Melder_throw (U"Your ymax (", Melder_single (ymax), U") should not be less than your ymin (", Melder_single (ymin), U").");
  55. CREATE_ONE
  56. autoMatrix result = Matrix_create (
  57. xmin, xmax, numberOfColumns, dx, x1,
  58. ymin, ymax, numberOfRows, dy, y1);
  59. Matrix_formula (result.get(), formula, interpreter, nullptr);
  60. CREATE_ONE_END (name)
  61. }
  62. FORM (NEW1_Matrix_createSimple, U"Create simple Matrix", U"Create simple Matrix...") {
  63. WORD (name, U"Name", U"xy")
  64. NATURAL (numberOfRows, U"Number of rows", U"10")
  65. NATURAL (numberOfColumns, U"Number of columns", U"10")
  66. TEXTFIELD (formula, U"Formula:", U"x*y")
  67. OK
  68. DO
  69. CREATE_ONE
  70. autoMatrix result = Matrix_createSimple (numberOfRows, numberOfColumns);
  71. Matrix_formula (result.get(), formula, interpreter, nullptr);
  72. CREATE_ONE_END (name);
  73. }
  74. // MARK: Open
  75. FORM_READ (READ1_Matrix_readFromRawTextFile, U"Read Matrix from raw text file", nullptr, true) {
  76. READ_ONE
  77. autoMatrix result = Matrix_readFromRawTextFile (file);
  78. READ_ONE_END
  79. }
  80. FORM_READ (READ1_Matrix_readAP, U"Read Matrix from LVS AP file", nullptr, true) {
  81. READ_ONE
  82. autoMatrix result = Matrix_readAP (file);
  83. READ_ONE_END
  84. }
  85. // MARK: Save
  86. FORM_SAVE (SAVE_Matrix_writeToMatrixTextFile, U"Save Matrix as matrix text file", nullptr, U"mat") {
  87. FIND_ONE (Matrix)
  88. Matrix_writeToMatrixTextFile (me, file);
  89. END
  90. }
  91. FORM_SAVE (SAVE_Matrix_writeToHeaderlessSpreadsheetFile, U"Save Matrix as spreadsheet", nullptr, U"txt") {
  92. FIND_ONE (Matrix)
  93. Matrix_writeToHeaderlessSpreadsheetFile (me, file);
  94. END
  95. }
  96. // MARK: Help
  97. DIRECT (HELP_Matrix_help) {
  98. HELP (U"Matrix")
  99. }
  100. // MARK: Movie
  101. static autoGraphics theMovieGraphics;
  102. static void gui_drawingarea_cb_expose (Thing /* boss */, GuiDrawingArea_ExposeEvent /* event */) {
  103. if (! theMovieGraphics) return;
  104. Graphics_play (theMovieGraphics.get(), theMovieGraphics.get());
  105. }
  106. extern "C" Graphics Movie_create (conststring32 title, int width, int height) {
  107. static GuiDialog dialog;
  108. static GuiDrawingArea drawingArea;
  109. if (! theMovieGraphics) {
  110. dialog = GuiDialog_create (theCurrentPraatApplication -> topShell, 100, 100, width + 2, height + 2, title, nullptr, nullptr, 0);
  111. drawingArea = GuiDrawingArea_createShown (dialog, 0, width, 0, height, gui_drawingarea_cb_expose, nullptr, nullptr, nullptr, nullptr, 0);
  112. GuiThing_show (dialog);
  113. theMovieGraphics = Graphics_create_xmdrawingarea (drawingArea);
  114. }
  115. GuiShell_setTitle (dialog, title);
  116. GuiControl_setSize (dialog, width + 2, height + 2);
  117. GuiControl_setSize (drawingArea, width, height);
  118. GuiThing_show (dialog);
  119. return theMovieGraphics.get();
  120. }
  121. DIRECT (MOVIE_Matrix_movie) {
  122. MOVIE_ONE (Matrix, U"Matrix movie", 300, 300)
  123. Matrix_movie (me, graphics);
  124. MOVIE_ONE_END
  125. }
  126. // MARK: Draw
  127. FORM (GRAPHICS_Matrix_drawRows, U"Draw rows", nullptr) {
  128. REAL (fromX, U"From x =", U"0.0")
  129. REAL (toX, U"To x =", U"0.0")
  130. REAL (fromY, U"From y =", U"0.0")
  131. REAL (toY, U"To y =", U"0.0")
  132. REAL (minimum, U"Minimum", U"0.0")
  133. REAL (maximum, U"Maximum", U"0.0")
  134. OK
  135. DO
  136. GRAPHICS_EACH (Matrix)
  137. Matrix_drawRows (me, GRAPHICS, fromX, toX, fromY, toY, minimum, maximum);
  138. GRAPHICS_EACH_END
  139. }
  140. FORM (GRAPHICS_Matrix_drawOneContour, U"Draw one altitude contour", nullptr) {
  141. REAL (fromX, U"From x =", U"0.0")
  142. REAL (toX, U"To x =", U"0.0")
  143. REAL (fromY, U"From y =", U"0.0")
  144. REAL (toY, U"To y =", U"0.0")
  145. REAL (height, U"Height", U"0.5")
  146. OK
  147. DO
  148. GRAPHICS_EACH (Matrix)
  149. Matrix_drawOneContour (me, GRAPHICS,fromX, toX, fromY, toY, height);
  150. GRAPHICS_EACH_END
  151. }
  152. FORM (GRAPHICS_Matrix_drawContours, U"Draw altitude contours", nullptr) {
  153. REAL (fromX, U"From x =", U"0.0")
  154. REAL (toX, U"To x =", U"0.0")
  155. REAL (fromY, U"From y =", U"0.0")
  156. REAL (toY, U"To y =", U"0.0")
  157. REAL (minimum, U"Minimum", U"0.0")
  158. REAL (maximum, U"Maximum", U"0.0")
  159. OK
  160. DO
  161. GRAPHICS_EACH (Matrix)
  162. Matrix_drawContours (me, GRAPHICS, fromX, toX, fromY, toY, minimum, maximum);
  163. GRAPHICS_EACH_END
  164. }
  165. FORM (GRAPHICS_Matrix_paintImage, U"Matrix: Paint grey image", nullptr) {
  166. REAL (fromX, U"From x =", U"0.0")
  167. REAL (toX, U"To x =", U"0.0")
  168. REAL (fromY, U"From y =", U"0.0")
  169. REAL (toY, U"To y =", U"0.0")
  170. REAL (minimum, U"Minimum", U"0.0")
  171. REAL (maximum, U"Maximum", U"0.0")
  172. OK
  173. DO
  174. GRAPHICS_EACH (Matrix)
  175. Matrix_paintImage (me, GRAPHICS, fromX, toX, fromY, toY, minimum, maximum);
  176. GRAPHICS_EACH_END
  177. }
  178. FORM (GRAPHICS_Matrix_paintContours, U"Matrix: Paint altitude contours with greys", nullptr) {
  179. REAL (fromX, U"From x =", U"0.0")
  180. REAL (toX, U"To x =", U"0.0")
  181. REAL (fromY, U"From y =", U"0.0")
  182. REAL (toY, U"To y =", U"0.0")
  183. REAL (minimum, U"Minimum", U"0.0")
  184. REAL (maximum, U"Maximum", U"0.0")
  185. OK
  186. DO
  187. GRAPHICS_EACH (Matrix)
  188. Matrix_paintContours (me, GRAPHICS, fromX, toX, fromY, toY, minimum, maximum);
  189. GRAPHICS_EACH_END
  190. }
  191. FORM (GRAPHICS_Matrix_paintCells, U"Matrix: Paint cells with greys", U"Matrix: Paint cells...") {
  192. REAL (fromX, U"From x =", U"0.0")
  193. REAL (toX, U"To x =", U"0.0")
  194. REAL (fromY, U"From y =", U"0.0")
  195. REAL (toY, U"To y =", U"0.0")
  196. REAL (minimum, U"Minimum", U"0.0")
  197. REAL (maximum, U"Maximum", U"0.0")
  198. OK
  199. DO
  200. GRAPHICS_EACH (Matrix)
  201. Matrix_paintCells (me, GRAPHICS, fromX, toX, fromY, toY, minimum, maximum);
  202. GRAPHICS_EACH_END
  203. }
  204. FORM (GRAPHICS_Matrix_paintSurface, U"Matrix: Paint 3-D surface plot", nullptr) {
  205. REAL (fromX, U"From x =", U"0.0")
  206. REAL (toX, U"To x =", U"0.0")
  207. REAL (fromY, U"From y =", U"0.0")
  208. REAL (toY, U"To y =", U"0.0")
  209. REAL (minimum, U"Minimum", U"0.0")
  210. REAL (maximum, U"Maximum", U"0.0")
  211. OK
  212. DO
  213. GRAPHICS_EACH (Matrix)
  214. Matrix_paintSurface (me, GRAPHICS, fromX, toX, fromY, toY, minimum, maximum, 30, 45);
  215. GRAPHICS_EACH_END
  216. }
  217. // MARK: Query
  218. DIRECT (REAL_Matrix_getLowestX) {
  219. NUMBER_ONE (Matrix)
  220. double result = my xmin;
  221. NUMBER_ONE_END (U" (xmin)")
  222. }
  223. DIRECT (REAL_Matrix_getHighestX) {
  224. NUMBER_ONE (Matrix)
  225. double result = my xmax;
  226. NUMBER_ONE_END (U" (xmax)")
  227. }
  228. DIRECT (REAL_Matrix_getLowestY) {
  229. NUMBER_ONE (Matrix)
  230. double result = my ymin;
  231. NUMBER_ONE_END (U" (ymin)")
  232. }
  233. DIRECT (REAL_Matrix_getHighestY) {
  234. NUMBER_ONE (Matrix)
  235. double result = my ymax;
  236. NUMBER_ONE_END (U" (xmax)")
  237. }
  238. DIRECT (INTEGER_Matrix_getNumberOfRows) {
  239. NUMBER_ONE (Matrix)
  240. integer result = my ny;
  241. NUMBER_ONE_END (U" rows")
  242. }
  243. DIRECT (INTEGER_Matrix_getNumberOfColumns) {
  244. NUMBER_ONE (Matrix)
  245. integer result = my nx;
  246. NUMBER_ONE_END (U" columns")
  247. }
  248. DIRECT (REAL_Matrix_getRowDistance) {
  249. NUMBER_ONE (Matrix)
  250. double result = my dy;
  251. NUMBER_ONE_END (U" (row distance)")
  252. }
  253. DIRECT (REAL_Matrix_getColumnDistance) {
  254. NUMBER_ONE (Matrix)
  255. double result = my dx;
  256. NUMBER_ONE_END (U" (column distance)")
  257. }
  258. FORM (REAL_Matrix_getYofRow, U"Matrix: Get y of row", nullptr) {
  259. NATURAL (rowNumber, U"Row number", U"1")
  260. OK
  261. DO
  262. NUMBER_ONE (Matrix)
  263. double result = Matrix_rowToY (me, rowNumber);
  264. NUMBER_ONE_END (U" (y of row ", rowNumber, U")")
  265. }
  266. FORM (REAL_Matrix_getXofColumn, U"Matrix: Get x of column", nullptr) {
  267. NATURAL (columnNumber, U"Column number", U"1")
  268. OK
  269. DO
  270. NUMBER_ONE (Matrix)
  271. double result = Matrix_columnToX (me, columnNumber);
  272. NUMBER_ONE_END (U" (x of column ", columnNumber, U")")
  273. }
  274. FORM (REAL_Matrix_getValueInCell, U"Matrix: Get value in cell", nullptr) {
  275. NATURAL (rowNumber, U"Row number", U"1")
  276. NATURAL (columnNumber, U"Column number", U"1")
  277. OK
  278. DO
  279. NUMBER_ONE (Matrix)
  280. if (rowNumber > my ny) Melder_throw (U"Row number should not exceed number of rows.");
  281. if (columnNumber > my nx) Melder_throw (U"Column number should not exceed number of columns.");
  282. double result = my z [rowNumber] [columnNumber];
  283. NUMBER_ONE_END (U" (value in column ", columnNumber, U" of row ", rowNumber, U")")
  284. }
  285. FORM (REAL_Matrix_getValueAtXY, U"Matrix: Get value at xy", nullptr) {
  286. REAL (x, U"X", U"0.0")
  287. REAL (y, U"Y", U"0.0")
  288. OK
  289. DO
  290. NUMBER_ONE (Matrix)
  291. double result = Matrix_getValueAtXY (me, x, y);
  292. NUMBER_ONE_END (U" (at x = ", x, U" and y = ", y, U")");
  293. }
  294. DIRECT (REAL_Matrix_getMinimum) {
  295. NUMBER_ONE (Matrix)
  296. double minimum = undefined, maximum = undefined;
  297. Matrix_getWindowExtrema (me, 0, 0, 0, 0, & minimum, & maximum);
  298. double result = minimum;
  299. NUMBER_ONE_END (U" (minimum)");
  300. }
  301. DIRECT (REAL_Matrix_getMaximum) {
  302. NUMBER_ONE (Matrix)
  303. double minimum = undefined, maximum = undefined;
  304. Matrix_getWindowExtrema (me, 0, 0, 0, 0, & minimum, & maximum);
  305. double result = maximum;
  306. NUMBER_ONE_END (U" (maximum)");
  307. }
  308. DIRECT (REAL_Matrix_getSum) {
  309. NUMBER_ONE (Matrix)
  310. double result = Matrix_getSum (me);
  311. NUMBER_ONE_END (U" (sum)");
  312. }
  313. // MARK: Modify
  314. FORM (MODIFY_Matrix_formula, U"Matrix Formula", U"Formula...") {
  315. LABEL (U"y := y1; for row := 1 to nrow do { x := x1; "
  316. "for col := 1 to ncol do { self [row, col] := `formula` ; x := x + dx } y := y + dy }")
  317. TEXTFIELD (formula, U"Formula:", U"self")
  318. OK
  319. DO
  320. MODIFY_EACH_WEAK (Matrix)
  321. Matrix_formula (me, formula, interpreter, nullptr);
  322. MODIFY_EACH_WEAK_END
  323. }
  324. FORM (MODIFY_Matrix_setValue, U"Matrix: Set value", U"Matrix: Set value...") {
  325. NATURAL (rowNumber, U"Row number", U"1")
  326. NATURAL (columnNumber, U"Column number", U"1")
  327. REAL (newValue, U"New value", U"0.0")
  328. OK
  329. DO
  330. MODIFY_EACH (Matrix)
  331. if (rowNumber > my ny)
  332. Melder_throw (U"Your row number should not be greater than your number of rows.");
  333. if (columnNumber > my nx)
  334. Melder_throw (U"Your column number should not be greater than your number of columns.");
  335. my z [rowNumber] [columnNumber] = newValue;
  336. MODIFY_EACH_END
  337. }
  338. // MARK: Analyse
  339. DIRECT (NEWTIMES2_Matrix_eigen) {
  340. LOOP {
  341. iam_LOOP (Matrix);
  342. autoMatrix vectors, values;
  343. Matrix_eigen (me, & vectors, & values);
  344. praat_new (vectors.move(), U"eigenvectors");
  345. praat_new (values.move(), U"eigenvalues");
  346. }
  347. END }
  348. // MARK: Synthesize
  349. FORM (NEW_Matrix_power, U"Matrix: Power...", nullptr) {
  350. NATURAL (power, U"Power", U"2")
  351. OK
  352. DO
  353. CONVERT_EACH (Matrix)
  354. autoMatrix result = Matrix_power (me, power);
  355. CONVERT_EACH_END (my name.get())
  356. }
  357. // MARK: Combine
  358. DIRECT (NEW1_Matrix_appendRows) {
  359. CONVERT_COUPLE (Matrix)
  360. autoMatrix result = Matrix_appendRows (me, you, classMatrix);
  361. CONVERT_COUPLE_END (my name.get(), U"_", your name.get())
  362. }
  363. // MARK: Cast
  364. DIRECT (NEW_Matrix_to_Cochleagram) {
  365. CONVERT_EACH (Matrix)
  366. autoCochleagram result = Matrix_to_Cochleagram (me);
  367. CONVERT_EACH_END (my name.get())
  368. }
  369. DIRECT (NEW_Matrix_to_Excitation) {
  370. CONVERT_EACH (Matrix)
  371. autoExcitation result = Matrix_to_Excitation (me);
  372. CONVERT_EACH_END (my name.get())
  373. }
  374. DIRECT (NEW_Matrix_to_Harmonicity) {
  375. CONVERT_EACH (Matrix)
  376. autoHarmonicity result = Matrix_to_Harmonicity (me);
  377. CONVERT_EACH_END (my name.get())
  378. }
  379. DIRECT (NEW_Matrix_to_Intensity) {
  380. CONVERT_EACH (Matrix)
  381. autoIntensity result = Matrix_to_Intensity (me);
  382. CONVERT_EACH_END (my name.get())
  383. }
  384. DIRECT (NEW_Matrix_to_Ltas) {
  385. CONVERT_EACH (Matrix)
  386. autoLtas result = Matrix_to_Ltas (me);
  387. CONVERT_EACH_END (my name.get())
  388. }
  389. DIRECT (NEW_Matrix_to_Pitch) {
  390. CONVERT_EACH (Matrix)
  391. autoPitch result = Matrix_to_Pitch (me);
  392. CONVERT_EACH_END (my name.get())
  393. }
  394. DIRECT (NEW_Matrix_to_PointProcess) {
  395. CONVERT_EACH (Matrix)
  396. autoPointProcess result = Matrix_to_PointProcess (me);
  397. CONVERT_EACH_END (my name.get())
  398. }
  399. DIRECT (NEW_Matrix_to_Polygon) {
  400. CONVERT_EACH (Matrix)
  401. autoPolygon result = Matrix_to_Polygon (me);
  402. CONVERT_EACH_END (my name.get())
  403. }
  404. DIRECT (NEW_Matrix_to_Sound) {
  405. CONVERT_EACH (Matrix)
  406. autoSound result = Matrix_to_Sound (me);
  407. CONVERT_EACH_END (my name.get())
  408. }
  409. FORM (NEW_Matrix_to_Sound_mono, U"Matrix: To Sound (mono)", 0) {
  410. INTEGER (rowNumber, U"Row number", U"1")
  411. LABEL (U"(negative values count from last row)")
  412. OK
  413. DO
  414. CONVERT_EACH (Matrix)
  415. autoSound result = Matrix_to_Sound_mono (me, rowNumber);
  416. CONVERT_EACH_END (my name.get())
  417. }
  418. DIRECT (NEW_Matrix_to_Spectrogram) {
  419. CONVERT_EACH (Matrix)
  420. autoSpectrogram result = Matrix_to_Spectrogram (me);
  421. CONVERT_EACH_END (my name.get())
  422. }
  423. DIRECT (NEW_Matrix_to_Spectrum) {
  424. CONVERT_EACH (Matrix)
  425. autoSpectrum result = Matrix_to_Spectrum (me);
  426. CONVERT_EACH_END (my name.get())
  427. }
  428. DIRECT (NEW_Matrix_to_TableOfReal) {
  429. CONVERT_EACH (Matrix)
  430. autoTableOfReal result = Matrix_to_TableOfReal (me);
  431. CONVERT_EACH_END (my name.get())
  432. }
  433. DIRECT (NEW_Matrix_to_Transition) {
  434. CONVERT_EACH (Matrix)
  435. autoTransition result = Matrix_to_Transition (me);
  436. CONVERT_EACH_END (my name.get())
  437. }
  438. DIRECT (NEW_Matrix_to_VocalTract) {
  439. CONVERT_EACH (Matrix)
  440. autoVocalTract result = Matrix_to_VocalTract (me);
  441. CONVERT_EACH_END (my name.get())
  442. }
  443. DIRECT (NEW1_Matrix_to_ParamCurve) {
  444. CONVERT_COUPLE (Matrix)
  445. autoSound sound1 = Matrix_to_Sound (me), sound2 = Matrix_to_Sound (you);
  446. autoParamCurve result = ParamCurve_create (sound1.get(), sound2.get());
  447. CONVERT_COUPLE_END (my name.get(), U"_", your name.get());
  448. }
  449. // MARK: - PHOTO
  450. // MARK: New
  451. FORM (NEW1_Photo_create, U"Create Photo", U"Create Photo...") {
  452. WORD (name, U"Name", U"xy")
  453. REAL (xmin, U"xmin", U"1.0")
  454. REAL (xmax, U"xmax", U"1.0")
  455. NATURAL (numberOfColumns, U"Number of columns", U"1")
  456. POSITIVE (dx, U"dx", U"1.0")
  457. REAL (x1, U"x1", U"1.0")
  458. REAL (ymin, U"ymin", U"1.0")
  459. REAL (ymax, U"ymax", U"1.0")
  460. NATURAL (numberOfRows, U"Number of rows", U"1")
  461. POSITIVE (dy, U"dy", U"1.0")
  462. REAL (y1, U"y1", U"1.0")
  463. TEXTFIELD (redFormula, U"Red formula:", U"x*y/100")
  464. TEXTFIELD (greenFormula, U"Green formula:", U"x*y/1000")
  465. TEXTFIELD (blueFormula, U"Blue formula:", U"x*y/100")
  466. OK
  467. DO
  468. if (xmax < xmin)
  469. Melder_throw (U"Your xmax (", Melder_single (xmax), U") should not be less than your xmin (", Melder_single (xmin), U").");
  470. if (ymax < ymin)
  471. Melder_throw (U"Your ymax (", Melder_single (ymax), U") should not be less than your ymin (", Melder_single (ymin), U").");
  472. CREATE_ONE
  473. autoPhoto result = Photo_create (
  474. xmin, xmax, numberOfColumns, dx, x1,
  475. ymin, ymax, numberOfRows, dy, y1);
  476. Matrix_formula (result -> d_red .get(), redFormula, interpreter, nullptr);
  477. Matrix_formula (result -> d_green.get(), greenFormula, interpreter, nullptr);
  478. Matrix_formula (result -> d_blue .get(), blueFormula, interpreter, nullptr);
  479. CREATE_ONE_END (name)
  480. }
  481. FORM (NEW1_Photo_createSimple, U"Create simple Photo", U"Create simple Photo...") {
  482. WORD (name, U"Name", U"xy")
  483. NATURAL (numberOfRows, U"Number of rows", U"10")
  484. NATURAL (numberOfColumns, U"Number of columns", U"10")
  485. TEXTFIELD (redFormula, U"Red formula:", U"x*y/100")
  486. TEXTFIELD (greenFormula, U"Green formula:", U"x*y/1000")
  487. TEXTFIELD (blueFormula, U"Blue formula:", U"x*y/100")
  488. OK
  489. DO
  490. CREATE_ONE
  491. autoPhoto result = Photo_createSimple (numberOfRows, numberOfColumns);
  492. Matrix_formula (result -> d_red.get(), redFormula, interpreter, nullptr);
  493. Matrix_formula (result -> d_green.get(), greenFormula, interpreter, nullptr);
  494. Matrix_formula (result -> d_blue.get(), blueFormula, interpreter, nullptr);
  495. CREATE_ONE_END (name)
  496. }
  497. DIRECT (NEW_Photo_extractBlue) {
  498. CONVERT_EACH (Photo)
  499. autoMatrix result = Data_copy (my d_blue.get());
  500. CONVERT_EACH_END (my name.get(), U"_blue");
  501. }
  502. DIRECT (NEW_Photo_extractGreen) {
  503. CONVERT_EACH (Photo)
  504. autoMatrix result = Data_copy (my d_green.get());
  505. CONVERT_EACH_END (my name.get(), U"_green");
  506. }
  507. DIRECT (NEW_Photo_extractRed) {
  508. CONVERT_EACH (Photo)
  509. autoMatrix result = Data_copy (my d_red.get());
  510. CONVERT_EACH_END (my name.get(), U"_red");
  511. }
  512. DIRECT (NEW_Photo_extractTransparency) {
  513. CONVERT_EACH (Photo)
  514. autoMatrix result = Data_copy (my d_transparency.get());
  515. CONVERT_EACH_END (my name.get(), U"_transparency");
  516. }
  517. FORM (MODIFY_Photo_formula_red, U"Photo Formula (red)", U"Formula (red)...") {
  518. LABEL (U"y := y1; for row := 1 to nrow do { x := x1; "
  519. "for col := 1 to ncol do { self [row, col] := `formula` ; x := x + dx } y := y + dy }")
  520. TEXTFIELD (formula, U"Formula:", U"self")
  521. OK
  522. DO
  523. MODIFY_EACH_WEAK (Photo)
  524. Matrix_formula (my d_red.get(), formula, interpreter, nullptr);
  525. MODIFY_EACH_WEAK_END
  526. }
  527. FORM (MODIFY_Photo_formula_green, U"Photo Formula (green)", U"Formula (green)...") {
  528. LABEL (U"y := y1; for row := 1 to nrow do { x := x1; "
  529. "for col := 1 to ncol do { self [row, col] := `formula` ; x := x + dx } y := y + dy }")
  530. TEXTFIELD (formula, U"Formula:", U"self")
  531. OK
  532. DO
  533. MODIFY_EACH_WEAK (Photo)
  534. Matrix_formula (my d_green.get(), formula, interpreter, nullptr);
  535. MODIFY_EACH_WEAK_END
  536. }
  537. FORM (MODIFY_Photo_formula_blue, U"Photo Formula (blue)", U"Formula (blue)...") {
  538. LABEL (U"y := y1; for row := 1 to nrow do { x := x1; "
  539. "for col := 1 to ncol do { self [row, col] := `formula` ; x := x + dx } y := y + dy }")
  540. TEXTFIELD (formula, U"Formula:", U"self")
  541. OK
  542. DO
  543. MODIFY_EACH_WEAK (Photo)
  544. Matrix_formula (my d_blue.get(), formula, interpreter, nullptr);
  545. MODIFY_EACH_WEAK_END
  546. }
  547. FORM (MODIFY_Photo_formula_transparency, U"Photo Formula (transparency)", U"Formula (transparency)...") {
  548. LABEL (U"y := y1; for row := 1 to nrow do { x := x1; "
  549. "for col := 1 to ncol do { self [row, col] := `formula` ; x := x + dx } y := y + dy }")
  550. TEXTFIELD (formula, U"Formula:", U"self")
  551. OK
  552. DO
  553. MODIFY_EACH_WEAK (Photo)
  554. Matrix_formula (my d_transparency.get(), formula, interpreter, nullptr);
  555. MODIFY_EACH_WEAK_END
  556. }
  557. FORM (GRAPHICS_Photo_paintCells, U"Photo: Paint cells with colour", U"Photo: Paint cells...") {
  558. REAL (fromX, U"From x =", U"0.0")
  559. REAL (toX, U"To x =", U"0.0")
  560. REAL (fromY, U"From y =", U"0.0")
  561. REAL (toY, U"To y =", U"0.0")
  562. OK
  563. DO
  564. GRAPHICS_EACH (Photo)
  565. Photo_paintCells (me, GRAPHICS, fromX, toX, fromY, toY);
  566. GRAPHICS_EACH_END
  567. }
  568. FORM (GRAPHICS_Photo_paintImage, U"Photo: Paint colour image", nullptr) {
  569. REAL (fromX, U"From x =", U"0.0")
  570. REAL (toX, U"To x =", U"0.0")
  571. REAL (fromY, U"From y =", U"0.0")
  572. REAL (toY, U"To y =", U"0.0")
  573. OK
  574. DO
  575. GRAPHICS_EACH (Photo)
  576. Photo_paintImage (me, GRAPHICS, fromX, toX, fromY, toY);
  577. GRAPHICS_EACH_END
  578. }
  579. FORM_SAVE (SAVE_Photo_saveAsAppleIconFile, U"Save as Apple icon file", nullptr, U"icns") {
  580. SAVE_ONE (Photo)
  581. Photo_saveAsAppleIconFile (me, file);
  582. SAVE_ONE_END
  583. }
  584. FORM_SAVE (SAVE_Photo_saveAsGIF, U"Save as GIF file", nullptr, U"gif") {
  585. SAVE_ONE (Photo)
  586. Photo_saveAsGIF (me, file);
  587. SAVE_ONE_END
  588. }
  589. FORM_SAVE (SAVE_Photo_saveAsJPEG, U"Save as JPEG file", nullptr, U"jpg") {
  590. SAVE_ONE (Photo)
  591. Photo_saveAsJPEG (me, file);
  592. SAVE_ONE_END
  593. }
  594. FORM_SAVE (SAVE_Photo_saveAsJPEG2000, U"Save as JPEG-2000 file", nullptr, U"jpg") {
  595. SAVE_ONE (Photo)
  596. Photo_saveAsJPEG2000 (me, file);
  597. SAVE_ONE_END
  598. }
  599. FORM_SAVE (SAVE_Photo_saveAsPNG, U"Save as PNG file", nullptr, U"png") {
  600. SAVE_ONE (Photo)
  601. Photo_saveAsPNG (me, file);
  602. SAVE_ONE_END
  603. }
  604. FORM_SAVE (SAVE_Photo_saveAsTIFF, U"Save as TIFF file", nullptr, U"tiff") {
  605. SAVE_ONE (Photo)
  606. Photo_saveAsTIFF (me, file);
  607. SAVE_ONE_END
  608. }
  609. FORM_SAVE (SAVE_Photo_saveAsWindowsBitmapFile, U"Save as Windows bitmap file", nullptr, U"bmp") {
  610. SAVE_ONE (Photo)
  611. Photo_saveAsWindowsBitmapFile (me, file);
  612. SAVE_ONE_END
  613. }
  614. FORM_SAVE (SAVE_Photo_saveAsWindowsIconFile, U"Save as Windows icon file", nullptr, U"ico") {
  615. SAVE_ONE (Photo)
  616. Photo_saveAsWindowsIconFile (me, file);
  617. SAVE_ONE_END
  618. }
  619. // MARK: - PHOTO & MATRIX
  620. DIRECT (MODIFY_Photo_Matrix_replaceBlue) {
  621. MODIFY_FIRST_OF_TWO (Photo, Matrix)
  622. Photo_replaceBlue (me, you);
  623. MODIFY_FIRST_OF_TWO_END
  624. }
  625. DIRECT (MODIFY_Photo_Matrix_replaceGreen) {
  626. MODIFY_FIRST_OF_TWO (Photo, Matrix)
  627. Photo_replaceGreen (me, you);
  628. MODIFY_FIRST_OF_TWO_END
  629. }
  630. DIRECT (MODIFY_Photo_Matrix_replaceRed) {
  631. MODIFY_FIRST_OF_TWO (Photo, Matrix)
  632. Photo_replaceRed (me, you);
  633. MODIFY_FIRST_OF_TWO_END
  634. }
  635. DIRECT (MODIFY_Photo_Matrix_replaceTransparency) {
  636. MODIFY_FIRST_OF_TWO (Photo, Matrix)
  637. Photo_replaceTransparency (me, you);
  638. MODIFY_FIRST_OF_TWO_END
  639. }
  640. // MARK: - MOVIE
  641. FORM_READ (READ1_Movie_openFromSoundFile, U"Open movie file", nullptr, true) {
  642. READ_ONE
  643. autoMovie result = Movie_openFromSoundFile (file);
  644. READ_ONE_END // but loses data when saving, if object is associated only with the sound file
  645. }
  646. FORM (GRAPHICS_Movie_paintOneImage, U"Movie: Paint one image", nullptr) {
  647. NATURAL (frameNumber, U"Frame number", U"1")
  648. REAL (fromX, U"From x =", U"0.0")
  649. REAL (toX, U"To x =", U"1.0")
  650. REAL (fromY, U"From y =", U"0.0")
  651. REAL (toY, U"To y =", U"1.0")
  652. OK
  653. DO
  654. GRAPHICS_EACH (Movie)
  655. Movie_paintOneImage (me, GRAPHICS, frameNumber, fromX, toX, fromY, toY);
  656. GRAPHICS_EACH_END
  657. }
  658. DIRECT (WINDOW_Movie_viewAndEdit) {
  659. if (theCurrentPraatApplication -> batch) Melder_throw (U"Cannot view or edit a Movie from batch.");
  660. FIND_ONE_WITH_IOBJECT (Movie)
  661. autoMovieWindow editor = MovieWindow_create (ID_AND_FULL_NAME, me);
  662. praat_installEditor (editor.get(), IOBJECT);
  663. editor.releaseToUser();
  664. END
  665. }
  666. // MARK: file recognizers
  667. static autoDaata imageFileRecognizer (integer /* nread */, const char * /* header */, MelderFile file) {
  668. conststring32 fileName = MelderFile_name (file);
  669. if (Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".jpg", false) ||
  670. Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".jpeg", false) ||
  671. Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".png", false) ||
  672. Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".tiff", false) ||
  673. Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".tif", false))
  674. {
  675. return Photo_readFromImageFile (file);
  676. }
  677. return autoDaata ();
  678. }
  679. // MARK: - buttons
  680. void praat_Matrix_init () {
  681. Thing_recognizeClassesByName (classMatrix, classPhoto, classMovie, nullptr);
  682. Data_recognizeFileType (imageFileRecognizer);
  683. praat_addMenuCommand (U"Objects", U"New", U"Matrix", nullptr, 0, nullptr);
  684. praat_addMenuCommand (U"Objects", U"New", U"Create Matrix...", nullptr, 1, NEW1_Matrix_create);
  685. praat_addMenuCommand (U"Objects", U"New", U"Create simple Matrix...", nullptr, 1, NEW1_Matrix_createSimple);
  686. praat_addMenuCommand (U"Objects", U"New", U"-- colour matrix --", nullptr, 1, nullptr);
  687. praat_addMenuCommand (U"Objects", U"New", U"Create Photo...", nullptr, 1, NEW1_Photo_create);
  688. praat_addMenuCommand (U"Objects", U"New", U"Create simple Photo...", nullptr, 1, NEW1_Photo_createSimple);
  689. praat_addMenuCommand (U"Objects", U"Open", U"-- read movie --", nullptr, praat_HIDDEN, nullptr);
  690. praat_addMenuCommand (U"Objects", U"Open", U"Open movie file...", nullptr, praat_HIDDEN, READ1_Movie_openFromSoundFile);
  691. praat_addMenuCommand (U"Objects", U"Open", U"-- read raw --", nullptr, 0, nullptr);
  692. praat_addMenuCommand (U"Objects", U"Open", U"Read Matrix from raw text file...", nullptr, 0, READ1_Matrix_readFromRawTextFile);
  693. praat_addMenuCommand (U"Objects", U"Open", U"Read Matrix from LVS AP file...", nullptr, praat_HIDDEN, READ1_Matrix_readAP);
  694. praat_addAction1 (classMatrix, 0, U"Matrix help", nullptr, 0, HELP_Matrix_help);
  695. praat_addAction1 (classMatrix, 1, U"Save as matrix text file...", nullptr, 0, SAVE_Matrix_writeToMatrixTextFile);
  696. praat_addAction1 (classMatrix, 1, U"Write to matrix text file...", U"*Save as matrix text file...", praat_DEPRECATED_2011, SAVE_Matrix_writeToMatrixTextFile);
  697. praat_addAction1 (classMatrix, 1, U"Save as headerless spreadsheet file...", nullptr, 0, SAVE_Matrix_writeToHeaderlessSpreadsheetFile);
  698. praat_addAction1 (classMatrix, 1, U"Write to headerless spreadsheet file...", nullptr, praat_DEPRECATED_2011, SAVE_Matrix_writeToHeaderlessSpreadsheetFile);
  699. praat_addAction1 (classMatrix, 1, U"Play movie", nullptr, 0, MOVIE_Matrix_movie);
  700. praat_addAction1 (classMatrix, 0, U"Draw -", nullptr, 0, nullptr);
  701. praat_addAction1 (classMatrix, 0, U"Draw rows...", nullptr, 1, GRAPHICS_Matrix_drawRows);
  702. praat_addAction1 (classMatrix, 0, U"Draw one contour...", nullptr, 1, GRAPHICS_Matrix_drawOneContour);
  703. praat_addAction1 (classMatrix, 0, U"Draw contours...", nullptr, 1, GRAPHICS_Matrix_drawContours);
  704. praat_addAction1 (classMatrix, 0, U"Paint image...", nullptr, 1, GRAPHICS_Matrix_paintImage);
  705. praat_addAction1 (classMatrix, 0, U"Paint contours...", nullptr, 1, GRAPHICS_Matrix_paintContours);
  706. praat_addAction1 (classMatrix, 0, U"Paint cells...", nullptr, 1, GRAPHICS_Matrix_paintCells);
  707. praat_addAction1 (classMatrix, 0, U"Paint surface...", nullptr, 1, GRAPHICS_Matrix_paintSurface);
  708. praat_addAction1 (classMatrix, 1, U"Query -", nullptr, 0, nullptr);
  709. praat_addAction1 (classMatrix, 1, U"Get lowest x", nullptr, 1, REAL_Matrix_getLowestX);
  710. praat_addAction1 (classMatrix, 1, U"Get highest x", nullptr, 1, REAL_Matrix_getHighestX);
  711. praat_addAction1 (classMatrix, 1, U"Get lowest y", nullptr, 1, REAL_Matrix_getLowestY);
  712. praat_addAction1 (classMatrix, 1, U"Get highest y", nullptr, 1, REAL_Matrix_getHighestY);
  713. praat_addAction1 (classMatrix, 1, U"-- get structure --", nullptr, 1, nullptr);
  714. praat_addAction1 (classMatrix, 1, U"Get number of rows", nullptr, 1, INTEGER_Matrix_getNumberOfRows);
  715. praat_addAction1 (classMatrix, 1, U"Get number of columns", nullptr, 1, INTEGER_Matrix_getNumberOfColumns);
  716. praat_addAction1 (classMatrix, 1, U"Get row distance", nullptr, 1, REAL_Matrix_getRowDistance);
  717. praat_addAction1 (classMatrix, 1, U"Get column distance", nullptr, 1, REAL_Matrix_getColumnDistance);
  718. praat_addAction1 (classMatrix, 1, U"Get y of row...", nullptr, 1, REAL_Matrix_getYofRow);
  719. praat_addAction1 (classMatrix, 1, U"Get x of column...", nullptr, 1, REAL_Matrix_getXofColumn);
  720. praat_addAction1 (classMatrix, 1, U"-- get value --", nullptr, 1, nullptr);
  721. praat_addAction1 (classMatrix, 1, U"Get value in cell...", nullptr, 1, REAL_Matrix_getValueInCell);
  722. praat_addAction1 (classMatrix, 1, U"Get value at xy...", nullptr, 1, REAL_Matrix_getValueAtXY);
  723. praat_addAction1 (classMatrix, 1, U"Get minimum", nullptr, 1, REAL_Matrix_getMinimum);
  724. praat_addAction1 (classMatrix, 1, U"Get maximum", nullptr, 1, REAL_Matrix_getMaximum);
  725. praat_addAction1 (classMatrix, 1, U"Get sum", nullptr, 1, REAL_Matrix_getSum);
  726. praat_addAction1 (classMatrix, 0, U"Modify -", nullptr, 0, nullptr);
  727. praat_addAction1 (classMatrix, 0, U"Formula...", nullptr, 1, MODIFY_Matrix_formula);
  728. praat_addAction1 (classMatrix, 0, U"Set value...", nullptr, 1, MODIFY_Matrix_setValue);
  729. praat_addAction1 (classMatrix, 0, U"Analyse", nullptr, 0, nullptr);
  730. praat_addAction1 (classMatrix, 0, U"Eigen", nullptr, 0, NEWTIMES2_Matrix_eigen);
  731. praat_addAction1 (classMatrix, 0, U"Synthesize", nullptr, 0, nullptr);
  732. praat_addAction1 (classMatrix, 0, U"Power...", nullptr, 0, NEW_Matrix_power);
  733. praat_addAction1 (classMatrix, 0, U"Combine two Matrices -", nullptr, 0, nullptr);
  734. praat_addAction1 (classMatrix, 2, U"Merge (append rows)", nullptr, 1, NEW1_Matrix_appendRows);
  735. praat_addAction1 (classMatrix, 2, U"To ParamCurve", nullptr, 1, NEW1_Matrix_to_ParamCurve);
  736. praat_addAction1 (classMatrix, 0, U"Cast -", nullptr, 0, nullptr);
  737. praat_addAction1 (classMatrix, 0, U"To Cochleagram", nullptr, 1, NEW_Matrix_to_Cochleagram);
  738. praat_addAction1 (classMatrix, 0, U"To Excitation", nullptr, 1, NEW_Matrix_to_Excitation);
  739. praat_addAction1 (classMatrix, 0, U"To Harmonicity", nullptr, 1, NEW_Matrix_to_Harmonicity);
  740. praat_addAction1 (classMatrix, 0, U"To Intensity", nullptr, 1, NEW_Matrix_to_Intensity);
  741. praat_addAction1 (classMatrix, 0, U"To Ltas", nullptr, 1, NEW_Matrix_to_Ltas);
  742. praat_addAction1 (classMatrix, 0, U"To Pitch", nullptr, 1, NEW_Matrix_to_Pitch);
  743. praat_addAction1 (classMatrix, 0, U"To PointProcess", nullptr, 1, NEW_Matrix_to_PointProcess);
  744. praat_addAction1 (classMatrix, 0, U"To Polygon", nullptr, 1, NEW_Matrix_to_Polygon);
  745. praat_addAction1 (classMatrix, 0, U"To Sound", nullptr, 1, NEW_Matrix_to_Sound);
  746. praat_addAction1 (classMatrix, 0, U"To Sound (slice)...", nullptr, 1, NEW_Matrix_to_Sound_mono);
  747. praat_addAction1 (classMatrix, 0, U"To Spectrogram", nullptr, 1, NEW_Matrix_to_Spectrogram);
  748. praat_addAction1 (classMatrix, 0, U"To TableOfReal", nullptr, 1, NEW_Matrix_to_TableOfReal);
  749. praat_addAction1 (classMatrix, 0, U"To Spectrum", nullptr, 1, NEW_Matrix_to_Spectrum);
  750. praat_addAction1 (classMatrix, 0, U"To Transition", nullptr, 1, NEW_Matrix_to_Transition);
  751. praat_addAction1 (classMatrix, 0, U"To VocalTract", nullptr, 1, NEW_Matrix_to_VocalTract);
  752. praat_addAction1 (classPhoto, 0, U"Draw -", nullptr, 0, nullptr);
  753. praat_addAction1 (classPhoto, 0, U"Paint image...", nullptr, 1, GRAPHICS_Photo_paintImage);
  754. praat_addAction1 (classPhoto, 0, U"Paint cells...", nullptr, 1, GRAPHICS_Photo_paintCells);
  755. praat_addAction1 (classPhoto, 0, U"Modify -", nullptr, 0, nullptr);
  756. praat_addAction1 (classPhoto, 0, U"Formula (red)...", nullptr, 1, MODIFY_Photo_formula_red);
  757. praat_addAction1 (classPhoto, 0, U"Formula (green)...", nullptr, 1, MODIFY_Photo_formula_green);
  758. praat_addAction1 (classPhoto, 0, U"Formula (blue)...", nullptr, 1, MODIFY_Photo_formula_blue);
  759. praat_addAction1 (classPhoto, 0, U"Formula (transparency)...", nullptr, 1, MODIFY_Photo_formula_transparency);
  760. praat_addAction1 (classPhoto, 0, U"Extract -", nullptr, 0, nullptr);
  761. praat_addAction1 (classPhoto, 0, U"Extract red", nullptr, 1, NEW_Photo_extractRed);
  762. praat_addAction1 (classPhoto, 0, U"Extract green", nullptr, 1, NEW_Photo_extractGreen);
  763. praat_addAction1 (classPhoto, 0, U"Extract blue", nullptr, 1, NEW_Photo_extractBlue);
  764. praat_addAction1 (classPhoto, 0, U"Extract transparency", nullptr, 1, NEW_Photo_extractTransparency);
  765. praat_addAction1 (classPhoto, 1, U"Save as PNG file...", nullptr, 0, SAVE_Photo_saveAsPNG);
  766. #if defined (macintosh) || defined (_WIN32)
  767. praat_addAction1 (classPhoto, 1, U"Save as TIFF file...", nullptr, 0, SAVE_Photo_saveAsTIFF);
  768. praat_addAction1 (classPhoto, 1, U"Save as GIF file...", nullptr, 0, SAVE_Photo_saveAsGIF);
  769. praat_addAction1 (classPhoto, 1, U"Save as Windows bitmap file...", nullptr, 0, SAVE_Photo_saveAsWindowsBitmapFile);
  770. praat_addAction1 (classPhoto, 1, U"Save as lossy JPEG file...", nullptr, 0, SAVE_Photo_saveAsJPEG);
  771. #endif
  772. #if defined (macintosh)
  773. praat_addAction1 (classPhoto, 1, U"Save as JPEG-2000 file...", nullptr, 0, SAVE_Photo_saveAsJPEG2000);
  774. praat_addAction1 (classPhoto, 1, U"Save as Apple icon file...", nullptr, 0, SAVE_Photo_saveAsAppleIconFile);
  775. praat_addAction1 (classPhoto, 1, U"Save as Windows icon file...", nullptr, 0, SAVE_Photo_saveAsWindowsIconFile);
  776. #endif
  777. praat_addAction1 (classMovie, 1, U"Paint one image...", nullptr, 1, GRAPHICS_Movie_paintOneImage);
  778. praat_addAction1 (classMovie, 1, U"View & Edit", nullptr, praat_ATTRACTIVE, WINDOW_Movie_viewAndEdit);
  779. praat_addAction2 (classMatrix, 1, classSound, 1, U"To ParamCurve", nullptr, 0, NEW1_Matrix_to_ParamCurve);
  780. praat_addAction2 (classPhoto, 1, classMatrix, 1, U"Replace red", nullptr, 0, MODIFY_Photo_Matrix_replaceRed);
  781. praat_addAction2 (classPhoto, 1, classMatrix, 1, U"Replace green", nullptr, 0, MODIFY_Photo_Matrix_replaceGreen);
  782. praat_addAction2 (classPhoto, 1, classMatrix, 1, U"Replace blue", nullptr, 0, MODIFY_Photo_Matrix_replaceBlue);
  783. praat_addAction2 (classPhoto, 1, classMatrix, 1, U"Replace transparency", nullptr, 0, MODIFY_Photo_Matrix_replaceTransparency);
  784. }
  785. /* End of file praat_Matrix.cpp */