praat_Sound.cpp 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415
  1. /* praat_Sound_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 "Ltas.h"
  19. #include "LongSound.h"
  20. #include "Manipulation.h"
  21. #include "ParamCurve.h"
  22. #include "Sound_and_Spectrogram.h"
  23. #include "Sound_and_Spectrum.h"
  24. #include "Sound_extensions.h"
  25. #include "Sound_to_Cochleagram.h"
  26. #include "Sound_to_Formant.h"
  27. #include "Sound_to_Harmonicity.h"
  28. #include "Sound_to_Intensity.h"
  29. #include "Sound_to_Pitch.h"
  30. #include "Sound_to_PointProcess.h"
  31. #include "SoundEditor.h"
  32. #include "SoundRecorder.h"
  33. #include "SpectrumEditor.h"
  34. #include "TextGrid_Sound.h"
  35. #include "mp3.h"
  36. #include "praat_Sound.h"
  37. #undef iam
  38. #define iam iam_LOOP
  39. /***** LONGSOUND *****/
  40. DIRECT (INFO_LongSound_concatenate) {
  41. INFO_NONE
  42. Melder_information (U"To concatenate LongSound objects, select them in the list\nand choose \"Save as WAV file...\" or a similar command.\n"
  43. "The result will be a sound file that contains\nthe concatenation of the selected sounds.");
  44. INFO_NONE_END
  45. }
  46. FORM (NEW_LongSound_extractPart, U"LongSound: Extract part", nullptr) {
  47. REAL (fromTime, U"left Time range (s)", U"0.0")
  48. REAL (toTime, U"right Time range (s)", U"1.0")
  49. BOOLEAN (preserveTimes, U"Preserve times", true)
  50. OK
  51. DO
  52. CONVERT_EACH (LongSound)
  53. autoSound result = LongSound_extractPart (me, fromTime, toTime, preserveTimes);
  54. CONVERT_EACH_END (my name.get())
  55. }
  56. FORM (REAL_LongSound_getIndexFromTime, U"LongSound: Get sample index from time", U"Sound: Get index from time...") {
  57. REAL (time, U"Time (s)", U"0.5")
  58. OK
  59. DO
  60. NUMBER_ONE (LongSound)
  61. double result = Sampled_xToIndex (me, time);
  62. NUMBER_ONE_END (U" (index at ", time, U" seconds)")
  63. }
  64. DIRECT (REAL_LongSound_getSamplePeriod) {
  65. NUMBER_ONE (LongSound)
  66. double result = my dx;
  67. NUMBER_ONE_END (U" seconds");
  68. }
  69. DIRECT (REAL_LongSound_getSampleRate) {
  70. NUMBER_ONE (LongSound)
  71. double result = 1.0 / my dx;
  72. NUMBER_ONE_END (U" Hz")
  73. }
  74. FORM (REAL_LongSound_getTimeFromIndex, U"LongSound: Get time from sample index", U"Sound: Get time from index...") {
  75. INTEGER (sampleIndex, U"Sample index", U"100")
  76. OK
  77. DO
  78. NUMBER_ONE (LongSound)
  79. double result = Sampled_indexToX (me, sampleIndex);
  80. NUMBER_ONE_END (U" seconds")
  81. }
  82. DIRECT (INTEGER_LongSound_getNumberOfSamples) {
  83. NUMBER_ONE (LongSound)
  84. integer result = my nx;
  85. NUMBER_ONE_END (U" samples")
  86. }
  87. DIRECT (HELP_LongSound_help) {
  88. HELP (U"LongSound")
  89. }
  90. FORM_READ (READ1_LongSound_open, U"Open long sound file", nullptr, true) {
  91. READ_ONE
  92. autoLongSound result = LongSound_open (file);
  93. READ_ONE_END
  94. }
  95. FORM (PLAY_LongSound_playPart, U"LongSound: Play part", nullptr) {
  96. REAL (fromTime, U"left Time range (s)", U"0.0")
  97. REAL (toTime, U"right Time range (s)", U"10.0")
  98. OK
  99. DO
  100. int n = 0;
  101. LOOP n ++;
  102. if (n == 1 || MelderAudio_getOutputMaximumAsynchronicity () < kMelder_asynchronicityLevel::ASYNCHRONOUS) {
  103. LOOP {
  104. iam (LongSound);
  105. LongSound_playPart (me, fromTime, toTime, nullptr, nullptr);
  106. }
  107. } else {
  108. MelderAudio_setOutputMaximumAsynchronicity (kMelder_asynchronicityLevel::INTERRUPTABLE);
  109. LOOP {
  110. iam (LongSound);
  111. LongSound_playPart (me, fromTime, toTime, nullptr, nullptr);
  112. }
  113. MelderAudio_setOutputMaximumAsynchronicity (kMelder_asynchronicityLevel::ASYNCHRONOUS);
  114. }
  115. END }
  116. FORM (SAVE_LongSound_savePartAsAudioFile, U"LongSound: Save part as audio file", nullptr) {
  117. TEXTFIELD (audioFile, U"Audio file:", U"")
  118. RADIO (type, U"Type", 3)
  119. { int i; for (i = 1; i <= Melder_NUMBER_OF_AUDIO_FILE_TYPES; i ++) {
  120. RADIOBUTTON (Melder_audioFileTypeString (i))
  121. }}
  122. REAL (fromTime, U"left Time range (s)", U"0.0")
  123. REAL (toTime, U"right Time range (s)", U"10.0")
  124. OK
  125. DO
  126. SAVE_ONE (LongSound)
  127. structMelderFile file { };
  128. Melder_relativePathToFile (audioFile, & file);
  129. LongSound_savePartAsAudioFile (me, type, fromTime, toTime, & file, 16);
  130. SAVE_ONE_END
  131. }
  132. FORM (NEW_LongSound_to_TextGrid, U"LongSound: To TextGrid...", U"LongSound: To TextGrid...") {
  133. SENTENCE (tierNames, U"Tier names", U"Mary John bell")
  134. SENTENCE (pointTiers, U"Point tiers", U"bell")
  135. OK
  136. DO
  137. CONVERT_EACH (LongSound)
  138. autoTextGrid result = TextGrid_create (my xmin, my xmax, tierNames, pointTiers);
  139. CONVERT_EACH_END (my name.get())
  140. }
  141. DIRECT (WINDOW_LongSound_view) {
  142. if (theCurrentPraatApplication -> batch) Melder_throw (U"Cannot view or edit a LongSound from batch.");
  143. FIND_ONE_WITH_IOBJECT (LongSound)
  144. autoSoundEditor editor = SoundEditor_create (ID_AND_FULL_NAME, me);
  145. praat_installEditor (editor.get(), IOBJECT);
  146. editor.releaseToUser();
  147. END
  148. }
  149. FORM_SAVE (SAVE_LongSound_saveAsAifcFile, U"Save as AIFC file", nullptr, U"aifc") {
  150. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  151. LongSound_concatenate (list.get(), file, Melder_AIFC, 16);
  152. SAVE_TYPED_LIST_END
  153. }
  154. FORM_SAVE (SAVE_LongSound_saveAsAiffFile, U"Save as AIFF file", nullptr, U"aiff") {
  155. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  156. LongSound_concatenate (list.get(), file, Melder_AIFF, 16);
  157. SAVE_TYPED_LIST_END
  158. }
  159. FORM_SAVE (SAVE_LongSound_saveAsNextSunFile, U"Save as NeXT/Sun file", nullptr, U"au") {
  160. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  161. LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16);
  162. SAVE_TYPED_LIST_END
  163. }
  164. FORM_SAVE (SAVE_LongSound_saveAsNistFile, U"Save as NIST file", nullptr, U"nist") {
  165. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  166. LongSound_concatenate (list.get(), file, Melder_NIST, 16);
  167. SAVE_TYPED_LIST_END
  168. }
  169. FORM_SAVE (SAVE_LongSound_saveAsFlacFile, U"Save as FLAC file", nullptr, U"flac") {
  170. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  171. LongSound_concatenate (list.get(), file, Melder_FLAC, 16);
  172. SAVE_TYPED_LIST_END
  173. }
  174. FORM_SAVE (SAVE_LongSound_saveAsWavFile, U"Save as WAV file", nullptr, U"wav") {
  175. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  176. LongSound_concatenate (list.get(), file, Melder_WAV, 16);
  177. SAVE_TYPED_LIST_END
  178. }
  179. FORM_SAVE (SAVE_LongSound_saveLeftChannelAsAifcFile, U"Save left channel as AIFC file", nullptr, U"aifc") {
  180. SAVE_ONE (LongSound)
  181. LongSound_saveChannelAsAudioFile (me, Melder_AIFC, 0, file);
  182. SAVE_ONE_END
  183. }
  184. FORM_SAVE (SAVE_LongSound_saveLeftChannelAsAiffFile, U"Save left channel as AIFF file", nullptr, U"aiff") {
  185. SAVE_ONE (LongSound)
  186. LongSound_saveChannelAsAudioFile (me, Melder_AIFF, 0, file);
  187. SAVE_ONE_END
  188. }
  189. FORM_SAVE (SAVE_LongSound_saveLeftChannelAsNextSunFile, U"Save left channel as NeXT/Sun file", nullptr, U"au") {
  190. SAVE_ONE (LongSound)
  191. LongSound_saveChannelAsAudioFile (me, Melder_NEXT_SUN, 0, file);
  192. SAVE_ONE_END
  193. }
  194. FORM_SAVE (SAVE_LongSound_saveLeftChannelAsNistFile, U"Save left channel as NIST file", nullptr, U"nist") {
  195. SAVE_ONE (LongSound)
  196. LongSound_saveChannelAsAudioFile (me, Melder_NIST, 0, file);
  197. SAVE_ONE_END
  198. }
  199. FORM_SAVE (SAVE_LongSound_saveLeftChannelAsFlacFile, U"Save left channel as FLAC file", nullptr, U"flac") {
  200. SAVE_ONE (LongSound)
  201. LongSound_saveChannelAsAudioFile (me, Melder_FLAC, 0, file);
  202. SAVE_ONE_END
  203. }
  204. FORM_SAVE (SAVE_LongSound_saveLeftChannelAsWavFile, U"Save left channel as WAV file", nullptr, U"wav") {
  205. SAVE_ONE (LongSound)
  206. LongSound_saveChannelAsAudioFile (me, Melder_WAV, 0, file);
  207. SAVE_ONE_END
  208. }
  209. FORM_SAVE (SAVE_LongSound_saveRightChannelAsAifcFile, U"Save right channel as AIFC file", nullptr, U"aifc") {
  210. SAVE_ONE (LongSound)
  211. LongSound_saveChannelAsAudioFile (me, Melder_AIFC, 1, file);
  212. SAVE_ONE_END
  213. }
  214. FORM_SAVE (SAVE_LongSound_saveRightChannelAsAiffFile, U"Save right channel as AIFF file", nullptr, U"aiff") {
  215. SAVE_ONE (LongSound)
  216. LongSound_saveChannelAsAudioFile (me, Melder_AIFF, 1, file);
  217. SAVE_ONE_END
  218. }
  219. FORM_SAVE (SAVE_LongSound_saveRightChannelAsNextSunFile, U"Save right channel as NeXT/Sun file", nullptr, U"au") {
  220. SAVE_ONE (LongSound)
  221. LongSound_saveChannelAsAudioFile (me, Melder_NEXT_SUN, 1, file);
  222. SAVE_ONE_END
  223. }
  224. FORM_SAVE (SAVE_LongSound_saveRightChannelAsNistFile, U"Save right channel as NIST file", nullptr, U"nist") {
  225. SAVE_ONE (LongSound)
  226. LongSound_saveChannelAsAudioFile (me, Melder_NIST, 1, file);
  227. SAVE_ONE_END
  228. }
  229. FORM_SAVE (SAVE_LongSound_saveRightChannelAsFlacFile, U"Save right channel as FLAC file", 0, U"flac") {
  230. SAVE_ONE (LongSound)
  231. LongSound_saveChannelAsAudioFile (me, Melder_FLAC, 1, file);
  232. SAVE_ONE_END
  233. }
  234. FORM_SAVE (SAVE_LongSound_saveRightChannelAsWavFile, U"Save right channel as WAV file", 0, U"wav") {
  235. SAVE_ONE (LongSound)
  236. LongSound_saveChannelAsAudioFile (me, Melder_WAV, 1, file);
  237. SAVE_ONE_END
  238. }
  239. FORM (PREFS_LongSoundPrefs, U"LongSound preferences", U"LongSound") {
  240. LABEL (U"This setting determines the maximum number of seconds")
  241. LABEL (U"for viewing the waveform and playing a sound in the LongSound window.")
  242. LABEL (U"The LongSound window can become very slow if you set it too high.")
  243. NATURAL (maximumViewablePart, U"Maximum viewable part (seconds)", U"60")
  244. LABEL (U"Note: this setting works for the next long sound file that you open,")
  245. LABEL (U"not for currently existing LongSound objects.")
  246. OK
  247. SET_INTEGER (maximumViewablePart, LongSound_getBufferSizePref_seconds ())
  248. DO
  249. LongSound_setBufferSizePref_seconds (maximumViewablePart);
  250. END }
  251. /********** LONGSOUND & SOUND **********/
  252. FORM_SAVE (SAVE_LongSound_Sound_saveAsAifcFile, U"Save as AIFC file", nullptr, U"aifc") {
  253. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  254. LongSound_concatenate (list.get(), file, Melder_AIFC, 16);
  255. SAVE_TYPED_LIST_END
  256. }
  257. FORM_SAVE (SAVE_LongSound_Sound_saveAsAiffFile, U"Save as AIFF file", nullptr, U"aiff") {
  258. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  259. LongSound_concatenate (list.get(), file, Melder_AIFF, 16);
  260. SAVE_TYPED_LIST_END
  261. }
  262. FORM_SAVE (SAVE_LongSound_Sound_saveAsNextSunFile, U"Save as NeXT/Sun file", nullptr, U"au") {
  263. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  264. LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16);
  265. SAVE_TYPED_LIST_END
  266. }
  267. FORM_SAVE (SAVE_LongSound_Sound_saveAsNistFile, U"Save as NIST file", nullptr, U"nist") {
  268. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  269. LongSound_concatenate (list.get(), file, Melder_NIST, 16);
  270. SAVE_TYPED_LIST_END
  271. }
  272. FORM_SAVE (SAVE_LongSound_Sound_saveAsFlacFile, U"Save as FLAC file", nullptr, U"flac") {
  273. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  274. LongSound_concatenate (list.get(), file, Melder_FLAC, 16);
  275. SAVE_TYPED_LIST_END
  276. }
  277. FORM_SAVE (SAVE_LongSound_Sound_saveAsWavFile, U"Save as WAV file", nullptr, U"wav") {
  278. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  279. LongSound_concatenate (list.get(), file, Melder_WAV, 16);
  280. SAVE_TYPED_LIST_END
  281. }
  282. /********** SOUND **********/
  283. FORM (MODIFY_Sound_add, U"Sound: Add", nullptr) {
  284. LABEL (U"The following number will be added to the amplitudes of ")
  285. LABEL (U"all samples of the sound.")
  286. REAL (number, U"Number", U"0.1")
  287. OK
  288. DO
  289. MODIFY_EACH (Sound)
  290. Vector_addScalar (me, number);
  291. MODIFY_EACH_END
  292. }
  293. FORM (NEW_Sound_autoCorrelate, U"Sound: autocorrelate", U"Sound: Autocorrelate...") {
  294. RADIO_ENUM (kSounds_convolve_scaling, amplitudeScaling,
  295. U"Amplitude scaling", kSounds_convolve_scaling::DEFAULT)
  296. RADIO_ENUM (kSounds_convolve_signalOutsideTimeDomain, signalOutsideTimeDomainIs,
  297. U"Signal outside time domain is...", kSounds_convolve_signalOutsideTimeDomain::DEFAULT)
  298. OK
  299. DO
  300. CONVERT_EACH (Sound)
  301. autoSound result = Sound_autoCorrelate (me, amplitudeScaling, signalOutsideTimeDomainIs);
  302. CONVERT_EACH_END (U"ac_", my name.get())
  303. }
  304. DIRECT (NEW1_Sounds_combineToStereo) {
  305. CONVERT_LIST (Sound)
  306. autoSound result = Sounds_combineToStereo (& list);
  307. integer numberOfChannels = result -> ny; // dereference before transferring
  308. CONVERT_LIST_END (U"combined_", numberOfChannels)
  309. }
  310. DIRECT (NEW1_Sounds_concatenate) {
  311. CONVERT_LIST (Sound)
  312. autoSound result = Sounds_concatenate (list, 0.0);
  313. CONVERT_LIST_END (U"chain")
  314. }
  315. FORM (NEW1_Sounds_concatenateWithOverlap, U"Sounds: Concatenate with overlap", U"Sounds: Concatenate with overlap...") {
  316. POSITIVE (overlap, U"Overlap (s)", U"0.01")
  317. OK
  318. DO
  319. CONVERT_LIST (Sound)
  320. autoSound result = Sounds_concatenate (list, overlap);
  321. CONVERT_LIST_END (U"chain")
  322. }
  323. DIRECT (NEW2_Sounds_concatenateRecoverably) {
  324. integer numberOfChannels = 0, nx = 0, iinterval = 0;
  325. double dx = 0.0, tmin = 0.0;
  326. LOOP {
  327. iam (Sound);
  328. if (numberOfChannels == 0) {
  329. numberOfChannels = my ny;
  330. } else if (my ny != numberOfChannels) {
  331. Melder_throw (U"To concatenate sounds, their numbers of channels (mono, stereo) must be equal.");
  332. }
  333. if (dx == 0.0) {
  334. dx = my dx;
  335. } else if (my dx != dx) {
  336. Melder_throw (U"To concatenate sounds, their sampling frequencies must be equal.\n"
  337. "You could resample one or more of the sounds before concatenating.");
  338. }
  339. nx += my nx;
  340. }
  341. autoSound thee = Sound_create (numberOfChannels, 0.0, nx * dx, nx, dx, 0.5 * dx);
  342. autoTextGrid him = TextGrid_create (0.0, nx * dx, U"labels", U"");
  343. nx = 0;
  344. LOOP {
  345. iam (Sound);
  346. double tmax = tmin + my nx * dx;
  347. for (integer channel = 1; channel <= numberOfChannels; channel ++) {
  348. NUMvector_copyElements (& my z [channel] [0], & thy z [channel] [nx], 1, my nx);
  349. }
  350. iinterval ++;
  351. if (iinterval > 1) {
  352. TextGrid_insertBoundary (him.get(), 1, tmin);
  353. }
  354. TextGrid_setIntervalText (him.get(), 1, iinterval, my name.get());
  355. nx += my nx;
  356. tmin = tmax;
  357. }
  358. praat_new (thee.move(), U"chain");
  359. praat_new (him.move(), U"chain");
  360. END
  361. }
  362. DIRECT (NEW_Sound_convertToMono) {
  363. CONVERT_EACH (Sound)
  364. autoSound result = Sound_convertToMono (me);
  365. CONVERT_EACH_END (my name.get(), U"_mono")
  366. }
  367. DIRECT (NEW_Sound_convertToStereo) {
  368. CONVERT_EACH (Sound)
  369. autoSound result = Sound_convertToStereo (me);
  370. CONVERT_EACH_END (my name.get(), U"_stereo")
  371. }
  372. DIRECT (NEW1_Sounds_convolve_old) {
  373. CONVERT_COUPLE (Sound)
  374. autoSound result = Sounds_convolve (me, you,
  375. kSounds_convolve_scaling::SUM, kSounds_convolve_signalOutsideTimeDomain::ZERO);
  376. CONVERT_COUPLE_END (my name.get(), U"_", your name.get())
  377. }
  378. FORM (NEW1_Sounds_convolve, U"Sounds: Convolve", U"Sounds: Convolve...") {
  379. RADIO_ENUM (kSounds_convolve_scaling, amplitudeScaling,
  380. U"Amplitude scaling", kSounds_convolve_scaling::DEFAULT)
  381. RADIO_ENUM (kSounds_convolve_signalOutsideTimeDomain, signalOutsideTimeDomainIs,
  382. U"Signal outside time domain is...", kSounds_convolve_signalOutsideTimeDomain::DEFAULT)
  383. OK
  384. DO
  385. CONVERT_COUPLE (Sound)
  386. autoSound result = Sounds_convolve (me, you, amplitudeScaling, signalOutsideTimeDomainIs);
  387. CONVERT_COUPLE_END (my name.get(), U"_", your name.get())
  388. }
  389. static void common_Sound_create (conststring32 name, integer numberOfChannels, double startTime, double endTime,
  390. double samplingFrequency, conststring32 formula, Interpreter interpreter)
  391. {
  392. double numberOfSamples_real = round ((endTime - startTime) * samplingFrequency);
  393. if (endTime <= startTime) {
  394. if (endTime == startTime)
  395. Melder_appendError (U"A Sound cannot have a duration of zero.");
  396. else
  397. Melder_appendError (U"A Sound cannot have a duration less than zero.");
  398. if (startTime == 0.0)
  399. Melder_throw (U"Please set the end time to something greater than 0 seconds.");
  400. else
  401. Melder_throw (U"Please lower the start time or raise the end time.");
  402. }
  403. if (samplingFrequency <= 0.0) {
  404. Melder_appendError (U"A Sound cannot have a negative sampling frequency.");
  405. Melder_throw (U"Please set the sampling frequency to something greater than zero, e.g. 44100 Hz.");
  406. }
  407. if (numberOfChannels < 1)
  408. Melder_throw (U"A Sound cannot have zero channels.");
  409. if (numberOfSamples_real < 1.0) {
  410. Melder_appendError (U"A Sound cannot have zero samples.");
  411. if (startTime == 0.0)
  412. Melder_throw (U"Please raise the end time.");
  413. else
  414. Melder_throw (U"Please lower the start time or raise the end time.");
  415. }
  416. if (numberOfSamples_real > INT54_MAX) {
  417. Melder_appendError (U"A Sound cannot have ", numberOfSamples_real, U" samples; the maximum is ",
  418. Melder_bigInteger (INT54_MAX), U" samples (or less, depending on your computer's memory).");
  419. if (startTime == 0.0)
  420. Melder_throw (U"Please lower the end time or the sampling frequency.");
  421. else
  422. Melder_throw (U"Please raise the start time, lower the end time, or lower the sampling frequency.");
  423. }
  424. int64 numberOfSamples = (int64) numberOfSamples_real;
  425. autoSound sound;
  426. try {
  427. sound = Sound_create (numberOfChannels, startTime, endTime, numberOfSamples, 1.0 / samplingFrequency,
  428. startTime + 0.5 * (endTime - startTime - (numberOfSamples - 1) / samplingFrequency));
  429. } catch (MelderError) {
  430. if (str32str (Melder_getError (), U"memory")) {
  431. Melder_clearError ();
  432. Melder_appendError (U"There is not enough memory to create a Sound that contains ", Melder_bigInteger (numberOfSamples), U" samples.");
  433. if (startTime == 0.0)
  434. Melder_throw (U"You could lower the end time or the sampling frequency and try again.");
  435. else
  436. Melder_throw (U"You could raise the start time or lower the end time or the sampling frequency, and try again.");
  437. } else {
  438. throw; // unexpected error; wait for generic message
  439. }
  440. }
  441. Matrix_formula (sound.get(), formula, interpreter, nullptr);
  442. praat_new (sound.move(), name);
  443. //praat_updateSelection ();
  444. }
  445. FORM (NEW1_Sound_create, U"Create mono Sound", U"Create Sound from formula...") {
  446. WORD (name, U"Name", U"sineWithNoise")
  447. REAL (startTime, U"Start time (s)", U"0.0")
  448. REAL (endTime, U"End time (s)", U"1.0")
  449. REAL (samplingFrequency, U"Sampling frequency (Hz)", U"44100")
  450. TEXTFIELD (formula, U"Formula:", U"1/2 * sin(2*pi*377*x) + randomGauss(0,0.1)")
  451. OK
  452. DO
  453. common_Sound_create (name, 1, startTime, endTime, samplingFrequency, formula, interpreter);
  454. END }
  455. FORM (NEW1_Sound_createFromFormula, U"Create Sound from formula", U"Create Sound from formula...") {
  456. WORD (name, U"Name", U"sineWithNoise")
  457. CHANNEL (numberOfChannels, U"Number of channels", U"1 (= mono)")
  458. REAL (startTime, U"Start time (s)", U"0.0")
  459. REAL (endTime, U"End time (s)", U"1.0")
  460. REAL (samplingFrequency, U"Sampling frequency (Hz)", U"44100")
  461. TEXTFIELD (formula, U"Formula:", U"1/2 * sin(2*pi*377*x) + randomGauss(0,0.1)")
  462. OK
  463. DO
  464. common_Sound_create (name, numberOfChannels, startTime, endTime, samplingFrequency, formula, interpreter);
  465. END }
  466. FORM (NEW1_Sound_createAsPureTone, U"Create Sound as pure tone", U"Create Sound as pure tone...") {
  467. WORD (name, U"Name", U"tone")
  468. CHANNEL (numberOfChannels, U"Number of channels", U"1 (= mono)")
  469. REAL (startTime, U"Start time (s)", U"0.0")
  470. REAL (endTime, U"End time (s)", U"0.4")
  471. POSITIVE (samplingFrequency, U"Sampling frequency (Hz)", U"44100.0")
  472. POSITIVE (toneFrequency, U"Tone frequency (Hz)", U"440.0")
  473. POSITIVE (amplitude, U"Amplitude (Pa)", U"0.2")
  474. POSITIVE (fadeInDuration, U"Fade-in duration (s)", U"0.01")
  475. POSITIVE (fadeOutDuration, U"Fade-out duration (s)", U"0.01")
  476. OK
  477. DO
  478. CREATE_ONE
  479. autoSound result = Sound_createAsPureTone (numberOfChannels, startTime, endTime,
  480. samplingFrequency, toneFrequency, amplitude, fadeInDuration, fadeOutDuration);
  481. CREATE_ONE_END (name)
  482. }
  483. FORM (NEW1_Sound_createAsToneComplex, U"Create Sound as tone complex", U"Create Sound as tone complex...") {
  484. WORD (name, U"Name", U"toneComplex")
  485. REAL (startTime, U"Start time (s)", U"0.0")
  486. REAL (endTime, U"End time (s)", U"1.0")
  487. POSITIVE (samplingFrequency, U"Sampling frequency (Hz)", U"44100.0")
  488. RADIOx (phase, U"Phase", 2, Sound_TONE_COMPLEX_SINE)
  489. RADIOBUTTON (U"sine")
  490. RADIOBUTTON (U"cosine")
  491. POSITIVE (frequencyStep, U"Frequency step (Hz)", U"100.0")
  492. REAL (firstFrequency, U"First frequency (Hz)", U"0.0 (= frequency step)")
  493. REAL (ceiling, U"Ceiling (Hz)", U"0.0 (= Nyquist)")
  494. INTEGER (numberOfComponents, U"Number of components", U"0 (= maximum)")
  495. OK
  496. DO
  497. CREATE_ONE
  498. autoSound result = Sound_createAsToneComplex (startTime, endTime,
  499. samplingFrequency, phase, frequencyStep, firstFrequency, ceiling, numberOfComponents);
  500. CREATE_ONE_END (name)
  501. }
  502. FORM (NEW1_old_Sounds_crossCorrelate, U"Cross-correlate (short)", nullptr) {
  503. REAL (fromLag, U"From lag (s)", U"-0.1")
  504. REAL (toLag, U"To lag (s)", U"0.1")
  505. BOOLEAN (normalize, U"Normalize", true)
  506. OK
  507. DO
  508. CONVERT_COUPLE (Sound)
  509. autoSound result = Sounds_crossCorrelate_short (me, you, fromLag, toLag, normalize);
  510. CONVERT_COUPLE_END (U"cc_", my name.get(), U"_", your name.get())
  511. }
  512. FORM (NEW1_Sounds_crossCorrelate, U"Sounds: Cross-correlate", U"Sounds: Cross-correlate...") {
  513. RADIO_ENUM (kSounds_convolve_scaling, amplitudeScaling,
  514. U"Amplitude scaling", kSounds_convolve_scaling::DEFAULT)
  515. RADIO_ENUM (kSounds_convolve_signalOutsideTimeDomain, signalOutsideTimeDomainIs,
  516. U"Signal outside time domain is...", kSounds_convolve_signalOutsideTimeDomain::DEFAULT)
  517. OK
  518. DO_ALTERNATIVE (NEW1_old_Sounds_crossCorrelate)
  519. CONVERT_COUPLE (Sound)
  520. autoSound result = Sounds_crossCorrelate (me, you, amplitudeScaling, signalOutsideTimeDomainIs);
  521. CONVERT_COUPLE_END (U"cc_", my name.get(), U"_", your name.get())
  522. }
  523. FORM (MODIFY_Sound_deemphasizeInplace, U"Sound: De-emphasize (in-place)", U"Sound: De-emphasize (in-place)...") {
  524. REAL (fromFrequency, U"From frequency (Hz)", U"50.0")
  525. OK
  526. DO
  527. MODIFY_EACH (Sound)
  528. Sound_deEmphasis (me, fromFrequency);
  529. Vector_scale (me, 0.99);
  530. MODIFY_EACH_END
  531. }
  532. FORM (NEW_Sound_deepenBandModulation, U"Deepen band modulation", U"Sound: Deepen band modulation...") {
  533. POSITIVE (enhancement, U"Enhancement (dB)", U"20.0")
  534. POSITIVE (fromFrequency, U"From frequency (Hz)", U"300.0")
  535. POSITIVE (toFrequency, U"To frequency (Hz)", U"8000.0")
  536. POSITIVE (slowModulation, U"Slow modulation (Hz)", U"3.0")
  537. POSITIVE (fastModulation, U"Fast modulation (Hz)", U"30.0")
  538. POSITIVE (bandSmoothing, U"Band smoothing (Hz)", U"100.0")
  539. OK
  540. DO
  541. CONVERT_EACH (Sound)
  542. autoSound result = Sound_deepenBandModulation (me, enhancement, fromFrequency, toFrequency,
  543. slowModulation, fastModulation, bandSmoothing);
  544. CONVERT_EACH_END (my name.get(), U"_", Melder_roundTowardsZero (enhancement))
  545. }
  546. FORM (GRAPHICS_old_Sound_draw, U"Sound: Draw", nullptr) {
  547. REAL (fromTime, U"left Time range (s)", U"0.0")
  548. REAL (toTime, U"right Time range", U"0.0 (= all)")
  549. REAL (fromAmplitude, U"left Amplitude range", U"0.0")
  550. REAL (toAmplitude, U"right Amplitude range", U"0.0 (= auto)")
  551. BOOLEAN (garnish, U"Garnish", true)
  552. OK
  553. DO
  554. GRAPHICS_EACH (Sound)
  555. Sound_draw (me, GRAPHICS, fromTime, toTime,
  556. fromAmplitude, toAmplitude, garnish, U"curve");
  557. GRAPHICS_EACH_END
  558. }
  559. FORM (GRAPHICS_Sound_draw, U"Sound: Draw", nullptr) {
  560. REAL (fromTime, U"left Time range (s)", U"0.0")
  561. REAL (toTime, U"right Time range", U"0.0 (= all)")
  562. REAL (fromAmplitude, U"left Amplitude range", U"0.0")
  563. REAL (toAmplitude, U"right Amplitude range", U"0.0 (= auto)")
  564. BOOLEAN (garnish, U"Garnish", true)
  565. LABEL (U"")
  566. OPTIONMENUSTR (drawingMethod, U"Drawing method", 1)
  567. OPTION (U"Curve")
  568. OPTION (U"Bars")
  569. OPTION (U"Poles")
  570. OPTION (U"Speckles")
  571. OK
  572. DO_ALTERNATIVE (GRAPHICS_old_Sound_draw)
  573. GRAPHICS_EACH (Sound)
  574. Sound_draw (me, GRAPHICS, fromTime, toTime,
  575. fromAmplitude, toAmplitude, garnish, drawingMethod);
  576. GRAPHICS_EACH_END
  577. }
  578. static void cb_SoundEditor_publication (Editor /* me */, autoDaata publication) {
  579. /*
  580. * Keep the gate for error handling.
  581. */
  582. try {
  583. bool isaSpectrum = Thing_isa (publication.get(), classSpectrum);
  584. praat_new (publication.move(), U"");
  585. praat_updateSelection ();
  586. if (isaSpectrum) {
  587. int IOBJECT;
  588. FIND_ONE_WITH_IOBJECT (Spectrum)
  589. autoSpectrumEditor editor2 = SpectrumEditor_create (ID_AND_FULL_NAME, me);
  590. praat_installEditor (editor2.get(), IOBJECT);
  591. editor2.releaseToUser();
  592. }
  593. } catch (MelderError) {
  594. Melder_flushError ();
  595. }
  596. }
  597. DIRECT (WINDOW_Sound_viewAndEdit) {
  598. if (theCurrentPraatApplication -> batch) Melder_throw (U"Cannot view or edit a Sound from batch.");
  599. FIND_ONE_WITH_IOBJECT (Sound)
  600. autoSoundEditor editor = SoundEditor_create (ID_AND_FULL_NAME, me);
  601. Editor_setPublicationCallback (editor.get(), cb_SoundEditor_publication);
  602. praat_installEditor (editor.get(), IOBJECT);
  603. editor.releaseToUser();
  604. END
  605. }
  606. DIRECT (NEWMANY_Sound_extractAllChannels) {
  607. LOOP {
  608. iam (Sound);
  609. for (integer channel = 1; channel <= my ny; channel ++) {
  610. autoSound thee = Sound_extractChannel (me, channel);
  611. praat_new (thee.move(), my name.get(), U"_ch", channel);
  612. }
  613. }
  614. END
  615. }
  616. FORM (NEW_Sound_extractChannel, U"Sound: Extract channel", nullptr) {
  617. CHANNEL (channel, U"Channel (number, Left, or Right)", U"1")
  618. OK
  619. DO
  620. CONVERT_EACH (Sound)
  621. autoSound result = Sound_extractChannel (me, channel);
  622. CONVERT_EACH_END (my name.get(), U"_ch", channel)
  623. }
  624. FORM (NEW_Sound_extractChannels, U"Sound: Extract channels", nullptr) {
  625. NUMVEC (channels, U"Channel numbers:", U"to# (64)")
  626. OK
  627. DO
  628. CONVERT_EACH (Sound)
  629. autoSound result = Sound_extractChannels (me, channels);
  630. CONVERT_EACH_END (my name.get(), U"_ch")
  631. }
  632. DIRECT (NEW_Sound_extractLeftChannel) {
  633. CONVERT_EACH (Sound)
  634. autoSound result = Sound_extractChannel (me, 1);
  635. CONVERT_EACH_END (my name.get(), U"_left")
  636. }
  637. FORM (NEW_Sound_extractPart, U"Sound: Extract part", nullptr) {
  638. REAL (fromTime, U"left Time range (s)", U"0.0")
  639. REAL (toTime, U"right Time range (s)", U"0.1")
  640. OPTIONMENU_ENUM (kSound_windowShape, windowShape, U"Window shape", kSound_windowShape::DEFAULT)
  641. POSITIVE (relativeWidth, U"Relative width", U"1.0")
  642. BOOLEAN (preserveTimes, U"Preserve times", false)
  643. OK
  644. DO
  645. CONVERT_EACH (Sound)
  646. autoSound result = Sound_extractPart (me, fromTime, toTime,
  647. windowShape, relativeWidth, preserveTimes);
  648. CONVERT_EACH_END (my name.get(), U"_part")
  649. }
  650. FORM (NEW_Sound_extractPartForOverlap, U"Sound: Extract part for overlap", nullptr) {
  651. REAL (fromTime, U"left Time range (s)", U"0.0")
  652. REAL (toTime, U"right Time range (s)", U"0.1")
  653. POSITIVE (overlap, U"Overlap (s)", U"0.01")
  654. OK
  655. DO
  656. CONVERT_EACH (Sound)
  657. autoSound result = Sound_extractPartForOverlap (me, fromTime, toTime, overlap);
  658. CONVERT_EACH_END (my name.get(), U"_part")
  659. }
  660. DIRECT (NEW_Sound_extractRightChannel) {
  661. CONVERT_EACH (Sound)
  662. autoSound result = Sound_extractChannel (me, 2);
  663. CONVERT_EACH_END (my name.get(), U"_right")
  664. }
  665. FORM (NEW_Sound_filter_deemphasis, U"Sound: Filter (de-emphasis)", U"Sound: Filter (de-emphasis)...") {
  666. REAL (fromFrequency, U"From frequency (Hz)", U"50.0")
  667. OK
  668. DO
  669. CONVERT_EACH (Sound)
  670. autoSound result = Sound_filter_deemphasis (me, fromFrequency);
  671. CONVERT_EACH_END (my name.get(), U"_deemp")
  672. }
  673. FORM (NEW_Sound_filter_formula, U"Sound: Filter (formula)...", U"Formula...") {
  674. LABEL (U"Frequency-domain filtering with a formula (uses Sound-to-Spectrum and Spectrum-to-Sound): x is frequency in hertz")
  675. TEXTFIELD (formula, U"Formula:", U"if x<500 or x>1000 then 0 else self fi; rectangular band filter")
  676. OK
  677. DO
  678. CONVERT_EACH (Sound)
  679. autoSound result = Sound_filter_formula (me, formula, interpreter);
  680. CONVERT_EACH_END (my name.get(), U"_filt")
  681. }
  682. FORM (NEW_Sound_filter_oneFormant, U"Sound: Filter (one formant)", U"Sound: Filter (one formant)...") {
  683. REAL (frequency, U"Frequency (Hz)", U"1000.0")
  684. POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100.0")
  685. OK
  686. DO
  687. CONVERT_EACH (Sound)
  688. autoSound result = Sound_filter_oneFormant (me, frequency, bandwidth);
  689. CONVERT_EACH_END (my name.get(), U"_filt")
  690. }
  691. FORM (MODIFY_Sound_filterWithOneFormantInplace, U"Sound: Filter with one formant (in-place)", U"Sound: Filter with one formant (in-place)...") {
  692. REAL (frequency, U"Frequency (Hz)", U"1000.0")
  693. POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100.0")
  694. OK
  695. DO
  696. MODIFY_EACH (Sound)
  697. Sound_filterWithOneFormantInplace (me, frequency, bandwidth);
  698. MODIFY_EACH_END
  699. }
  700. FORM (NEW_Sound_filter_passHannBand, U"Sound: Filter (pass Hann band)", U"Sound: Filter (pass Hann band)...") {
  701. REAL (fromFrequency, U"From frequency (Hz)", U"500.0")
  702. REAL (toFrequency, U"To frequency (Hz)", U"1000.0")
  703. POSITIVE (smoothing, U"Smoothing (Hz)", U"100.0")
  704. OK
  705. DO
  706. CONVERT_EACH (Sound)
  707. autoSound result = Sound_filter_passHannBand (me, fromFrequency, toFrequency, smoothing);
  708. CONVERT_EACH_END (my name.get(), U"_band")
  709. }
  710. FORM (NEW_Sound_filter_preemphasis, U"Sound: Filter (pre-emphasis)", U"Sound: Filter (pre-emphasis)...") {
  711. REAL (fromFrequency, U"From frequency (Hz)", U"50.0")
  712. OK
  713. DO
  714. CONVERT_EACH (Sound)
  715. autoSound result = Sound_filter_preemphasis (me, fromFrequency);
  716. CONVERT_EACH_END (my name.get(), U"_preemp")
  717. }
  718. FORM (NEW_Sound_filter_stopHannBand, U"Sound: Filter (stop Hann band)", U"Sound: Filter (stop Hann band)...") {
  719. REAL (fromFrequency, U"From frequency (Hz)", U"500.0")
  720. REAL (toFrequency, U"To frequency (Hz)", U"1000.0")
  721. POSITIVE (smoothing, U"Smoothing (Hz)", U"100.0")
  722. OK
  723. DO
  724. CONVERT_EACH (Sound)
  725. autoSound result = Sound_filter_stopHannBand (me, fromFrequency, toFrequency, smoothing);
  726. CONVERT_EACH_END (my name.get(), U"_band")
  727. }
  728. FORM (MODIFY_Sound_formula, U"Sound: Formula", U"Sound: Formula...") {
  729. LABEL (U"# `x` is the time in seconds, `col` is the sample number.")
  730. LABEL (U"x = x1 ! time associated with first sample")
  731. LABEL (U"for col from 1 to ncol")
  732. LABEL (U" self [col] = ...")
  733. TEXTFIELD (formula, nullptr, U"self")
  734. LABEL (U" x = x + dx")
  735. LABEL (U"endfor")
  736. OK
  737. DO
  738. MODIFY_EACH_WEAK (Sound)
  739. Matrix_formula (me, formula, interpreter, nullptr);
  740. MODIFY_EACH_WEAK_END
  741. }
  742. FORM (MODIFY_Sound_formula_part, U"Sound: Formula (part)", U"Sound: Formula...") {
  743. REAL (fromTime, U"From time", U"0.0")
  744. REAL (toTime, U"To time", U"0.0 (= all)")
  745. NATURAL (fromChannel, U"From channel", U"1")
  746. NATURAL (toChannel, U"To channel", U"2")
  747. TEXTFIELD (formula, U"Formula:", U"2 * self")
  748. OK
  749. DO
  750. MODIFY_EACH_WEAK (Sound)
  751. Matrix_formula_part (me, fromTime, toTime,
  752. fromChannel - 0.5, toChannel + 0.5,
  753. formula, interpreter, nullptr);
  754. MODIFY_EACH_WEAK_END
  755. }
  756. FORM (REAL_Sound_getAbsoluteExtremum, U"Sound: Get absolute extremum", U"Sound: Get absolute extremum...") {
  757. REAL (fromTime, U"left Time range (s)", U"0.0")
  758. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  759. RADIOx (interpolation, U"Interpolation", 4, 0)
  760. RADIOBUTTON (U"None")
  761. RADIOBUTTON (U"Parabolic")
  762. RADIOBUTTON (U"Cubic")
  763. RADIOBUTTON (U"Sinc70")
  764. RADIOBUTTON (U"Sinc700")
  765. OK
  766. DO
  767. NUMBER_ONE (Sound)
  768. double result = Vector_getAbsoluteExtremum (me, fromTime, toTime, interpolation);
  769. NUMBER_ONE_END (U" Pascal")
  770. }
  771. FORM (REAL_Sound_getEnergy, U"Sound: Get energy", U"Sound: Get energy...") {
  772. REAL (fromTime, U"left Time range (s)", U"0.0")
  773. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  774. OK
  775. DO
  776. NUMBER_ONE (Sound)
  777. double result = Sound_getEnergy (me, fromTime, toTime);
  778. NUMBER_ONE_END (U" Pa2 sec")
  779. }
  780. DIRECT (REAL_Sound_getEnergyInAir) {
  781. NUMBER_ONE (Sound)
  782. double result = Sound_getEnergyInAir (me);
  783. NUMBER_ONE_END (U" Joule/m2")
  784. }
  785. FORM (REAL_Sound_getIndexFromTime, U"Get sample number from time", U"Get sample number from time...") {
  786. REAL (time, U"Time (s)", U"0.5")
  787. OK
  788. DO
  789. NUMBER_ONE (Sound)
  790. double result = Sampled_xToIndex (me, time);
  791. NUMBER_ONE_END (U" (index at time ", time, U" seconds)")
  792. }
  793. DIRECT (REAL_Sound_getIntensity_dB) {
  794. NUMBER_ONE (Sound)
  795. double result = Sound_getIntensity_dB (me);
  796. NUMBER_ONE_END (U" dB")
  797. }
  798. FORM (REAL_Sound_getMaximum, U"Sound: Get maximum", U"Sound: Get maximum...") {
  799. REAL (fromTime, U"left Time range (s)", U"0.0")
  800. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  801. RADIOx (interpolation, U"Interpolation", 4, 0)
  802. RADIOBUTTON (U"None")
  803. RADIOBUTTON (U"Parabolic")
  804. RADIOBUTTON (U"Cubic")
  805. RADIOBUTTON (U"Sinc70")
  806. RADIOBUTTON (U"Sinc700")
  807. OK
  808. DO
  809. NUMBER_ONE (Sound)
  810. double result = Vector_getMaximum (me, fromTime, toTime, interpolation);
  811. NUMBER_ONE_END (U" Pascal")
  812. }
  813. FORM (REAL_old_Sound_getMean, U"Sound: Get mean", U"Sound: Get mean...") {
  814. REAL (fromTime, U"left Time range (s)", U"0.0")
  815. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  816. OK
  817. DO
  818. NUMBER_ONE (Sound)
  819. double result = Vector_getMean (me, fromTime, toTime, Vector_CHANNEL_AVERAGE);
  820. NUMBER_ONE_END (U" Pascal")
  821. }
  822. FORM (REAL_Sound_getMean, U"Sound: Get mean", U"Sound: Get mean...") {
  823. CHANNEL (channel, U"Channel", U"0 (= all)")
  824. REAL (fromTime, U"left Time range (s)", U"0.0")
  825. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  826. OK
  827. DO_ALTERNATIVE (REAL_old_Sound_getMean)
  828. NUMBER_ONE (Sound)
  829. if (channel > my ny) channel = 1;
  830. double result = Vector_getMean (me, fromTime, toTime, channel);
  831. NUMBER_ONE_END (U" Pascal")
  832. }
  833. FORM (REAL_Sound_getMinimum, U"Sound: Get minimum", U"Sound: Get minimum...") {
  834. REAL (fromTime, U"left Time range (s)", U"0.0")
  835. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  836. RADIOx (interpolation, U"Interpolation", 4, 0)
  837. RADIOBUTTON (U"None")
  838. RADIOBUTTON (U"Parabolic")
  839. RADIOBUTTON (U"Cubic")
  840. RADIOBUTTON (U"Sinc70")
  841. RADIOBUTTON (U"Sinc700")
  842. OK
  843. DO
  844. NUMBER_ONE (Sound)
  845. double result = Vector_getMinimum (me, fromTime, toTime, interpolation);
  846. NUMBER_ONE_END (U" Pascal")
  847. }
  848. FORM (REAL_old_Sound_getNearestZeroCrossing, U"Sound: Get nearest zero crossing", U"Sound: Get nearest zero crossing...") {
  849. REAL (time, U"Time (s)", U"0.5")
  850. OK
  851. DO
  852. NUMBER_ONE (Sound)
  853. if (my ny > 1) Melder_throw (U"Cannot determine a zero crossing for a stereo sound.");
  854. double result = Sound_getNearestZeroCrossing (me, time, 1);
  855. NUMBER_ONE_END (U" seconds")
  856. }
  857. FORM (REAL_Sound_getNearestZeroCrossing, U"Sound: Get nearest zero crossing", U"Sound: Get nearest zero crossing...") {
  858. CHANNEL (channel, U"Channel (number, Left, or Right)", U"1")
  859. REAL (time, U"Time (s)", U"0.5")
  860. OK
  861. DO_ALTERNATIVE (REAL_old_Sound_getNearestZeroCrossing)
  862. NUMBER_ONE (Sound)
  863. if (channel > my ny) channel = 1;
  864. double result = Sound_getNearestZeroCrossing (me, time, channel);
  865. NUMBER_ONE_END (U" seconds")
  866. }
  867. DIRECT (INTEGER_Sound_getNumberOfChannels) {
  868. NUMBER_ONE (Sound)
  869. integer result = my ny;
  870. NUMBER_ONE_END (result == 1 ? U" channel (mono)" : result == 2 ? U" channels (stereo)" : U" channels")
  871. }
  872. DIRECT (INTEGER_Sound_getNumberOfSamples) {
  873. NUMBER_ONE (Sound)
  874. integer result = my nx;
  875. NUMBER_ONE_END (U" samples")
  876. }
  877. FORM (REAL_Sound_getPower, U"Sound: Get power", U"Sound: Get power...") {
  878. REAL (fromTime, U"left Time range (s)", U"0.0")
  879. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  880. OK
  881. DO
  882. NUMBER_ONE (Sound)
  883. double result = Sound_getPower (me, fromTime, toTime);
  884. NUMBER_ONE_END (U" Pa2")
  885. }
  886. DIRECT (REAL_Sound_getPowerInAir) {
  887. NUMBER_ONE (Sound)
  888. double result = Sound_getPowerInAir (me);
  889. NUMBER_ONE_END (U" Watt/m2")
  890. }
  891. FORM (REAL_Sound_getRootMeanSquare, U"Sound: Get root-mean-square", U"Sound: Get root-mean-square...") {
  892. REAL (fromTime, U"left Time range (s)", U"0.0")
  893. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  894. OK
  895. DO
  896. NUMBER_ONE (Sound)
  897. double result = Sound_getRootMeanSquare (me, fromTime, toTime);
  898. NUMBER_ONE_END (U" Pascal")
  899. }
  900. DIRECT (REAL_Sound_getSamplePeriod) {
  901. NUMBER_ONE (Sound)
  902. double result = my dx;
  903. NUMBER_ONE_END (U" seconds")
  904. }
  905. DIRECT (REAL_Sound_getSampleRate) {
  906. NUMBER_ONE (Sound)
  907. double result = 1.0 / my dx;
  908. NUMBER_ONE_END (U" Hz")
  909. }
  910. FORM (REAL_old_Sound_getStandardDeviation, U"Sound: Get standard deviation", U"Sound: Get standard deviation...") {
  911. REAL (fromTime, U"left Time range (s)", U"0.0")
  912. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  913. OK
  914. DO
  915. NUMBER_ONE (Sound)
  916. double result = Vector_getStandardDeviation (me, fromTime, toTime, Vector_CHANNEL_AVERAGE);
  917. NUMBER_ONE_END (U" Pascal")
  918. }
  919. FORM (REAL_Sound_getStandardDeviation, U"Sound: Get standard deviation", U"Sound: Get standard deviation...") {
  920. CHANNEL (channel, U"Channel", U"0 (= average)")
  921. REAL (fromTime, U"left Time range (s)", U"0.0")
  922. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  923. OK
  924. DO_ALTERNATIVE (REAL_old_Sound_getStandardDeviation)
  925. NUMBER_ONE (Sound)
  926. if (channel > my ny) channel = 1;
  927. double result = Vector_getStandardDeviation (me, fromTime, toTime, channel);
  928. NUMBER_ONE_END (U" Pascal")
  929. }
  930. FORM (REAL_Sound_getTimeFromIndex, U"Get time from sample number", U"Get time from sample number...") {
  931. INTEGER (sampleNumber, U"Sample number", U"100")
  932. OK
  933. DO
  934. NUMBER_ONE (Sound)
  935. double result = Sampled_indexToX (me, sampleNumber);
  936. NUMBER_ONE_END (U" seconds")
  937. }
  938. DIRECT (NUMVEC_Sound_getSampleTimes) {
  939. NUMVEC_ONE (Sound)
  940. autoVEC result = Sampled_getAllXValues (me);
  941. NUMVEC_ONE_END
  942. }
  943. FORM (REAL_Sound_getTimeOfMaximum, U"Sound: Get time of maximum", U"Sound: Get time of maximum...") {
  944. REAL (fromTime, U"left Time range (s)", U"0.0")
  945. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  946. RADIOx (interpolation, U"Interpolation", 4, 0)
  947. RADIOBUTTON (U"None")
  948. RADIOBUTTON (U"Parabolic")
  949. RADIOBUTTON (U"Cubic")
  950. RADIOBUTTON (U"Sinc70")
  951. RADIOBUTTON (U"Sinc700")
  952. OK
  953. DO
  954. NUMBER_ONE (Sound)
  955. double result = Vector_getXOfMaximum (me, fromTime, toTime, interpolation);
  956. NUMBER_ONE_END (U" seconds")
  957. }
  958. FORM (REAL_Sound_getTimeOfMinimum, U"Sound: Get time of minimum", U"Sound: Get time of minimum...") {
  959. REAL (fromTime, U"left Time range (s)", U"0.0")
  960. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  961. RADIOx (interpolation, U"Interpolation", 4, 0)
  962. RADIOBUTTON (U"None")
  963. RADIOBUTTON (U"Parabolic")
  964. RADIOBUTTON (U"Cubic")
  965. RADIOBUTTON (U"Sinc70")
  966. RADIOBUTTON (U"Sinc700")
  967. OK
  968. DO
  969. NUMBER_ONE (Sound)
  970. double result = Vector_getXOfMinimum (me, fromTime, toTime, interpolation);
  971. NUMBER_ONE_END (U" seconds")
  972. }
  973. FORM (REAL_old_Sound_getValueAtIndex, U"Sound: Get value at sample number", U"Sound: Get value at sample number...") {
  974. INTEGER (sampleNumber, U"Sample number", U"100")
  975. OK
  976. DO
  977. NUMBER_ONE (Sound)
  978. double result = sampleNumber < 1 || sampleNumber > my nx ? undefined :
  979. my ny == 1 ? my z [1] [sampleNumber] : 0.5 * (my z [1] [sampleNumber] + my z [2] [sampleNumber]);
  980. NUMBER_ONE_END (U" Pascal")
  981. }
  982. FORM (REAL_Sound_getValueAtIndex, U"Sound: Get value at sample number", U"Sound: Get value at sample number...") {
  983. CHANNEL (channel, U"Channel", U"0 (= average)")
  984. INTEGER (sampleNumber, U"Sample number", U"100")
  985. OK
  986. DO_ALTERNATIVE (REAL_old_Sound_getValueAtIndex)
  987. NUMBER_ONE (Sound)
  988. if (channel > my ny) channel = 1;
  989. double result = sampleNumber < 1 || sampleNumber > my nx ? undefined :
  990. Sampled_getValueAtSample (me, sampleNumber, channel, 0);
  991. NUMBER_ONE_END (U" Pascal")
  992. }
  993. FORM (REAL_old_Sound_getValueAtTime, U"Sound: Get value at time", U"Sound: Get value at time...") {
  994. REAL (time, U"Time (s)", U"0.5")
  995. RADIOx (interpolation, U"Interpolation", 4, 0)
  996. RADIOBUTTON (U"Nearest")
  997. RADIOBUTTON (U"Linear")
  998. RADIOBUTTON (U"Cubic")
  999. RADIOBUTTON (U"Sinc70")
  1000. RADIOBUTTON (U"Sinc700")
  1001. OK
  1002. DO
  1003. NUMBER_ONE (Sound)
  1004. double result = Vector_getValueAtX (me, time, Vector_CHANNEL_AVERAGE, interpolation);
  1005. NUMBER_ONE_END (U" Pascal")
  1006. }
  1007. FORM (REAL_Sound_getValueAtTime, U"Sound: Get value at time", U"Sound: Get value at time...") {
  1008. CHANNEL (channel, U"Channel", U"0 (= average)")
  1009. REAL (time, U"Time (s)", U"0.5")
  1010. RADIOx (interpolation, U"Interpolation", 4, 0)
  1011. RADIOBUTTON (U"Nearest")
  1012. RADIOBUTTON (U"Linear")
  1013. RADIOBUTTON (U"Cubic")
  1014. RADIOBUTTON (U"Sinc70")
  1015. RADIOBUTTON (U"Sinc700")
  1016. OK
  1017. DO_ALTERNATIVE (REAL_old_Sound_getValueAtTime)
  1018. NUMBER_ONE (Sound)
  1019. if (channel > my ny) channel = 1;
  1020. double result = Vector_getValueAtX (me, time, channel, interpolation);
  1021. NUMBER_ONE_END (U" Pascal")
  1022. }
  1023. DIRECT (HELP_Sound_help) {
  1024. HELP (U"Sound")
  1025. }
  1026. FORM (NEW_Sound_lengthen_overlapAdd, U"Sound: Lengthen (overlap-add)", U"Sound: Lengthen (overlap-add)...") {
  1027. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1028. POSITIVE (maximumPitch, U"Maximum pitch (Hz)", U"600.0")
  1029. POSITIVE (factor, U"Factor", U"1.5")
  1030. OK
  1031. DO
  1032. if (minimumPitch >= maximumPitch) Melder_throw (U"Maximum pitch should be greater than minimum pitch.");
  1033. CONVERT_EACH (Sound)
  1034. autoSound result = Sound_lengthen_overlapAdd (me, minimumPitch, maximumPitch, factor);
  1035. CONVERT_EACH_END (my name.get(), U"_", Melder_fixed (factor, 2));
  1036. }
  1037. FORM (MODIFY_Sound_multiply, U"Sound: Multiply", nullptr) {
  1038. REAL (multiplicationFactor, U"Multiplication factor", U"1.5")
  1039. OK
  1040. DO
  1041. MODIFY_EACH (Sound)
  1042. Vector_multiplyByScalar (me, multiplicationFactor);
  1043. MODIFY_EACH_END
  1044. }
  1045. FORM (MODIFY_Sound_multiplyByWindow, U"Sound: Multiply by window", nullptr) {
  1046. OPTIONMENU_ENUM (kSound_windowShape, windowShape, U"Window shape", kSound_windowShape::HANNING)
  1047. OK
  1048. DO
  1049. MODIFY_EACH (Sound)
  1050. Sound_multiplyByWindow (me, windowShape);
  1051. MODIFY_EACH_END
  1052. }
  1053. FORM (MODIFY_Sound_overrideSamplingFrequency, U"Sound: Override sampling frequency", nullptr) {
  1054. POSITIVE (newSamplingFrequency, U"New sampling frequency (Hz)", U"16000.0")
  1055. OK
  1056. DO
  1057. MODIFY_EACH (Sound)
  1058. Sound_overrideSamplingFrequency (me, newSamplingFrequency);
  1059. MODIFY_EACH_END
  1060. }
  1061. DIRECT (PLAY_Sound_play) {
  1062. int n = 0;
  1063. LOOP {
  1064. n ++;
  1065. }
  1066. if (n == 1 || MelderAudio_getOutputMaximumAsynchronicity () < kMelder_asynchronicityLevel::ASYNCHRONOUS) {
  1067. LOOP {
  1068. iam (Sound);
  1069. Sound_play (me, nullptr, nullptr);
  1070. }
  1071. } else {
  1072. MelderAudio_setOutputMaximumAsynchronicity (kMelder_asynchronicityLevel::INTERRUPTABLE);
  1073. LOOP {
  1074. iam (Sound);
  1075. Sound_play (me, nullptr, nullptr); // BUG: exception-safe?
  1076. }
  1077. MelderAudio_setOutputMaximumAsynchronicity (kMelder_asynchronicityLevel::ASYNCHRONOUS);
  1078. }
  1079. END }
  1080. FORM (MODIFY_Sound_preemphasizeInplace, U"Sound: Pre-emphasize (in-place)", U"Sound: Pre-emphasize (in-place)...") {
  1081. REAL (fromFrequency, U"From frequency (Hz)", U"50.0")
  1082. OK
  1083. DO
  1084. MODIFY_EACH (Sound)
  1085. Sound_preEmphasis (me, fromFrequency);
  1086. Vector_scale (me, 0.99);
  1087. MODIFY_EACH_END
  1088. }
  1089. FORM_READ (READMANY_Sound_readSeparateChannelsFromSoundFile, U"Read separate channels from sound file", nullptr, true) {
  1090. autoSound sound = Sound_readFromSoundFile (file);
  1091. char32 name [300];
  1092. Melder_sprint (name,300, MelderFile_name (file));
  1093. char32 *lastPeriod = str32rchr (name, U'.');
  1094. if (lastPeriod) {
  1095. *lastPeriod = U'\0';
  1096. }
  1097. for (integer ichan = 1; ichan <= sound -> ny; ichan ++) {
  1098. autoSound thee = Sound_extractChannel (sound.get(), ichan);
  1099. praat_new (thee.move(), name, U"_ch", ichan);
  1100. }
  1101. END
  1102. }
  1103. FORM_READ (READ1_Sound_readFromRawAlawFile, U"Read Sound from raw Alaw file", nullptr, true) {
  1104. READ_ONE
  1105. autoSound result = Sound_readFromRawAlawFile (file);
  1106. READ_ONE_END
  1107. }
  1108. static SoundRecorder theReferenceToTheOnlySoundRecorder;
  1109. static int thePreviousNumberOfChannels;
  1110. static void cb_SoundRecorder_destruction (SoundRecorder /* me */) {
  1111. theReferenceToTheOnlySoundRecorder = nullptr;
  1112. }
  1113. static void cb_SoundRecorder_publication (Editor /* me */, autoDaata publication) {
  1114. try {
  1115. praat_new (publication.move());
  1116. } catch (MelderError) {
  1117. Melder_flushError ();
  1118. }
  1119. praat_updateSelection ();
  1120. }
  1121. static void do_Sound_record (int numberOfChannels) {
  1122. if (theCurrentPraatApplication -> batch)
  1123. Melder_throw (U"Cannot record a Sound from batch.");
  1124. if (theReferenceToTheOnlySoundRecorder && numberOfChannels == thePreviousNumberOfChannels) {
  1125. Editor_raise (theReferenceToTheOnlySoundRecorder);
  1126. } else {
  1127. forget (theReferenceToTheOnlySoundRecorder);
  1128. autoSoundRecorder recorder = SoundRecorder_create (numberOfChannels);
  1129. Editor_setDestructionCallback (recorder.get(), cb_SoundRecorder_destruction);
  1130. Editor_setPublicationCallback (recorder.get(), cb_SoundRecorder_publication);
  1131. theReferenceToTheOnlySoundRecorder = recorder.get();
  1132. recorder.releaseToUser();
  1133. thePreviousNumberOfChannels = numberOfChannels;
  1134. }
  1135. }
  1136. DIRECT (WINDOW_Sound_recordMono) {
  1137. do_Sound_record (1);
  1138. END }
  1139. DIRECT (WINDOW_Sound_recordStereo) {
  1140. do_Sound_record (2);
  1141. END }
  1142. FORM (RECORD1_Sound_record_fixedTime, U"Record Sound", nullptr) {
  1143. RADIO (inputSource, U"Input source", 1)
  1144. RADIOBUTTON (U"Microphone")
  1145. RADIOBUTTON (U"Line")
  1146. REAL (gain, U"Gain (0-1)", U"0.1")
  1147. REAL (balance, U"Balance (0-1)", U"0.5")
  1148. RADIOSTR (samplingFrequency, U"Sampling frequency", 1)
  1149. #ifdef UNIX
  1150. RADIOBUTTON (U"8000")
  1151. #endif
  1152. #ifndef macintosh
  1153. RADIOBUTTON (U"11025")
  1154. #endif
  1155. #ifdef UNIX
  1156. RADIOBUTTON (U"16000")
  1157. #endif
  1158. #ifndef macintosh
  1159. RADIOBUTTON (U"22050")
  1160. #endif
  1161. #ifdef UNIX
  1162. RADIOBUTTON (U"32000")
  1163. #endif
  1164. RADIOBUTTON (U"44100")
  1165. RADIOBUTTON (U"48000")
  1166. RADIOBUTTON (U"96000")
  1167. POSITIVE (duration, U"Duration (seconds)", U"1.0")
  1168. OK
  1169. DO
  1170. CREATE_ONE
  1171. autoSound result = Sound_record_fixedTime (inputSource,
  1172. gain, balance, Melder_atof (samplingFrequency), duration);
  1173. CREATE_ONE_END (U"untitled")
  1174. }
  1175. extern "C" void* Praat_Sound_resample (void* sound, double newSamplingFrequency, int precision);
  1176. #if 0
  1177. void* Praat_Sound_resample (void* sound, double newSamplingFrequency, int precision) {
  1178. try {
  1179. if (newSamplingFrequency <= 0.0) Melder_throw (U"`newSamplingFrequency` has to be positive.");
  1180. if (precision <= 0) Melder_throw (U"`precision` has to be greater than 0.");
  1181. autoSound thee = Sound_resample ((Sound) sound, newSamplingFrequency, precision);
  1182. return (void*) thee.releaseToAmbiguousOwner();
  1183. } catch (MelderError) {
  1184. Melder_flushError (U"Praat: Sound_resample: not performed.");
  1185. return NULL;
  1186. }
  1187. }
  1188. #elif 0
  1189. typedef struct {
  1190. int type;
  1191. union { void* _object; double _double; int _int; };
  1192. } PraatLibArg;
  1193. #define PraatLibArg_OBJECT 0
  1194. #define PraatLibArg_DOUBLE 1
  1195. #define PraatLibArg_INT 2
  1196. extern "C" void* praatlib_do (const char *commandTitle, PraatLibArg args [], int narg);
  1197. void* Praat_Sound_resample (void* sound, double newSamplingFrequency, int precision) {
  1198. PraatLibArg args [3];
  1199. args [0]. type = PraatLibArg_OBJECT;
  1200. args [0]. _object = sound;
  1201. args [1]. type = PraatLibArg_DOUBLE;
  1202. args [1]. _double = newSamplingFrequency;
  1203. args [2]. type = PraatLibArg_INT;
  1204. args [2]. _int = precision;
  1205. return praatlib_do ("Sound: Resample...", args, 3);
  1206. }
  1207. #endif
  1208. FORM (NEW_Sound_resample, U"Sound: Resample", U"Sound: Resample...") {
  1209. POSITIVE (newSamplingFrequency, U"New sampling frequency (Hz)", U"10000.0")
  1210. NATURAL (precision, U"Precision (samples)", U"50")
  1211. OK
  1212. DO
  1213. CONVERT_EACH (Sound)
  1214. autoSound result = Sound_resample (me, newSamplingFrequency, precision);
  1215. CONVERT_EACH_END (my name.get(), U"_", Melder_iround (newSamplingFrequency));
  1216. }
  1217. DIRECT (MODIFY_Sound_reverse) {
  1218. MODIFY_EACH (Sound)
  1219. Sound_reverse (me, 0.0, 0.0);
  1220. MODIFY_EACH_END
  1221. }
  1222. FORM_SAVE (SAVE_Sound_saveAs24BitWavFile, U"Save as 24-bit WAV file", nullptr, U"wav") {
  1223. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1224. LongSound_concatenate (list.get(), file, Melder_WAV, 24);
  1225. SAVE_TYPED_LIST_END
  1226. }
  1227. FORM_SAVE (SAVE_Sound_saveAs32BitWavFile, U"Save as 32-bit WAV file", nullptr, U"wav") {
  1228. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1229. LongSound_concatenate (list.get(), file, Melder_WAV, 32);
  1230. SAVE_TYPED_LIST_END
  1231. }
  1232. FORM (MODIFY_Sound_scalePeak, U"Sound: Scale peak", U"Sound: Scale peak...") {
  1233. POSITIVE (newAbsolutePeak, U"New absolute peak", U"0.99")
  1234. OK
  1235. DO
  1236. MODIFY_EACH (Sound)
  1237. Vector_scale (me, newAbsolutePeak);
  1238. MODIFY_EACH_END
  1239. }
  1240. FORM (MODIFY_Sound_scaleIntensity, U"Sound: Scale intensity", U"Sound: Scale intensity...") {
  1241. POSITIVE (newAverageIntensity, U"New average intensity (dB SPL)", U"70.0")
  1242. OK
  1243. DO
  1244. MODIFY_EACH (Sound)
  1245. Sound_scaleIntensity (me, newAverageIntensity);
  1246. MODIFY_EACH_END
  1247. }
  1248. FORM (MODIFY_old_Sound_setValueAtIndex, U"Sound: Set value at sample number", U"Sound: Set value at sample number...") {
  1249. NATURAL (sampleNumber, U"Sample number", U"100")
  1250. REAL (newValue, U"New value", U"0.0")
  1251. OK
  1252. DO
  1253. MODIFY_EACH (Sound)
  1254. if (sampleNumber > my nx)
  1255. Melder_throw (U"The sample number should not exceed the number of samples, which is ", my nx, U".");
  1256. for (integer channel = 1; channel <= my ny; channel ++)
  1257. my z [channel] [sampleNumber] = newValue;
  1258. MODIFY_EACH_END
  1259. }
  1260. FORM (MODIFY_Sound_setValueAtIndex, U"Sound: Set value at sample number", U"Sound: Set value at sample number...") {
  1261. CHANNEL (channel, U"Channel", U"0 (= all)")
  1262. NATURAL (sampleNumber, U"Sample number", U"100")
  1263. REAL (newValue, U"New value", U"0.0")
  1264. OK
  1265. DO_ALTERNATIVE (MODIFY_old_Sound_setValueAtIndex)
  1266. MODIFY_EACH (Sound)
  1267. if (sampleNumber > my nx)
  1268. Melder_throw (U"The sample number should not exceed the number of samples, which is ", my nx, U".");
  1269. if (channel > my ny) channel = 1;
  1270. if (channel > 0) {
  1271. my z [channel] [sampleNumber] = newValue;
  1272. } else {
  1273. for (channel = 1; channel <= my ny; channel ++) {
  1274. my z [channel] [sampleNumber] = newValue;
  1275. }
  1276. }
  1277. MODIFY_EACH_END
  1278. }
  1279. FORM (MODIFY_Sound_setPartToZero, U"Sound: Set part to zero", nullptr) {
  1280. REAL (fromTime, U"left Time range (s)", U"0.0")
  1281. REAL (toTime, U"right Time range (s)", U"0.0 (= all)")
  1282. RADIOx (cut, U"Cut", 2, 0)
  1283. OPTION (U"at exactly these times")
  1284. OPTION (U"at nearest zero crossing")
  1285. OK
  1286. DO
  1287. MODIFY_EACH (Sound)
  1288. Sound_setZero (me, fromTime, toTime, cut);
  1289. MODIFY_EACH_END
  1290. }
  1291. DIRECT (MODIFY_Sound_subtractMean) {
  1292. MODIFY_EACH (Sound)
  1293. Vector_subtractMean (me);
  1294. MODIFY_EACH_END
  1295. }
  1296. FORM (NEW_Sound_to_Manipulation, U"Sound: To Manipulation", U"Manipulation") {
  1297. POSITIVE (timeStep, U"Time step (s)", U"0.01")
  1298. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1299. POSITIVE (maximumPitch, U"Maximum pitch (Hz)", U"600.0")
  1300. OK
  1301. DO
  1302. if (maximumPitch <= minimumPitch) Melder_throw (U"The maximum pitch should be greater than the minimum pitch.");
  1303. CONVERT_EACH (Sound)
  1304. autoManipulation result = Sound_to_Manipulation (me, timeStep, minimumPitch, maximumPitch);
  1305. CONVERT_EACH_END (my name.get())
  1306. }
  1307. FORM (NEW_Sound_to_Cochleagram, U"Sound: To Cochleagram", nullptr) {
  1308. POSITIVE (timeStep, U"Time step (s)", U"0.01")
  1309. POSITIVE (frequencyResolution, U"Frequency resolution (Bark)", U"0.1")
  1310. POSITIVE (windowLength, U"Window length (s)", U"0.03")
  1311. REAL (forwardMaskingTime, U"Forward-masking time (s)", U"0.03")
  1312. OK
  1313. DO
  1314. CONVERT_EACH (Sound)
  1315. autoCochleagram result = Sound_to_Cochleagram (me, timeStep,
  1316. frequencyResolution, windowLength, forwardMaskingTime);
  1317. CONVERT_EACH_END (my name.get())
  1318. }
  1319. FORM (NEW_Sound_to_Cochleagram_edb, U"Sound: To Cochleagram (De Boer, Meddis & Hewitt)", nullptr) {
  1320. POSITIVE (timeStep, U"Time step (s)", U"0.01")
  1321. POSITIVE (frequencyResolution, U"Frequency resolution (Bark)", U"0.1")
  1322. BOOLEAN (hasSynapse, U"Has synapse", true)
  1323. LABEL (U"Meddis synapse properties")
  1324. POSITIVE (replenishmentRate, U" replenishment rate (/sec)", U"5.05")
  1325. POSITIVE (lossRate, U" loss rate (/sec)", U"2500.0")
  1326. POSITIVE (returnRate, U" return rate (/sec)", U"6580.0")
  1327. POSITIVE (reprocessingRate, U" reprocessing rate (/sec)", U"66.31")
  1328. OK
  1329. DO
  1330. CONVERT_EACH (Sound)
  1331. autoCochleagram result = Sound_to_Cochleagram_edb (me, timeStep, frequencyResolution, hasSynapse,
  1332. replenishmentRate, lossRate, returnRate, reprocessingRate);
  1333. CONVERT_EACH_END (my name.get())
  1334. }
  1335. FORM (NEW_Sound_to_Formant_burg, U"Sound: To Formant (Burg method)", U"Sound: To Formant (burg)...") {
  1336. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1337. POSITIVE (maximumNumberOfFormants, U"Max. number of formants", U"5.0")
  1338. REAL (maximumFormant, U"Maximum formant (Hz)", U"5500.0 (= adult female)")
  1339. POSITIVE (windowLength, U"Window length (s)", U"0.025")
  1340. POSITIVE (preEmphasisFrom, U"Pre-emphasis from (Hz)", U"50.0")
  1341. OK
  1342. DO
  1343. CONVERT_EACH (Sound)
  1344. autoFormant result = Sound_to_Formant_burg (me, timeStep,
  1345. maximumNumberOfFormants, maximumFormant, windowLength, preEmphasisFrom);
  1346. CONVERT_EACH_END (my name.get())
  1347. }
  1348. FORM (NEW_Sound_to_Formant_keepAll, U"Sound: To Formant (keep all)", U"Sound: To Formant (keep all)...") {
  1349. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1350. POSITIVE (maximumNumberOfFormants, U"Max. number of formants", U"5.0")
  1351. REAL (maximumFormant, U"Maximum formant (Hz)", U"5500.0 (= adult female)")
  1352. POSITIVE (windowLength, U"Window length (s)", U"0.025")
  1353. POSITIVE (preEmphasisFrom, U"Pre-emphasis from (Hz)", U"50.0")
  1354. OK
  1355. DO
  1356. CONVERT_EACH (Sound)
  1357. autoFormant result = Sound_to_Formant_keepAll (me, timeStep,
  1358. maximumNumberOfFormants, maximumFormant, windowLength, preEmphasisFrom);
  1359. CONVERT_EACH_END (my name.get())
  1360. }
  1361. FORM (NEW_Sound_to_Formant_willems, U"Sound: To Formant (split Levinson (Willems))", U"Sound: To Formant (sl)...") {
  1362. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1363. POSITIVE (numberOfFormants, U"Number of formants", U"5.0")
  1364. REAL (maximumFormant, U"Maximum formant (Hz)", U"5500.0 (= adult female)")
  1365. POSITIVE (windowLength, U"Window length (s)", U"0.025")
  1366. POSITIVE (preEmphasisFrom, U"Pre-emphasis from (Hz)", U"50.0")
  1367. OK
  1368. DO
  1369. CONVERT_EACH (Sound)
  1370. autoFormant result = Sound_to_Formant_willems (me, timeStep,
  1371. numberOfFormants, maximumFormant, windowLength, preEmphasisFrom);
  1372. CONVERT_EACH_END (my name.get())
  1373. }
  1374. FORM (NEW_Sound_to_Harmonicity_ac, U"Sound: To Harmonicity (ac)", U"Sound: To Harmonicity (ac)...") {
  1375. POSITIVE (timeStep, U"Time step (s)", U"0.01")
  1376. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1377. REAL (silenceThreshold, U"Silence threshold", U"0.1")
  1378. POSITIVE (periodsPerWindow, U"Periods per window", U"4.5")
  1379. OK
  1380. DO
  1381. if (periodsPerWindow < 3.0) Melder_throw (U"Number of periods per window must be at least 3.0.");
  1382. CONVERT_EACH (Sound)
  1383. autoHarmonicity result = Sound_to_Harmonicity_ac (me, timeStep,
  1384. minimumPitch, silenceThreshold, periodsPerWindow);
  1385. CONVERT_EACH_END (my name.get())
  1386. }
  1387. FORM (NEW_Sound_to_Harmonicity_cc, U"Sound: To Harmonicity (cc)", U"Sound: To Harmonicity (cc)...") {
  1388. POSITIVE (timeStep, U"Time step (s)", U"0.01")
  1389. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1390. REAL (silenceThreshold, U"Silence threshold", U"0.1")
  1391. POSITIVE (periodsPerWindow, U"Periods per window", U"1.0")
  1392. OK
  1393. DO
  1394. CONVERT_EACH (Sound)
  1395. autoHarmonicity result = Sound_to_Harmonicity_cc (me, timeStep,
  1396. minimumPitch, silenceThreshold, periodsPerWindow);
  1397. CONVERT_EACH_END (my name.get())
  1398. }
  1399. FORM (NEW_Sound_to_Harmonicity_gne, U"Sound: To Harmonicity (gne)", nullptr) {
  1400. POSITIVE (minimumFrequency, U"Minimum frequency (Hz)", U"500.0")
  1401. POSITIVE (maximumFrequency, U"Maximum frequency (Hz)", U"4500.0")
  1402. POSITIVE (bandwidth, U"Bandwidth (Hz)", U"1000.0")
  1403. POSITIVE (step, U"Step (Hz)", U"80.0")
  1404. OK
  1405. DO
  1406. CONVERT_EACH (Sound)
  1407. autoMatrix result = Sound_to_Harmonicity_GNE (me, minimumFrequency,
  1408. maximumFrequency, bandwidth, step);
  1409. CONVERT_EACH_END (my name.get())
  1410. }
  1411. FORM (NEW_old_Sound_to_Intensity, U"Sound: To Intensity", U"Sound: To Intensity...") {
  1412. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"100.0")
  1413. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1414. OK
  1415. DO
  1416. CONVERT_EACH (Sound)
  1417. autoIntensity result = Sound_to_Intensity (me,
  1418. minimumPitch, timeStep, false);
  1419. CONVERT_EACH_END (my name.get())
  1420. }
  1421. FORM (NEW_Sound_to_Intensity, U"Sound: To Intensity", U"Sound: To Intensity...") {
  1422. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"100.0")
  1423. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1424. BOOLEAN (subtractMean, U"Subtract mean", true)
  1425. OK
  1426. DO_ALTERNATIVE (NEW_old_Sound_to_Intensity)
  1427. CONVERT_EACH (Sound)
  1428. autoIntensity result = Sound_to_Intensity (me,
  1429. minimumPitch, timeStep, subtractMean);
  1430. CONVERT_EACH_END (my name.get())
  1431. }
  1432. FORM (NEW_Sound_to_IntensityTier, U"Sound: To IntensityTier", nullptr) {
  1433. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"100.0")
  1434. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1435. BOOLEAN (subtractMean, U"Subtract mean", true)
  1436. OK
  1437. DO
  1438. CONVERT_EACH (Sound)
  1439. autoIntensityTier result = Sound_to_IntensityTier (me,
  1440. minimumPitch, timeStep, subtractMean);
  1441. CONVERT_EACH_END (my name.get())
  1442. }
  1443. DIRECT (NEW_Sound_to_IntervalTier) {
  1444. CONVERT_EACH (Sound)
  1445. autoIntervalTier result = IntervalTier_create (my xmin, my xmax);
  1446. CONVERT_EACH_END (my name.get())
  1447. }
  1448. FORM (NEW_Sound_to_Ltas, U"Sound: To long-term average spectrum", nullptr) {
  1449. POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100")
  1450. OK
  1451. DO
  1452. CONVERT_EACH (Sound)
  1453. autoLtas result = Sound_to_Ltas (me, bandwidth);
  1454. CONVERT_EACH_END (my name.get())
  1455. }
  1456. FORM (NEW_Sound_to_Ltas_pitchCorrected, U"Sound: To Ltas (pitch-corrected)", U"Sound: To Ltas (pitch-corrected)...") {
  1457. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1458. POSITIVE (maximumPitch, U"Maximum pitch (Hz)", U"600.0")
  1459. POSITIVE (maximumFrequency, U"Maximum frequency (Hz)", U"5000.0")
  1460. POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100.0")
  1461. REAL (shortestPeriod, U"Shortest period (s)", U"0.0001")
  1462. REAL (longestPeriod, U"Longest period (s)", U"0.02")
  1463. POSITIVE (maximumPeriodFactor, U"Maximum period factor", U"1.3")
  1464. OK
  1465. DO
  1466. if (maximumPitch <= minimumPitch) Melder_throw (U"Your maximum pitch should be greater than your minimum pitch.");
  1467. CONVERT_EACH (Sound)
  1468. autoLtas result = Sound_to_Ltas_pitchCorrected (me, minimumPitch, maximumPitch,
  1469. maximumFrequency, bandwidth, shortestPeriod, longestPeriod, maximumPeriodFactor);
  1470. CONVERT_EACH_END (my name.get())
  1471. }
  1472. DIRECT (NEW_Sound_downto_Matrix) {
  1473. CONVERT_EACH (Sound)
  1474. autoMatrix result = Sound_to_Matrix (me);
  1475. CONVERT_EACH_END (my name.get())
  1476. }
  1477. DIRECT (NEW1_Sounds_to_ParamCurve) {
  1478. Sound s1 = nullptr, s2 = nullptr;
  1479. LOOP {
  1480. iam (Sound);
  1481. ( s1 ? s2 : s1 ) = me;
  1482. }
  1483. autoParamCurve thee = ParamCurve_create (s1, s2);
  1484. praat_new (thee.move(), s1 -> name.get(), U"_", s2 -> name.get());
  1485. END }
  1486. FORM (NEW_Sound_to_Pitch, U"Sound: To Pitch", U"Sound: To Pitch...") {
  1487. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1488. POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0")
  1489. POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0")
  1490. OK
  1491. DO
  1492. CONVERT_EACH (Sound)
  1493. autoPitch result = Sound_to_Pitch (me, timeStep, pitchFloor, pitchCeiling);
  1494. CONVERT_EACH_END (my name.get())
  1495. }
  1496. FORM (NEW_Sound_to_Pitch_ac, U"Sound: To Pitch (ac)", U"Sound: To Pitch (ac)...") {
  1497. LABEL (U"Finding the candidates")
  1498. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1499. POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0")
  1500. NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15")
  1501. BOOLEAN (veryAccurate, U"Very accurate", false)
  1502. LABEL (U"Finding a path")
  1503. REAL (silenceThreshold, U"Silence threshold", U"0.03")
  1504. REAL (voicingThreshold, U"Voicing threshold", U"0.45")
  1505. REAL (octaveCost, U"Octave cost", U"0.01")
  1506. REAL (octaveJumpCost, U"Octave-jump cost", U"0.35")
  1507. REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14")
  1508. POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0")
  1509. OK
  1510. DO
  1511. if (maximumNumberOfCandidates <= 1)
  1512. Melder_throw (U"Your maximum number of candidates should be greater than 1.");
  1513. CONVERT_EACH (Sound)
  1514. autoPitch result = Sound_to_Pitch_ac (me, timeStep,
  1515. pitchFloor, 3.0, maximumNumberOfCandidates, veryAccurate,
  1516. silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost, pitchCeiling);
  1517. CONVERT_EACH_END (my name.get())
  1518. }
  1519. FORM (NEW_Sound_to_Pitch_cc, U"Sound: To Pitch (cc)", U"Sound: To Pitch (cc)...") {
  1520. LABEL (U"Finding the candidates")
  1521. REAL (timeStep, U"Time step (s)", U"0.0 (= auto)")
  1522. POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0")
  1523. NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15")
  1524. BOOLEAN (veryAccurate, U"Very accurate", false)
  1525. LABEL (U"Finding a path")
  1526. REAL (silenceThreshold, U"Silence threshold", U"0.03")
  1527. REAL (voicingThreshold, U"Voicing threshold", U"0.45")
  1528. REAL (octaveCost, U"Octave cost", U"0.01")
  1529. REAL (octaveJumpCost, U"Octave-jump cost", U"0.35")
  1530. REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14")
  1531. POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0")
  1532. OK
  1533. DO
  1534. if (maximumNumberOfCandidates <= 1) Melder_throw (U"Youraximum number of candidates should be greater than 1.");
  1535. CONVERT_EACH (Sound)
  1536. autoPitch result = Sound_to_Pitch_cc (me, timeStep,
  1537. pitchFloor, 1.0, maximumNumberOfCandidates, veryAccurate,
  1538. silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost, pitchCeiling);
  1539. CONVERT_EACH_END (my name.get())
  1540. }
  1541. FORM (NEW_Sound_to_PointProcess_extrema, U"Sound: To PointProcess (extrema)", nullptr) {
  1542. CHANNEL (channel, U"Channel (number, Left, or Right)", U"1")
  1543. BOOLEAN (includeMaxima, U"Include maxima", true)
  1544. BOOLEAN (includeMinima, U"Include minima", false)
  1545. RADIOx (interpolation, U"Interpolation", 4, 0)
  1546. RADIOBUTTON (U"None")
  1547. RADIOBUTTON (U"Parabolic")
  1548. RADIOBUTTON (U"Cubic")
  1549. RADIOBUTTON (U"Sinc70")
  1550. RADIOBUTTON (U"Sinc700")
  1551. OK
  1552. DO
  1553. CONVERT_EACH (Sound)
  1554. autoPointProcess result = Sound_to_PointProcess_extrema (me, channel > my ny ? 1 : channel,
  1555. interpolation, includeMaxima, includeMinima);
  1556. CONVERT_EACH_END (my name.get())
  1557. }
  1558. FORM (NEW_Sound_to_PointProcess_periodic_cc, U"Sound: To PointProcess (periodic, cc)", U"Sound: To PointProcess (periodic, cc)...") {
  1559. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1560. POSITIVE (maximumPitch, U"Maximum pitch (Hz)", U"600.0")
  1561. OK
  1562. DO
  1563. if (maximumPitch <= minimumPitch)
  1564. Melder_throw (U"Your maximum pitch should be greater than your minimum pitch.");
  1565. CONVERT_EACH (Sound)
  1566. autoPointProcess result = Sound_to_PointProcess_periodic_cc (me, minimumPitch, maximumPitch);
  1567. CONVERT_EACH_END (my name.get())
  1568. }
  1569. FORM (NEW_Sound_to_PointProcess_periodic_peaks, U"Sound: To PointProcess (periodic, peaks)", U"Sound: To PointProcess (periodic, peaks)...") {
  1570. POSITIVE (minimumPitch, U"Minimum pitch (Hz)", U"75.0")
  1571. POSITIVE (maximumPitch, U"Maximum pitch (Hz)", U"600.0")
  1572. BOOLEAN (includeMaxima, U"Include maxima", true)
  1573. BOOLEAN (includeMinima, U"Include minima", false)
  1574. OK
  1575. DO
  1576. if (maximumPitch <= minimumPitch)
  1577. Melder_throw (U"Your maximum pitch should be greater than your minimum pitch.");
  1578. CONVERT_EACH (Sound)
  1579. autoPointProcess result = Sound_to_PointProcess_periodic_peaks (me,
  1580. minimumPitch, maximumPitch, includeMaxima, includeMinima);
  1581. CONVERT_EACH_END (my name.get())
  1582. }
  1583. FORM (NEW_Sound_to_PointProcess_zeroes, U"Get zeroes", nullptr) {
  1584. CHANNEL (channel, U"Channel (number, Left, or Right)", U"1")
  1585. BOOLEAN (includeRaisers, U"Include raisers", true)
  1586. BOOLEAN (includeFallers, U"Include fallers", false)
  1587. OK
  1588. DO
  1589. CONVERT_EACH (Sound)
  1590. autoPointProcess result = Sound_to_PointProcess_zeroes (me, channel > my ny ? 1 : channel,
  1591. includeRaisers, includeFallers);
  1592. CONVERT_EACH_END (my name.get())
  1593. }
  1594. FORM (NEW_Sound_to_Spectrogram, U"Sound: To Spectrogram", U"Sound: To Spectrogram...") {
  1595. POSITIVE (windowLength, U"Window length (s)", U"0.005")
  1596. POSITIVE (maximumFrequency, U"Maximum frequency (Hz)", U"5000.0")
  1597. POSITIVE (timeStep, U"Time step (s)", U"0.002")
  1598. POSITIVE (frequencyStep, U"Frequency step (Hz)", U"20.0")
  1599. RADIO_ENUM (kSound_to_Spectrogram_windowShape, windowShape,
  1600. U"Window shape", kSound_to_Spectrogram_windowShape::DEFAULT)
  1601. OK
  1602. DO
  1603. CONVERT_EACH (Sound)
  1604. autoSpectrogram result = Sound_to_Spectrogram (me, windowLength,
  1605. maximumFrequency, timeStep, frequencyStep, windowShape, 8.0, 8.0);
  1606. CONVERT_EACH_END (my name.get())
  1607. }
  1608. FORM (NEW_Sound_to_Spectrum, U"Sound: To Spectrum", U"Sound: To Spectrum...") {
  1609. BOOLEAN (fast, U"Fast", true)
  1610. OK
  1611. DO
  1612. CONVERT_EACH (Sound)
  1613. autoSpectrum result = Sound_to_Spectrum (me, fast);
  1614. CONVERT_EACH_END (my name.get())
  1615. }
  1616. DIRECT (NEW_Sound_to_Spectrum_dft) {
  1617. CONVERT_EACH (Sound)
  1618. autoSpectrum result = Sound_to_Spectrum (me, false);
  1619. CONVERT_EACH_END (my name.get())
  1620. }
  1621. DIRECT (NEW_Sound_to_Spectrum_fft) {
  1622. CONVERT_EACH (Sound)
  1623. autoSpectrum result = Sound_to_Spectrum (me, true);
  1624. CONVERT_EACH_END (my name.get())
  1625. }
  1626. FORM (NEW_Sound_to_TextGrid, U"Sound: To TextGrid", U"Sound: To TextGrid...") {
  1627. SENTENCE (allTierNames, U"All tier names", U"Mary John bell")
  1628. SENTENCE (whichOfTheseArePointTiers, U"Which of these are point tiers?", U"bell")
  1629. OK
  1630. DO
  1631. CONVERT_EACH (Sound)
  1632. autoTextGrid result = TextGrid_create (my xmin, my xmax, allTierNames, whichOfTheseArePointTiers);
  1633. CONVERT_EACH_END (my name.get())
  1634. }
  1635. DIRECT (NEW_Sound_to_TextTier) {
  1636. CONVERT_EACH (Sound)
  1637. autoTextTier result = TextTier_create (my xmin, my xmax);
  1638. CONVERT_EACH_END (my name.get())
  1639. }
  1640. FORM (PREFS_SoundInputPrefs, U"Sound recording preferences", U"SoundRecorder") {
  1641. NATURAL (bufferSize, U"Buffer size (MB)", U"60")
  1642. OPTIONMENU_ENUM (kMelder_inputSoundSystem, inputSoundSystem,
  1643. U"Input sound system", kMelder_inputSoundSystem::DEFAULT)
  1644. OK
  1645. SET_INTEGER (bufferSize, SoundRecorder_getBufferSizePref_MB ())
  1646. SET_ENUM (inputSoundSystem, kMelder_inputSoundSystem, MelderAudio_getInputSoundSystem())
  1647. DO
  1648. if (bufferSize > 1000) Melder_throw (U"Buffer size cannot exceed 1000 megabytes.");
  1649. SoundRecorder_setBufferSizePref_MB (bufferSize);
  1650. MelderAudio_setInputSoundSystem (inputSoundSystem);
  1651. END }
  1652. FORM (PREFS_SoundOutputPrefs, U"Sound playing preferences", nullptr) {
  1653. LABEL (U"The following determines how sounds are played.")
  1654. LABEL (U"Between parentheses, you find what you can do simultaneously.")
  1655. LABEL (U"Decrease asynchronicity if sound plays with discontinuities.")
  1656. OPTIONMENU_ENUM (kMelder_asynchronicityLevel, maximumAsynchronicity,
  1657. U"Maximum asynchronicity", kMelder_asynchronicityLevel::DEFAULT)
  1658. #define xstr(s) str(s)
  1659. #define str(s) #s
  1660. REAL (silenceBefore, U"Silence before (s)", U"" xstr (kMelderAudio_outputSilenceBefore_DEFAULT))
  1661. REAL (silenceAfter, U"Silence after (s)", U"" xstr (kMelderAudio_outputSilenceAfter_DEFAULT))
  1662. OPTIONMENU_ENUM (kMelder_outputSoundSystem, outputSoundSystem,
  1663. U"Output sound system", kMelder_outputSoundSystem::DEFAULT)
  1664. OK
  1665. SET_ENUM (maximumAsynchronicity, kMelder_asynchronicityLevel, MelderAudio_getOutputMaximumAsynchronicity ())
  1666. SET_REAL (silenceBefore, MelderAudio_getOutputSilenceBefore ())
  1667. SET_REAL (silenceAfter, MelderAudio_getOutputSilenceAfter ())
  1668. SET_ENUM (outputSoundSystem, kMelder_outputSoundSystem, MelderAudio_getOutputSoundSystem())
  1669. DO
  1670. MelderAudio_stopPlaying (MelderAudio_IMPLICIT);
  1671. MelderAudio_setOutputMaximumAsynchronicity (maximumAsynchronicity);
  1672. MelderAudio_setOutputSilenceBefore (silenceBefore);
  1673. MelderAudio_setOutputSilenceAfter (silenceAfter);
  1674. MelderAudio_setOutputSoundSystem (outputSoundSystem);
  1675. END
  1676. }
  1677. #ifdef HAVE_PULSEAUDIO
  1678. void pulseAudio_serverReport ();
  1679. DIRECT (INFO_Praat_reportSoundServerProperties) {
  1680. pulseAudio_serverReport ();
  1681. END }
  1682. #endif
  1683. FORM_SAVE (SAVE_Sound_saveAsAifcFile, U"Save as AIFC file", nullptr, U"aifc") {
  1684. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1685. LongSound_concatenate (list.get(), file, Melder_AIFC, 16);
  1686. SAVE_TYPED_LIST_END
  1687. }
  1688. FORM_SAVE (SAVE_Sound_saveAsAiffFile, U"Save as AIFF file", nullptr, U"aiff") {
  1689. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1690. LongSound_concatenate (list.get(), file, Melder_AIFF, 16);
  1691. END }
  1692. FORM_SAVE (SAVE_Sound_saveAsFlacFile, U"Save as FLAC file", nullptr, U"flac") {
  1693. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1694. LongSound_concatenate (list.get(), file, Melder_FLAC, 16);
  1695. SAVE_TYPED_LIST_END
  1696. }
  1697. FORM_SAVE (SAVE_Sound_saveAsKayFile, U"Save as Kay sound file", nullptr, U"kay") {
  1698. SAVE_ONE (Sound)
  1699. Sound_saveAsKayFile (me, file);
  1700. SAVE_ONE_END
  1701. }
  1702. FORM_SAVE (SAVE_Sound_saveAsNextSunFile, U"Save as NeXT/Sun file", nullptr, U"au") {
  1703. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1704. LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16);
  1705. SAVE_TYPED_LIST_END
  1706. }
  1707. FORM_SAVE (SAVE_Sound_saveAsNistFile, U"Save as NIST file", nullptr, U"nist") {
  1708. SAVE_TYPED_LIST (Sampled, SoundAndLongSoundList)
  1709. LongSound_concatenate (list.get(), file, Melder_NIST, 16);
  1710. SAVE_TYPED_LIST_END
  1711. }
  1712. FORM_SAVE (SAVE_Sound_saveAsRaw8bitSignedFile, U"Save as raw 8-bit signed sound file", nullptr, U"8sig") {
  1713. SAVE_ONE (Sound)
  1714. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_8_SIGNED);
  1715. SAVE_ONE_END
  1716. }
  1717. FORM_SAVE (SAVE_Sound_saveAsRaw8bitUnsignedFile, U"Save as raw 8-bit unsigned sound file", nullptr, U"8uns") {
  1718. SAVE_ONE (Sound)
  1719. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_8_UNSIGNED);
  1720. SAVE_ONE_END
  1721. }
  1722. FORM_SAVE (SAVE_Sound_saveAsRaw16bitBigEndianFile, U"Save as raw 16-bit big-endian sound file", nullptr, U"16be") {
  1723. SAVE_ONE (Sound)
  1724. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_16_BIG_ENDIAN);
  1725. SAVE_ONE_END
  1726. }
  1727. FORM_SAVE (SAVE_Sound_saveAsRaw16bitLittleEndianFile, U"Save as raw 16-bit little-endian sound file", nullptr, U"16le") {
  1728. SAVE_ONE (Sound)
  1729. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_16_LITTLE_ENDIAN);
  1730. SAVE_ONE_END
  1731. }
  1732. FORM_SAVE (SAVE_Sound_saveAsRaw24bitBigEndianFile, U"Save as raw 24-bit big-endian sound file", nullptr, U"24be") {
  1733. SAVE_ONE (Sound)
  1734. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_24_BIG_ENDIAN);
  1735. SAVE_ONE_END
  1736. }
  1737. FORM_SAVE (SAVE_Sound_saveAsRaw24bitLittleEndianFile, U"Save as raw 24-bit little-endian sound file", nullptr, U"24le") {
  1738. SAVE_ONE (Sound)
  1739. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_24_LITTLE_ENDIAN);
  1740. SAVE_ONE_END
  1741. }
  1742. FORM_SAVE (SAVE_Sound_saveAsRaw32bitBigEndianFile, U"Save as raw 32-bit big-endian sound file", nullptr, U"32be") {
  1743. SAVE_ONE (Sound)
  1744. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_32_BIG_ENDIAN);
  1745. SAVE_ONE_END
  1746. }
  1747. FORM_SAVE (SAVE_Sound_saveAsRaw32bitLittleEndianFile, U"Save as raw 32-bit little-endian sound file", nullptr, U"32le") {
  1748. SAVE_ONE (Sound)
  1749. Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_32_LITTLE_ENDIAN);
  1750. SAVE_ONE_END
  1751. }
  1752. FORM_SAVE (SAVE_Sound_saveAsSesamFile, U"Save as Sesam file", nullptr, U"sdf") {
  1753. SAVE_ONE (Sound)
  1754. Sound_saveAsSesamFile (me, file);
  1755. SAVE_ONE_END
  1756. }
  1757. FORM_SAVE (SAVE_Sound_saveAsStereoAifcFile, U"Save as stereo AIFC file", nullptr, U"aifc") {
  1758. SAVE_LIST (Sound)
  1759. autoSound stereo = Sounds_combineToStereo (& list);
  1760. Sound_saveAsAudioFile (stereo.get(), file, Melder_AIFC, 16);
  1761. SAVE_LIST_END
  1762. }
  1763. FORM_SAVE (SAVE_Sound_saveAsStereoAiffFile, U"Save as stereo AIFF file", nullptr, U"aiff") {
  1764. SAVE_LIST (Sound)
  1765. autoSound stereo = Sounds_combineToStereo (& list);
  1766. Sound_saveAsAudioFile (stereo.get(), file, Melder_AIFF, 16);
  1767. SAVE_LIST_END
  1768. }
  1769. FORM_SAVE (SAVE_Sound_saveAsStereoNextSunFile, U"Save as stereo NeXT/Sun file", nullptr, U"au") {
  1770. SAVE_LIST (Sound)
  1771. autoSound stereo = Sounds_combineToStereo (& list);
  1772. Sound_saveAsAudioFile (stereo.get(), file, Melder_NEXT_SUN, 16);
  1773. SAVE_LIST_END
  1774. }
  1775. FORM_SAVE (SAVE_Sound_saveAsStereoNistFile, U"Save as stereo NIST file", nullptr, U"nist") {
  1776. SAVE_LIST (Sound)
  1777. autoSound stereo = Sounds_combineToStereo (& list);
  1778. Sound_saveAsAudioFile (stereo.get(), file, Melder_NIST, 16);
  1779. SAVE_LIST_END
  1780. }
  1781. FORM_SAVE (SAVE_Sound_saveAsStereoFlacFile, U"Save as stereo FLAC file", nullptr, U"flac") {
  1782. SAVE_LIST (Sound)
  1783. autoSound stereo = Sounds_combineToStereo (& list);
  1784. Sound_saveAsAudioFile (stereo.get(), file, Melder_FLAC, 16);
  1785. SAVE_LIST_END
  1786. }
  1787. FORM_SAVE (SAVE_Sound_saveAsStereoWavFile, U"Save as stereo WAV file", nullptr, U"wav") {
  1788. SAVE_LIST (Sound)
  1789. autoSound stereo = Sounds_combineToStereo (& list);
  1790. Sound_saveAsAudioFile (stereo.get(), file, Melder_WAV, 16);
  1791. SAVE_LIST_END
  1792. }
  1793. FORM_SAVE (SAVE_Sound_saveAsSunAudioFile, U"Save as NeXT/Sun file", nullptr, U"au") {
  1794. SAVE_TYPED_LIST (Sound, SoundAndLongSoundList)
  1795. LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16);
  1796. SAVE_TYPED_LIST_END
  1797. }
  1798. FORM_SAVE (SAVE_Sound_saveAsWavFile, U"Save as WAV file", nullptr, U"wav") {
  1799. SAVE_TYPED_LIST (Sound, SoundAndLongSoundList)
  1800. LongSound_concatenate (list.get(), file, Melder_WAV, 16);
  1801. SAVE_TYPED_LIST_END
  1802. }
  1803. /***** STOP *****/
  1804. DIRECT (PLAY_stopPlayingSound) {
  1805. MelderAudio_stopPlaying (MelderAudio_IMPLICIT);
  1806. END }
  1807. /***** Help menus *****/
  1808. DIRECT (HELP_AnnotationTutorial) {
  1809. HELP (U"Intro 7. Annotation")
  1810. }
  1811. DIRECT (HELP_FilteringTutorial) {
  1812. HELP (U"Filtering")
  1813. }
  1814. /***** file recognizers *****/
  1815. static autoDaata macSoundOrEmptyFileRecognizer (integer nread, const char * /* header */, MelderFile file) {
  1816. /***** No data in file? This may be a Macintosh sound file with only a resource fork. *****/
  1817. if (nread > 0) return autoDaata ();
  1818. Melder_throw (U"File ", file, U" contains no audio data."); // !!!
  1819. }
  1820. static autoDaata soundFileRecognizer (integer nread, const char *header, MelderFile file) {
  1821. if (nread < 16) return autoDaata ();
  1822. if (strnequ (header, "FORM", 4) && strnequ (header + 8, "AIF", 3)) return Sound_readFromSoundFile (file);
  1823. if (strnequ (header, "RIFF", 4) && (strnequ (header + 8, "WAVE", 4) || strnequ (header + 8, "CDDA", 4))) return Sound_readFromSoundFile (file);
  1824. if (strnequ (header, ".snd", 4)) return Sound_readFromSoundFile (file);
  1825. if (strnequ (header, "NIST_1A", 7)) return Sound_readFromSoundFile (file);
  1826. if (strnequ (header, "fLaC", 4)) return Sound_readFromSoundFile (file); // Erez Volk, March 2007
  1827. if ((Melder_stringMatchesCriterion (MelderFile_name (file), kMelder_string::ENDS_WITH, U".mp3", false))
  1828. && mp3_recognize (nread, header)) return Sound_readFromSoundFile (file); // Erez Volk, May 2007
  1829. return autoDaata ();
  1830. }
  1831. static autoDaata movieFileRecognizer (integer nread, const char * /* header */, MelderFile file) {
  1832. conststring32 fileName = MelderFile_name (file);
  1833. /*Melder_casual ("%d %d %d %d %d %d %d %d %d %d", header [0],
  1834. header [1], header [2], header [3],
  1835. header [4], header [5], header [6],
  1836. header [7], header [8], header [9]);*/
  1837. if (nread < 512 || (! Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".mov", false) &&
  1838. ! Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".avi", false))) return autoDaata ();
  1839. Melder_throw (U"This Praat version cannot open movie files.");
  1840. return autoDaata ();
  1841. }
  1842. static autoDaata sesamFileRecognizer (integer nread, const char * /* header */, MelderFile file) {
  1843. conststring32 fileName = MelderFile_name (file);
  1844. if (nread < 512 || (! Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".sdf", false))) return autoDaata ();
  1845. return Sound_readFromSesamFile (file);
  1846. }
  1847. static autoDaata bellLabsFileRecognizer (integer nread, const char *header, MelderFile file) {
  1848. if (nread < 16 || ! strnequ (& header [0], "SIG\n", 4)) return autoDaata ();
  1849. return Sound_readFromBellLabsFile (file);
  1850. }
  1851. static autoDaata kayFileRecognizer (integer nread, const char *header, MelderFile file) {
  1852. if (nread <= 12 || ! strnequ (& header [0], "FORMDS16", 8)) return autoDaata ();
  1853. return Sound_readFromKayFile (file);
  1854. }
  1855. /***** override play and record buttons in manuals *****/
  1856. static autoSound melderSound, melderSoundFromFile;
  1857. static Sound last;
  1858. static int recordProc (double duration) {
  1859. if (last == melderSound.get()) last = nullptr;
  1860. MelderAudio_stopPlaying (MelderAudio_IMPLICIT);
  1861. melderSound = Sound_record_fixedTime (1, 1.0, 0.5, 44100, duration);
  1862. if (! melderSound) return 0;
  1863. last = melderSound.get();
  1864. return 1;
  1865. }
  1866. static int recordFromFileProc (MelderFile file) {
  1867. if (last == melderSoundFromFile.get()) last = nullptr;
  1868. Melder_warningOff (); // like "missing samples"
  1869. melderSoundFromFile = Data_readFromFile (file). static_cast_move<structSound>();
  1870. Melder_warningOn ();
  1871. if (! melderSoundFromFile) return 0;
  1872. if (! Thing_isa (melderSoundFromFile.get(), classSound)) { melderSoundFromFile.reset(); return 0; }
  1873. last = melderSoundFromFile.get();
  1874. Sound_play (melderSoundFromFile.get(), nullptr, nullptr);
  1875. return 1;
  1876. }
  1877. static void playProc () {
  1878. if (melderSound) {
  1879. Sound_play (melderSound.get(), nullptr, nullptr);
  1880. last = melderSound.get();
  1881. }
  1882. }
  1883. static void playReverseProc () {
  1884. /*if (melderSound) Sound_playReverse (melderSound);*/
  1885. }
  1886. static int publishPlayedProc () {
  1887. if (! last) return 0;
  1888. autoSound sound = Data_copy (last);
  1889. return Data_publish (sound.move());
  1890. }
  1891. /***** buttons *****/
  1892. void praat_Sound_init () {
  1893. Thing_recognizeClassesByName (classSound, classLongSound, nullptr);
  1894. Data_recognizeFileType (macSoundOrEmptyFileRecognizer);
  1895. Data_recognizeFileType (soundFileRecognizer);
  1896. Data_recognizeFileType (movieFileRecognizer);
  1897. Data_recognizeFileType (sesamFileRecognizer);
  1898. Data_recognizeFileType (bellLabsFileRecognizer);
  1899. Data_recognizeFileType (kayFileRecognizer);
  1900. SoundRecorder_preferences ();
  1901. structSoundRecorder :: f_preferences ();
  1902. structFunctionEditor :: f_preferences ();
  1903. LongSound_preferences ();
  1904. structTimeSoundEditor :: f_preferences ();
  1905. structTimeSoundAnalysisEditor :: f_preferences ();
  1906. Melder_setRecordProc (recordProc);
  1907. Melder_setRecordFromFileProc (recordFromFileProc);
  1908. Melder_setPlayProc (playProc);
  1909. Melder_setPlayReverseProc (playReverseProc);
  1910. Melder_setPublishPlayedProc (publishPlayedProc);
  1911. praat_addMenuCommand (U"Objects", U"New", U"Record mono Sound...", nullptr, praat_ATTRACTIVE | 'R' | praat_NO_API, WINDOW_Sound_recordMono);
  1912. praat_addMenuCommand (U"Objects", U"New", U"Record stereo Sound...", nullptr, praat_NO_API, WINDOW_Sound_recordStereo);
  1913. praat_addMenuCommand (U"Objects", U"New", U"Record Sound (fixed time)...", nullptr, praat_HIDDEN | praat_FORCE_API, RECORD1_Sound_record_fixedTime);
  1914. praat_addMenuCommand (U"Objects", U"New", U"Sound", nullptr, 0, nullptr);
  1915. praat_addMenuCommand (U"Objects", U"New", U"Create Sound as pure tone...", nullptr, 1, NEW1_Sound_createAsPureTone);
  1916. praat_addMenuCommand (U"Objects", U"New", U"Create Sound from formula...", nullptr, 1, NEW1_Sound_createFromFormula);
  1917. praat_addMenuCommand (U"Objects", U"New", U"Create Sound...", U"*Create Sound from formula...", praat_DEPTH_1 | praat_DEPRECATED_2007, NEW1_Sound_create);
  1918. praat_addMenuCommand (U"Objects", U"New", U"-- create sound advanced --", nullptr, 1, nullptr);
  1919. praat_addMenuCommand (U"Objects", U"New", U"Create Sound as tone complex...", nullptr, 1, NEW1_Sound_createAsToneComplex);
  1920. praat_addMenuCommand (U"Objects", U"New", U"Create Sound from tone complex...", U"*Create Sound as tone complex...", praat_DEPTH_1 | praat_DEPRECATED_2013, NEW1_Sound_createAsToneComplex);
  1921. praat_addMenuCommand (U"Objects", U"Open", U"-- read sound --", nullptr, 0, nullptr);
  1922. praat_addMenuCommand (U"Objects", U"Open", U"Open long sound file...", nullptr, 'L', READ1_LongSound_open);
  1923. praat_addMenuCommand (U"Objects", U"Open", U"Read two Sounds from stereo file...", nullptr, praat_DEPRECATED_2010, READMANY_Sound_readSeparateChannelsFromSoundFile);
  1924. praat_addMenuCommand (U"Objects", U"Open", U"Read separate channels from sound file...", nullptr, 0, READMANY_Sound_readSeparateChannelsFromSoundFile);
  1925. praat_addMenuCommand (U"Objects", U"Open", U"Read from special sound file", nullptr, 0, nullptr);
  1926. praat_addMenuCommand (U"Objects", U"Open", U"Read Sound from raw Alaw file...", nullptr, praat_DEPTH_1, READ1_Sound_readFromRawAlawFile);
  1927. praat_addMenuCommand (U"Objects", U"Goodies", U"Stop playing sound", nullptr, GuiMenu_ESCAPE, PLAY_stopPlayingSound);
  1928. praat_addMenuCommand (U"Objects", U"Preferences", U"-- sound prefs --", nullptr, 0, nullptr);
  1929. praat_addMenuCommand (U"Objects", U"Preferences", U"Sound recording preferences...", nullptr, 0, PREFS_SoundInputPrefs);
  1930. praat_addMenuCommand (U"Objects", U"Preferences", U"Sound playing preferences...", nullptr, 0, PREFS_SoundOutputPrefs);
  1931. praat_addMenuCommand (U"Objects", U"Preferences", U"LongSound preferences...", nullptr, 0, PREFS_LongSoundPrefs);
  1932. #ifdef HAVE_PULSEAUDIO
  1933. praat_addMenuCommand (U"Objects", U"Technical", U"Report sound server properties", U"Report system properties", 0, INFO_Praat_reportSoundServerProperties);
  1934. #endif
  1935. praat_addAction1 (classLongSound, 0, U"LongSound help", nullptr, 0, HELP_LongSound_help);
  1936. praat_addAction1 (classLongSound, 1, U"View", nullptr, praat_ATTRACTIVE, WINDOW_LongSound_view);
  1937. praat_addAction1 (classLongSound, 1, U"Open", U"*View", praat_DEPRECATED_2011, WINDOW_LongSound_view);
  1938. praat_addAction1 (classLongSound, 0, U"Play part...", nullptr, 0, PLAY_LongSound_playPart);
  1939. praat_addAction1 (classLongSound, 1, U"Query -", nullptr, 0, nullptr);
  1940. praat_TimeFunction_query_init (classLongSound);
  1941. praat_addAction1 (classLongSound, 1, U"Sampling", nullptr, 1, nullptr);
  1942. praat_addAction1 (classLongSound, 1, U"Get number of samples", nullptr, 2, INTEGER_LongSound_getNumberOfSamples);
  1943. praat_addAction1 (classLongSound, 1, U"Get sampling period", nullptr, 2, REAL_LongSound_getSamplePeriod);
  1944. praat_addAction1 (classLongSound, 1, U"Get sample duration", U"*Get sampling period", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_LongSound_getSamplePeriod);
  1945. praat_addAction1 (classLongSound, 1, U"Get sample period", U"*Get sampling period", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_LongSound_getSamplePeriod);
  1946. praat_addAction1 (classLongSound, 1, U"Get sampling frequency", nullptr, 2, REAL_LongSound_getSampleRate);
  1947. praat_addAction1 (classLongSound, 1, U"Get sample rate", U"*Get sampling frequency", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_LongSound_getSampleRate);
  1948. praat_addAction1 (classLongSound, 1, U"-- get time discretization --", nullptr, 2, nullptr);
  1949. praat_addAction1 (classLongSound, 1, U"Get time from sample number...", nullptr, 2, REAL_LongSound_getTimeFromIndex);
  1950. praat_addAction1 (classLongSound, 1, U"Get time from index...", U"*Get time from sample number...", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_LongSound_getTimeFromIndex);
  1951. praat_addAction1 (classLongSound, 1, U"Get sample number from time...", nullptr, 2, REAL_LongSound_getIndexFromTime);
  1952. praat_addAction1 (classLongSound, 1, U"Get index from time...", U"*Get sample number from time...", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_LongSound_getIndexFromTime);
  1953. praat_addAction1 (classLongSound, 0, U"Annotate -", nullptr, 0, nullptr);
  1954. praat_addAction1 (classLongSound, 0, U"Annotation tutorial", nullptr, 1, HELP_AnnotationTutorial);
  1955. praat_addAction1 (classLongSound, 0, U"-- to text grid --", nullptr, 1, nullptr);
  1956. praat_addAction1 (classLongSound, 0, U"To TextGrid...", nullptr, 1, NEW_LongSound_to_TextGrid);
  1957. praat_addAction1 (classLongSound, 0, U"Convert to Sound", nullptr, 0, nullptr);
  1958. praat_addAction1 (classLongSound, 0, U"Extract part...", nullptr, 0, NEW_LongSound_extractPart);
  1959. praat_addAction1 (classLongSound, 0, U"Concatenate?", nullptr, 0, INFO_LongSound_concatenate);
  1960. praat_addAction1 (classLongSound, 0, U"Save as WAV file...", nullptr, 0, SAVE_LongSound_saveAsWavFile);
  1961. praat_addAction1 (classLongSound, 0, U"Write to WAV file...", U"*Save as WAV file...", praat_DEPRECATED_2011, SAVE_LongSound_saveAsWavFile);
  1962. praat_addAction1 (classLongSound, 0, U"Save as AIFF file...", nullptr, 0, SAVE_LongSound_saveAsAiffFile);
  1963. praat_addAction1 (classLongSound, 0, U"Write to AIFF file...", U"*Save as AIFF file...", praat_DEPRECATED_2011, SAVE_LongSound_saveAsAiffFile);
  1964. praat_addAction1 (classLongSound, 0, U"Save as AIFC file...", nullptr, 0, SAVE_LongSound_saveAsAifcFile);
  1965. praat_addAction1 (classLongSound, 0, U"Write to AIFC file...", U"*Save as AIFC file...", praat_DEPRECATED_2011, SAVE_LongSound_saveAsAifcFile);
  1966. praat_addAction1 (classLongSound, 0, U"Save as Next/Sun file...", nullptr, 0, SAVE_LongSound_saveAsNextSunFile);
  1967. praat_addAction1 (classLongSound, 0, U"Write to Next/Sun file...", U"*Save as Next/Sun file...", praat_DEPRECATED_2011, SAVE_LongSound_saveAsNextSunFile);
  1968. praat_addAction1 (classLongSound, 0, U"Save as NIST file...", nullptr, 0, SAVE_LongSound_saveAsNistFile);
  1969. praat_addAction1 (classLongSound, 0, U"Write to NIST file...", U"*Save as NIST file...", praat_DEPRECATED_2011, SAVE_LongSound_saveAsNistFile);
  1970. praat_addAction1 (classLongSound, 0, U"Save as FLAC file...", nullptr, 0, SAVE_LongSound_saveAsFlacFile);
  1971. praat_addAction1 (classLongSound, 0, U"Write to FLAC file...", U"*Save as FLAC file...", praat_DEPRECATED_2011, SAVE_LongSound_saveAsFlacFile);
  1972. praat_addAction1 (classLongSound, 0, U"Save left channel as WAV file...", nullptr, 0, SAVE_LongSound_saveLeftChannelAsWavFile);
  1973. praat_addAction1 (classLongSound, 0, U"Write left channel to WAV file...", U"*Save left channel as WAV file...", praat_DEPRECATED_2011, SAVE_LongSound_saveLeftChannelAsWavFile);
  1974. praat_addAction1 (classLongSound, 0, U"Save left channel as AIFF file...", nullptr, 0, SAVE_LongSound_saveLeftChannelAsAiffFile);
  1975. praat_addAction1 (classLongSound, 0, U"Write left channel to AIFF file...", U"*Save left channel as AIFF file...", praat_DEPRECATED_2011, SAVE_LongSound_saveLeftChannelAsAiffFile);
  1976. praat_addAction1 (classLongSound, 0, U"Save left channel as AIFC file...", nullptr, 0, SAVE_LongSound_saveLeftChannelAsAifcFile);
  1977. praat_addAction1 (classLongSound, 0, U"Write left channel to AIFC file...", U"*Save left channel as AIFC file...", praat_DEPRECATED_2011, SAVE_LongSound_saveLeftChannelAsAifcFile);
  1978. praat_addAction1 (classLongSound, 0, U"Save left channel as Next/Sun file...", nullptr, 0, SAVE_LongSound_saveLeftChannelAsNextSunFile);
  1979. praat_addAction1 (classLongSound, 0, U"Write left channel to Next/Sun file...", U"*Save left channel as Next/Sun file...", praat_DEPRECATED_2011, SAVE_LongSound_saveLeftChannelAsNextSunFile);
  1980. praat_addAction1 (classLongSound, 0, U"Save left channel as NIST file...", nullptr, 0, SAVE_LongSound_saveLeftChannelAsNistFile);
  1981. praat_addAction1 (classLongSound, 0, U"Write left channel to NIST file...", U"*Save left channel as NIST file...", praat_DEPRECATED_2011, SAVE_LongSound_saveLeftChannelAsNistFile);
  1982. praat_addAction1 (classLongSound, 0, U"Save left channel as FLAC file...", nullptr, 0, SAVE_LongSound_saveLeftChannelAsFlacFile);
  1983. praat_addAction1 (classLongSound, 0, U"Write left channel to FLAC file...", U"*Save left channel as FLAC file...", praat_DEPRECATED_2011, SAVE_LongSound_saveLeftChannelAsFlacFile);
  1984. praat_addAction1 (classLongSound, 0, U"Save right channel as WAV file...", nullptr, 0, SAVE_LongSound_saveRightChannelAsWavFile);
  1985. praat_addAction1 (classLongSound, 0, U"Write right channel to WAV file...", U"*Save right channel as WAV file...", praat_DEPRECATED_2011, SAVE_LongSound_saveRightChannelAsWavFile);
  1986. praat_addAction1 (classLongSound, 0, U"Save right channel as AIFF file...", nullptr, 0, SAVE_LongSound_saveRightChannelAsAiffFile);
  1987. praat_addAction1 (classLongSound, 0, U"Write right channel to AIFF file...", U"*Save right channel as AIFF file...", praat_DEPRECATED_2011, SAVE_LongSound_saveRightChannelAsAiffFile);
  1988. praat_addAction1 (classLongSound, 0, U"Save right channel as AIFC file...", nullptr, 0, SAVE_LongSound_saveRightChannelAsAifcFile);
  1989. praat_addAction1 (classLongSound, 0, U"Write right channel to AIFC file...", U"*Save right channel as AIFC file...", praat_DEPRECATED_2011, SAVE_LongSound_saveRightChannelAsAifcFile);
  1990. praat_addAction1 (classLongSound, 0, U"Save right channel as Next/Sun file...", nullptr, 0, SAVE_LongSound_saveRightChannelAsNextSunFile);
  1991. praat_addAction1 (classLongSound, 0, U"Write right channel to Next/Sun file...", U"*Save right channel as Next/Sun file...", praat_DEPRECATED_2011, SAVE_LongSound_saveRightChannelAsNextSunFile);
  1992. praat_addAction1 (classLongSound, 0, U"Save right channel as NIST file...", nullptr, 0, SAVE_LongSound_saveRightChannelAsNistFile);
  1993. praat_addAction1 (classLongSound, 0, U"Write right channel to NIST file...", U"*Save right channel as NIST file...", praat_DEPRECATED_2011, SAVE_LongSound_saveRightChannelAsNistFile);
  1994. praat_addAction1 (classLongSound, 0, U"Save right channel as FLAC file...", nullptr, 0, SAVE_LongSound_saveRightChannelAsFlacFile);
  1995. praat_addAction1 (classLongSound, 0, U"Write right channel to FLAC file...", U"*Save right channel as FLAC file...", praat_DEPRECATED_2011, SAVE_LongSound_saveRightChannelAsFlacFile);
  1996. praat_addAction1 (classLongSound, 0, U"Save part as audio file...", nullptr, 0, SAVE_LongSound_savePartAsAudioFile);
  1997. praat_addAction1 (classLongSound, 0, U"Write part to audio file...", U"*Save part as audio file...", praat_DEPRECATED_2011, SAVE_LongSound_savePartAsAudioFile);
  1998. praat_addAction1 (classSound, 0, U"Save as WAV file...", nullptr, 0, SAVE_Sound_saveAsWavFile);
  1999. praat_addAction1 (classSound, 0, U"Write to WAV file...", U"*Save as WAV file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsWavFile);
  2000. praat_addAction1 (classSound, 0, U"Save as AIFF file...", nullptr, 0, SAVE_Sound_saveAsAiffFile);
  2001. praat_addAction1 (classSound, 0, U"Write to AIFF file...", U"*Save as AIFF file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsAiffFile);
  2002. praat_addAction1 (classSound, 0, U"Save as AIFC file...", nullptr, 0, SAVE_Sound_saveAsAifcFile);
  2003. praat_addAction1 (classSound, 0, U"Write to AIFC file...", U"*Save as AIFC file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsAifcFile);
  2004. praat_addAction1 (classSound, 0, U"Save as Next/Sun file...", nullptr, 0, SAVE_Sound_saveAsNextSunFile);
  2005. praat_addAction1 (classSound, 0, U"Write to Next/Sun file...", U"*Save as Next/Sun file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsNextSunFile);
  2006. praat_addAction1 (classSound, 0, U"Save as Sun audio file...", nullptr, praat_HIDDEN, SAVE_Sound_saveAsSunAudioFile);
  2007. praat_addAction1 (classSound, 0, U"Write to Sun audio file...", U"*Save as Sun audio file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsSunAudioFile);
  2008. praat_addAction1 (classSound, 0, U"Save as NIST file...", nullptr, 0, SAVE_Sound_saveAsNistFile);
  2009. praat_addAction1 (classSound, 0, U"Write to NIST file...", U"*Save as NIST file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsNistFile);
  2010. praat_addAction1 (classSound, 0, U"Save as FLAC file...", nullptr, 0, SAVE_Sound_saveAsFlacFile);
  2011. praat_addAction1 (classSound, 0, U"Write to FLAC file...", U"*Save as FLAC file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsFlacFile);
  2012. praat_addAction1 (classSound, 1, U"Save as Kay sound file...", nullptr, 0, SAVE_Sound_saveAsKayFile);
  2013. praat_addAction1 (classSound, 1, U"Write to Kay sound file...", U"*Save as Kay sound file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsKayFile);
  2014. praat_addAction1 (classSound, 1, U"Save as Sesam file...", nullptr, praat_HIDDEN, SAVE_Sound_saveAsSesamFile);
  2015. praat_addAction1 (classSound, 1, U"Write to Sesam file...", U"*Save as Sesam file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsSesamFile);
  2016. praat_addAction1 (classSound, 0, U"Save as 24-bit WAV file...", nullptr, 0, SAVE_Sound_saveAs24BitWavFile);
  2017. praat_addAction1 (classSound, 0, U"Save as 32-bit WAV file...", nullptr, 0, SAVE_Sound_saveAs32BitWavFile);
  2018. praat_addAction1 (classSound, 2, U"Write to stereo WAV file...", U"* \"Combine to stereo\" and \"Save to WAV file...\"", praat_DEPRECATED_2007, SAVE_Sound_saveAsStereoWavFile);
  2019. praat_addAction1 (classSound, 2, U"Write to stereo AIFF file...", U"* \"Combine to stereo\" and \"Save to AIFF file...\"", praat_DEPRECATED_2007, SAVE_Sound_saveAsStereoAiffFile);
  2020. praat_addAction1 (classSound, 2, U"Write to stereo AIFC file...", U"* \"Combine to stereo\" and \"Save to AIFC file...\"", praat_DEPRECATED_2007, SAVE_Sound_saveAsStereoAifcFile);
  2021. praat_addAction1 (classSound, 2, U"Write to stereo Next/Sun file...", U"* \"Combine to stereo\" and \"Save to Next/Sun file...\"", praat_DEPRECATED_2007, SAVE_Sound_saveAsStereoNextSunFile);
  2022. praat_addAction1 (classSound, 2, U"Write to stereo NIST file...", U"* \"Combine to stereo\" and \"Save to NIST file...\"", praat_DEPRECATED_2007, SAVE_Sound_saveAsStereoNistFile);
  2023. praat_addAction1 (classSound, 2, U"Write to stereo FLAC file...", U"* \"Combine to stereo\" and \"Save to FLAC file...\"", praat_DEPRECATED_2007, SAVE_Sound_saveAsStereoFlacFile);
  2024. //praat_addAction1 (classSound, 1, U"Save as raw sound file", nullptr, 0, nullptr);
  2025. praat_addAction1 (classSound, 1, U"Save as raw 8-bit signed file...", nullptr, 0, SAVE_Sound_saveAsRaw8bitSignedFile);
  2026. praat_addAction1 (classSound, 1, U"Write to raw 8-bit signed file...", U"*Save as raw 8-bit signed file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsRaw8bitSignedFile);
  2027. praat_addAction1 (classSound, 1, U"Save as raw 8-bit unsigned file...", nullptr, 0, SAVE_Sound_saveAsRaw8bitUnsignedFile);
  2028. praat_addAction1 (classSound, 1, U"Write to raw 8-bit unsigned file...", U"*Save as raw 8-bit unsigned file...", praat_DEPRECATED_2011, SAVE_Sound_saveAsRaw8bitUnsignedFile);
  2029. praat_addAction1 (classSound, 1, U"Save as raw 16-bit big-endian file...", nullptr, 0, SAVE_Sound_saveAsRaw16bitBigEndianFile);
  2030. praat_addAction1 (classSound, 1, U"Save as raw 16-bit little-endian file...", nullptr, 0, SAVE_Sound_saveAsRaw16bitLittleEndianFile);
  2031. praat_addAction1 (classSound, 1, U"Save as raw 24-bit big-endian file...", nullptr, 0, SAVE_Sound_saveAsRaw24bitBigEndianFile);
  2032. praat_addAction1 (classSound, 1, U"Save as raw 24-bit little-endian file...", nullptr, 0, SAVE_Sound_saveAsRaw24bitLittleEndianFile);
  2033. praat_addAction1 (classSound, 1, U"Save as raw 32-bit big-endian file...", nullptr, 0, SAVE_Sound_saveAsRaw32bitBigEndianFile);
  2034. praat_addAction1 (classSound, 1, U"Save as raw 32-bit little-endian file...", nullptr, 0, SAVE_Sound_saveAsRaw32bitLittleEndianFile);
  2035. praat_addAction1 (classSound, 0, U"Sound help", nullptr, 0, HELP_Sound_help);
  2036. praat_addAction1 (classSound, 1, U"View & Edit", 0, praat_ATTRACTIVE | praat_NO_API, WINDOW_Sound_viewAndEdit);
  2037. praat_addAction1 (classSound, 1, U"Edit", U"*View & Edit", praat_DEPRECATED_2011 | praat_NO_API, WINDOW_Sound_viewAndEdit);
  2038. praat_addAction1 (classSound, 1, U"Open", U"*View & Edit", praat_DEPRECATED_2011 | praat_NO_API, WINDOW_Sound_viewAndEdit);
  2039. praat_addAction1 (classSound, 0, U"Play", nullptr, 0, PLAY_Sound_play);
  2040. praat_addAction1 (classSound, 1, U"Draw -", nullptr, 0, nullptr);
  2041. praat_addAction1 (classSound, 0, U"Draw...", nullptr, 1, GRAPHICS_Sound_draw);
  2042. praat_addAction1 (classSound, 1, U"Query -", nullptr, 0, nullptr);
  2043. praat_TimeFunction_query_init (classSound);
  2044. praat_addAction1 (classSound, 1, U"Get number of channels", nullptr, 1, INTEGER_Sound_getNumberOfChannels);
  2045. praat_addAction1 (classSound, 1, U"Query time sampling", nullptr, 1, nullptr);
  2046. praat_addAction1 (classSound, 1, U"Get number of samples", nullptr, 2, INTEGER_Sound_getNumberOfSamples);
  2047. praat_addAction1 (classSound, 1, U"Get sampling period", nullptr, 2, REAL_Sound_getSamplePeriod);
  2048. praat_addAction1 (classSound, 1, U"Get sample duration", U"*Get sampling period", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_Sound_getSamplePeriod);
  2049. praat_addAction1 (classSound, 1, U"Get sample period", U"*Get sampling period", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_Sound_getSamplePeriod);
  2050. praat_addAction1 (classSound, 1, U"Get sampling frequency", nullptr, 2, REAL_Sound_getSampleRate);
  2051. praat_addAction1 (classSound, 1, U"Get sample rate", U"*Get sampling frequency", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_Sound_getSampleRate);
  2052. praat_addAction1 (classSound, 1, U"-- get time discretization --", nullptr, 2, nullptr);
  2053. praat_addAction1 (classSound, 1, U"Get time from sample number...", nullptr, 2, REAL_Sound_getTimeFromIndex);
  2054. praat_addAction1 (classSound, 1, U"Get time from index...", U"*Get time from sample number...", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_Sound_getTimeFromIndex);
  2055. praat_addAction1 (classSound, 1, U"Get sample times", nullptr, 2, NUMVEC_Sound_getSampleTimes);
  2056. praat_addAction1 (classSound, 1, U"Get sample number from time...", nullptr, 2, REAL_Sound_getIndexFromTime);
  2057. praat_addAction1 (classSound, 1, U"Get index from time...", U"*Get sample number from time...", praat_DEPTH_2 | praat_DEPRECATED_2004, REAL_Sound_getIndexFromTime);
  2058. praat_addAction1 (classSound, 1, U"-- get content --", nullptr, 1, nullptr);
  2059. praat_addAction1 (classSound, 1, U"Get value at time...", nullptr, 1, REAL_Sound_getValueAtTime);
  2060. praat_addAction1 (classSound, 1, U"Get value at sample number...", nullptr, 1, REAL_Sound_getValueAtIndex);
  2061. praat_addAction1 (classSound, 1, U"Get value at index...", U"*Get value at sample number...", praat_DEPTH_1 | praat_DEPRECATED_2004, REAL_Sound_getValueAtIndex);
  2062. praat_addAction1 (classSound, 1, U"-- get shape --", nullptr, 1, nullptr);
  2063. praat_addAction1 (classSound, 1, U"Get minimum...", nullptr, 1, REAL_Sound_getMinimum);
  2064. praat_addAction1 (classSound, 1, U"Get time of minimum...", nullptr, 1, REAL_Sound_getTimeOfMinimum);
  2065. praat_addAction1 (classSound, 1, U"Get maximum...", nullptr, 1, REAL_Sound_getMaximum);
  2066. praat_addAction1 (classSound, 1, U"Get time of maximum...", nullptr, 1, REAL_Sound_getTimeOfMaximum);
  2067. praat_addAction1 (classSound, 1, U"Get absolute extremum...", nullptr, 1, REAL_Sound_getAbsoluteExtremum);
  2068. praat_addAction1 (classSound, 1, U"Get nearest zero crossing...", nullptr, 1, REAL_Sound_getNearestZeroCrossing);
  2069. praat_addAction1 (classSound, 1, U"-- get statistics --", nullptr, 1, nullptr);
  2070. praat_addAction1 (classSound, 1, U"Get mean...", nullptr, 1, REAL_Sound_getMean);
  2071. praat_addAction1 (classSound, 1, U"Get root-mean-square...", nullptr, 1, REAL_Sound_getRootMeanSquare);
  2072. praat_addAction1 (classSound, 1, U"Get standard deviation...", nullptr, 1, REAL_Sound_getStandardDeviation);
  2073. praat_addAction1 (classSound, 1, U"-- get energy --", nullptr, 1, nullptr);
  2074. praat_addAction1 (classSound, 1, U"Get energy...", nullptr, 1, REAL_Sound_getEnergy);
  2075. praat_addAction1 (classSound, 1, U"Get power...", nullptr, 1, REAL_Sound_getPower);
  2076. praat_addAction1 (classSound, 1, U"-- get energy in air --", nullptr, 1, nullptr);
  2077. praat_addAction1 (classSound, 1, U"Get energy in air", nullptr, 1, REAL_Sound_getEnergyInAir);
  2078. praat_addAction1 (classSound, 1, U"Get power in air", nullptr, 1, REAL_Sound_getPowerInAir);
  2079. praat_addAction1 (classSound, 1, U"Get intensity (dB)", nullptr, 1, REAL_Sound_getIntensity_dB);
  2080. praat_addAction1 (classSound, 0, U"Modify -", nullptr, 0, nullptr);
  2081. praat_TimeFunction_modify_init (classSound);
  2082. praat_addAction1 (classSound, 0, U"-- modify generic --", nullptr, 1, nullptr);
  2083. praat_addAction1 (classSound, 0, U"Reverse", nullptr, 1, MODIFY_Sound_reverse);
  2084. praat_addAction1 (classSound, 0, U"Formula...", nullptr, 1, MODIFY_Sound_formula);
  2085. praat_addAction1 (classSound, 0, U"Formula (part)...", nullptr, 1, MODIFY_Sound_formula_part);
  2086. praat_addAction1 (classSound, 0, U"-- add & mul --", nullptr, 1, nullptr);
  2087. praat_addAction1 (classSound, 0, U"Add...", nullptr, 1, MODIFY_Sound_add);
  2088. praat_addAction1 (classSound, 0, U"Subtract mean", nullptr, 1, MODIFY_Sound_subtractMean);
  2089. praat_addAction1 (classSound, 0, U"Multiply...", nullptr, 1, MODIFY_Sound_multiply);
  2090. praat_addAction1 (classSound, 0, U"Multiply by window...", nullptr, 1, MODIFY_Sound_multiplyByWindow);
  2091. praat_addAction1 (classSound, 0, U"Scale peak...", nullptr, 1, MODIFY_Sound_scalePeak);
  2092. praat_addAction1 (classSound, 0, U"Scale...", nullptr, praat_DEPTH_1 | praat_DEPRECATED_2004, MODIFY_Sound_scalePeak);
  2093. praat_addAction1 (classSound, 0, U"Scale intensity...", nullptr, 1, MODIFY_Sound_scaleIntensity);
  2094. praat_addAction1 (classSound, 0, U"-- set --", nullptr, 1, nullptr);
  2095. praat_addAction1 (classSound, 0, U"Set value at sample number...", nullptr, 1, MODIFY_Sound_setValueAtIndex);
  2096. praat_addAction1 (classSound, 0, U"Set value at index...", U"*Set value at sample number...", praat_DEPTH_1 | praat_DEPRECATED_2004, MODIFY_Sound_setValueAtIndex);
  2097. praat_addAction1 (classSound, 0, U"Set part to zero...", nullptr, 1, MODIFY_Sound_setPartToZero);
  2098. praat_addAction1 (classSound, 0, U"-- modify hack --", nullptr, 1, nullptr);
  2099. praat_addAction1 (classSound, 0, U"Override sampling frequency...", nullptr, 1, MODIFY_Sound_overrideSamplingFrequency);
  2100. praat_addAction1 (classSound, 0, U"Override sample rate...", U"*Override sampling frequency...", praat_DEPTH_1 | praat_DEPRECATED_2004, MODIFY_Sound_overrideSamplingFrequency);
  2101. praat_addAction1 (classSound, 0, U"-- in-place filters --", nullptr, 1, nullptr);
  2102. praat_addAction1 (classSound, 0, U"In-place filters", nullptr, 1, nullptr);
  2103. praat_addAction1 (classSound, 0, U"Filter with one formant (in-place)...", nullptr, 2, MODIFY_Sound_filterWithOneFormantInplace);
  2104. praat_addAction1 (classSound, 0, U"Filter with one formant (in-line)...", nullptr, praat_DEPTH_2 | praat_DEPRECATED_2017, MODIFY_Sound_filterWithOneFormantInplace);
  2105. praat_addAction1 (classSound, 0, U"Pre-emphasize (in-place)...", nullptr, 2, MODIFY_Sound_preemphasizeInplace);
  2106. praat_addAction1 (classSound, 0, U"Pre-emphasize (in-line)...", nullptr, praat_DEPTH_2 | praat_DEPRECATED_2017, MODIFY_Sound_preemphasizeInplace);
  2107. praat_addAction1 (classSound, 0, U"De-emphasize (in-place)...", nullptr, 2, MODIFY_Sound_deemphasizeInplace);
  2108. praat_addAction1 (classSound, 0, U"De-emphasize (in-line)...", nullptr, praat_DEPTH_2 | praat_DEPRECATED_2017, MODIFY_Sound_deemphasizeInplace);
  2109. praat_addAction1 (classSound, 0, U"Annotate -", nullptr, 0, nullptr);
  2110. praat_addAction1 (classSound, 0, U"Annotation tutorial", nullptr, 1, HELP_AnnotationTutorial);
  2111. praat_addAction1 (classSound, 0, U"-- to text grid --", nullptr, 1, nullptr);
  2112. praat_addAction1 (classSound, 0, U"To TextGrid...", nullptr, 1, NEW_Sound_to_TextGrid);
  2113. praat_addAction1 (classSound, 0, U"To TextTier", nullptr, praat_DEPTH_1 | praat_HIDDEN, NEW_Sound_to_TextTier);
  2114. praat_addAction1 (classSound, 0, U"To IntervalTier", nullptr, praat_DEPTH_1 | praat_HIDDEN, NEW_Sound_to_IntervalTier);
  2115. praat_addAction1 (classSound, 0, U"Analyse periodicity -", nullptr, 0, nullptr);
  2116. praat_addAction1 (classSound, 0, U"To Pitch...", nullptr, 1, NEW_Sound_to_Pitch);
  2117. praat_addAction1 (classSound, 0, U"To Pitch (ac)...", nullptr, 1, NEW_Sound_to_Pitch_ac);
  2118. praat_addAction1 (classSound, 0, U"To Pitch (cc)...", nullptr, 1, NEW_Sound_to_Pitch_cc);
  2119. praat_addAction1 (classSound, 0, U"To PointProcess (periodic, cc)...", nullptr, 1, NEW_Sound_to_PointProcess_periodic_cc);
  2120. praat_addAction1 (classSound, 0, U"To PointProcess (periodic, peaks)...", nullptr, 1, NEW_Sound_to_PointProcess_periodic_peaks);
  2121. praat_addAction1 (classSound, 0, U"-- points --", nullptr, 1, nullptr);
  2122. praat_addAction1 (classSound, 0, U"To PointProcess (extrema)...", nullptr, 1, NEW_Sound_to_PointProcess_extrema);
  2123. praat_addAction1 (classSound, 0, U"To PointProcess (zeroes)...", nullptr, 1, NEW_Sound_to_PointProcess_zeroes);
  2124. praat_addAction1 (classSound, 0, U"-- hnr --", nullptr, 1, nullptr);
  2125. praat_addAction1 (classSound, 0, U"To Harmonicity (cc)...", nullptr, 1, NEW_Sound_to_Harmonicity_cc);
  2126. praat_addAction1 (classSound, 0, U"To Harmonicity (ac)...", nullptr, 1, NEW_Sound_to_Harmonicity_ac);
  2127. praat_addAction1 (classSound, 0, U"To Harmonicity (gne)...", nullptr, 1, NEW_Sound_to_Harmonicity_gne);
  2128. praat_addAction1 (classSound, 0, U"-- autocorrelation --", nullptr, 1, nullptr);
  2129. praat_addAction1 (classSound, 0, U"Autocorrelate...", nullptr, 1, NEW_Sound_autoCorrelate);
  2130. praat_addAction1 (classSound, 0, U"Analyse spectrum -", nullptr, 0, nullptr);
  2131. praat_addAction1 (classSound, 0, U"To Spectrum...", nullptr, 1, NEW_Sound_to_Spectrum);
  2132. praat_addAction1 (classSound, 0, U"To Spectrum (fft)", U"*To Spectrum...", praat_DEPTH_1 | praat_DEPRECATED_2004, NEW_Sound_to_Spectrum_fft);
  2133. praat_addAction1 (classSound, 0, U"To Spectrum", U"*To Spectrum...", praat_DEPTH_1 | praat_DEPRECATED_2004, NEW_Sound_to_Spectrum_fft);
  2134. praat_addAction1 (classSound, 0, U"To Spectrum (dft)", U"*To Spectrum...", praat_DEPTH_1 | praat_DEPRECATED_2004, NEW_Sound_to_Spectrum_dft);
  2135. praat_addAction1 (classSound, 0, U"To Ltas...", nullptr, 1, NEW_Sound_to_Ltas);
  2136. praat_addAction1 (classSound, 0, U"To Ltas (pitch-corrected)...", nullptr, 1, NEW_Sound_to_Ltas_pitchCorrected);
  2137. praat_addAction1 (classSound, 0, U"-- spectrotemporal --", nullptr, 1, nullptr);
  2138. praat_addAction1 (classSound, 0, U"To Spectrogram...", nullptr, 1, NEW_Sound_to_Spectrogram);
  2139. praat_addAction1 (classSound, 0, U"To Cochleagram...", nullptr, 1, NEW_Sound_to_Cochleagram);
  2140. praat_addAction1 (classSound, 0, U"To Cochleagram (edb)...", nullptr, praat_DEPTH_1 | praat_HIDDEN, NEW_Sound_to_Cochleagram_edb);
  2141. praat_addAction1 (classSound, 0, U"-- formants --", nullptr, 1, nullptr);
  2142. praat_addAction1 (classSound, 0, U"To Formant (burg)...", nullptr, 1, NEW_Sound_to_Formant_burg);
  2143. praat_addAction1 (classSound, 0, U"To Formant (hack)", nullptr, 1, nullptr);
  2144. praat_addAction1 (classSound, 0, U"To Formant (keep all)...", nullptr, 2, NEW_Sound_to_Formant_keepAll);
  2145. praat_addAction1 (classSound, 0, U"To Formant (sl)...", nullptr, 2, NEW_Sound_to_Formant_willems);
  2146. praat_addAction1 (classSound, 0, U"To Intensity...", nullptr, 0, NEW_Sound_to_Intensity);
  2147. praat_addAction1 (classSound, 0, U"To IntensityTier...", nullptr, praat_HIDDEN, NEW_Sound_to_IntensityTier);
  2148. praat_addAction1 (classSound, 0, U"Manipulate -", nullptr, 0, nullptr);
  2149. praat_addAction1 (classSound, 0, U"To Manipulation...", nullptr, 1, NEW_Sound_to_Manipulation);
  2150. praat_addAction1 (classSound, 0, U"Convert -", nullptr, 0, nullptr);
  2151. praat_addAction1 (classSound, 0, U"Convert to mono", nullptr, 1, NEW_Sound_convertToMono);
  2152. praat_addAction1 (classSound, 0, U"Convert to stereo", nullptr, 1, NEW_Sound_convertToStereo);
  2153. praat_addAction1 (classSound, 0, U"Extract all channels", nullptr, 1, NEWMANY_Sound_extractAllChannels);
  2154. praat_addAction1 (classSound, 0, U"Extract one channel...", nullptr, 1, NEW_Sound_extractChannel);
  2155. praat_addAction1 (classSound, 0, U"Extract left channel", U"*Extract one channel...", praat_DEPTH_1 | praat_DEPRECATED_2010, NEW_Sound_extractLeftChannel);
  2156. praat_addAction1 (classSound, 0, U"Extract right channel", U"*Extract one channel...", praat_DEPTH_1 | praat_DEPRECATED_2010, NEW_Sound_extractRightChannel);
  2157. praat_addAction1 (classSound, 0, U"Extract channels...", nullptr, 1, NEW_Sound_extractChannels);
  2158. praat_addAction1 (classSound, 0, U"Extract part...", nullptr, 1, NEW_Sound_extractPart);
  2159. praat_addAction1 (classSound, 0, U"Extract part for overlap...", nullptr, 1, NEW_Sound_extractPartForOverlap);
  2160. praat_addAction1 (classSound, 0, U"Resample...", nullptr, 1, NEW_Sound_resample);
  2161. praat_addAction1 (classSound, 0, U"-- enhance --", nullptr, 1, nullptr);
  2162. praat_addAction1 (classSound, 0, U"Lengthen (overlap-add)...", nullptr, 1, NEW_Sound_lengthen_overlapAdd);
  2163. praat_addAction1 (classSound, 0, U"Lengthen (PSOLA)...", U"*Lengthen (overlap-add)...", praat_DEPTH_1 | praat_DEPRECATED_2007, NEW_Sound_lengthen_overlapAdd);
  2164. praat_addAction1 (classSound, 0, U"Deepen band modulation...", nullptr, 1, NEW_Sound_deepenBandModulation);
  2165. praat_addAction1 (classSound, 0, U"-- cast --", nullptr, 1, nullptr);
  2166. praat_addAction1 (classSound, 0, U"Down to Matrix", nullptr, 1, NEW_Sound_downto_Matrix);
  2167. praat_addAction1 (classSound, 0, U"Filter -", nullptr, 0, nullptr);
  2168. praat_addAction1 (classSound, 0, U"Filtering tutorial", nullptr, 1, HELP_FilteringTutorial);
  2169. praat_addAction1 (classSound, 0, U"-- frequency-domain filter --", nullptr, 1, nullptr);
  2170. praat_addAction1 (classSound, 0, U"Filter (pass Hann band)...", nullptr, 1, NEW_Sound_filter_passHannBand);
  2171. praat_addAction1 (classSound, 0, U"Filter (stop Hann band)...", nullptr, 1, NEW_Sound_filter_stopHannBand);
  2172. praat_addAction1 (classSound, 0, U"Filter (formula)...", nullptr, 1, NEW_Sound_filter_formula);
  2173. praat_addAction1 (classSound, 0, U"-- time-domain filter --", nullptr, 1, nullptr);
  2174. praat_addAction1 (classSound, 0, U"Filter (one formant)...", nullptr, 1, NEW_Sound_filter_oneFormant);
  2175. praat_addAction1 (classSound, 0, U"Filter (pre-emphasis)...", nullptr, 1, NEW_Sound_filter_preemphasis);
  2176. praat_addAction1 (classSound, 0, U"Filter (de-emphasis)...", nullptr, 1, NEW_Sound_filter_deemphasis);
  2177. praat_addAction1 (classSound, 0, U"Combine -", nullptr, 0, nullptr);
  2178. praat_addAction1 (classSound, 0, U"Combine to stereo", nullptr, 1, NEW1_Sounds_combineToStereo);
  2179. praat_addAction1 (classSound, 0, U"Concatenate", nullptr, 1, NEW1_Sounds_concatenate);
  2180. praat_addAction1 (classSound, 0, U"Concatenate recoverably", nullptr, 1, NEW2_Sounds_concatenateRecoverably);
  2181. praat_addAction1 (classSound, 0, U"Concatenate with overlap...", nullptr, 1, NEW1_Sounds_concatenateWithOverlap);
  2182. praat_addAction1 (classSound, 2, U"Convolve...", nullptr, 1, NEW1_Sounds_convolve);
  2183. praat_addAction1 (classSound, 2, U"Convolve", U"*Convolve...", praat_DEPTH_1 | praat_DEPRECATED_2010, NEW1_Sounds_convolve_old);
  2184. praat_addAction1 (classSound, 2, U"Cross-correlate...", nullptr, 1, NEW1_Sounds_crossCorrelate);
  2185. praat_addAction1 (classSound, 2, U"To ParamCurve", nullptr, 1, NEW1_Sounds_to_ParamCurve);
  2186. praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as WAV file...", nullptr, 0, SAVE_LongSound_Sound_saveAsWavFile);
  2187. praat_addAction2 (classLongSound, 0, classSound, 0, U"Write to WAV file...", U"*Save as WAV file...", praat_DEPRECATED_2011, SAVE_LongSound_Sound_saveAsWavFile);
  2188. praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as AIFF file...", nullptr, 0, SAVE_LongSound_Sound_saveAsAiffFile);
  2189. praat_addAction2 (classLongSound, 0, classSound, 0, U"Write to AIFF file...", U"*Save as AIFF file...", praat_DEPRECATED_2011, SAVE_LongSound_Sound_saveAsAiffFile);
  2190. praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as AIFC file...", nullptr, 0, SAVE_LongSound_Sound_saveAsAifcFile);
  2191. praat_addAction2 (classLongSound, 0, classSound, 0, U"Write to AIFC file...", U"*Save as AIFC file...", praat_DEPRECATED_2011, SAVE_LongSound_Sound_saveAsAifcFile);
  2192. praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as NeXT/Sun file...", nullptr, 0, SAVE_LongSound_Sound_saveAsNextSunFile);
  2193. praat_addAction2 (classLongSound, 0, classSound, 0, U"Write to NeXT/Sun file...", U"*Save as NeXT/Sun file...", praat_DEPRECATED_2011, SAVE_LongSound_Sound_saveAsNextSunFile);
  2194. praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as NIST file...", nullptr, 0, SAVE_LongSound_Sound_saveAsNistFile);
  2195. praat_addAction2 (classLongSound, 0, classSound, 0, U"Write to NIST file...", U"*Save as NIST file...", praat_DEPRECATED_2011, SAVE_LongSound_Sound_saveAsNistFile);
  2196. praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as FLAC file...", nullptr, 0, SAVE_LongSound_Sound_saveAsFlacFile);
  2197. praat_addAction2 (classLongSound, 0, classSound, 0, U"Write to FLAC file...", U"*Save as FLAC file...", praat_DEPRECATED_2011, SAVE_LongSound_Sound_saveAsFlacFile);
  2198. }
  2199. /* End of file praat_Sound.cpp */