| 1 | /* praat_Sound.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2026 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 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "Ltas.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_and_TextGrid_extensions.h" |
| 26 | #include "Sound_to_Cochleagram.h" |
| 27 | #include "Sound_to_Formant.h" |
| 28 | #include "Sound_to_Harmonicity.h" |
| 29 | #include "Sound_to_Intensity.h" |
| 30 | #include "Sound_to_Pitch.h" |
| 31 | #include "Sound_to_PointProcess.h" |
| 32 | #include "SoundEditor.h" |
| 33 | #include "SoundRecorder.h" |
| 34 | #include "SoundSet.h" |
| 35 | #include "SpectrumEditor.h" |
| 36 | #include "TextGrid_Sound.h" |
| 37 | #include "mp3.h" |
| 38 | #include "SpeechRecognizer.h" |
| 39 | |
| 40 | #include "praat_Sound.h" |
| 41 | |
| 42 | /***** LONGSOUND *****/ |
| 43 | |
| 44 | DIRECT (INFO_NONE__LongSound_concatenate) { |
| 45 | INFO_NONE |
| 46 | Melder_information (U"To concatenate LongSound objects, " |
| 47 | "select them in the list\nand choose \"Save as WAV file...\" or a similar command.\n" |
| 48 | "The result will be a sound file that contains\nthe concatenation of the selected sounds." |
| 49 | ); |
| 50 | INFO_NONE_END |
| 51 | } |
| 52 | |
| 53 | FORM (NEW_LongSound_extractPart, U"LongSound: Extract part", U"LongSound: Extract part...") { |
| 54 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 55 | REAL (toTime, U"right Time range (s)", U"1.0") |
| 56 | BOOLEAN (preserveTimes, U"Preserve times", true) |
| 57 | OK |
| 58 | DO |
| 59 | CONVERT_EACH_TO_ONE (LongSound) |
| 60 | autoSound result = LongSound_extractPart (me, fromTime, toTime, preserveTimes); |
| 61 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 62 | } |
| 63 | |
| 64 | FORM (REAL_LongSound_getIndexFromTime, U"LongSound: Get sample index from time", U"Sound: Get index from time...") { |
| 65 | REAL (time, U"Time (s)", U"0.5") |
| 66 | OK |
| 67 | DO |
| 68 | QUERY_ONE_FOR_REAL (LongSound) |
| 69 | const double result = Sampled_xToIndex (me, time); |
| 70 | QUERY_ONE_FOR_REAL_END (U" (index at ", time, U" seconds)") |
| 71 | } |
| 72 | |
| 73 | DIRECT (REAL_LongSound_getSamplePeriod) { |
| 74 | QUERY_ONE_FOR_REAL (LongSound) |
| 75 | const double result = my dx; |
| 76 | QUERY_ONE_FOR_REAL_END (U" seconds"); |
| 77 | } |
| 78 | |
| 79 | DIRECT (REAL_LongSound_getSampleRate) { |
| 80 | QUERY_ONE_FOR_REAL (LongSound) |
| 81 | const double result = 1.0 / my dx; |
| 82 | QUERY_ONE_FOR_REAL_END (U" Hz") |
| 83 | } |
| 84 | |
| 85 | FORM (REAL_LongSound_getTimeFromIndex, U"LongSound: Get time from sample index", U"Sound: Get time from index...") { |
| 86 | INTEGER (sampleIndex, U"Sample index", U"100") |
| 87 | OK |
| 88 | DO |
| 89 | QUERY_ONE_FOR_REAL (LongSound) |
| 90 | const double result = Sampled_indexToX (me, sampleIndex); |
| 91 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 92 | } |
| 93 | |
| 94 | DIRECT (INTEGER_LongSound_getNumberOfSamples) { |
| 95 | QUERY_ONE_FOR_REAL (LongSound) |
| 96 | const integer result = my nx; |
| 97 | QUERY_ONE_FOR_REAL_END (U" samples") |
| 98 | } |
| 99 | |
| 100 | DIRECT (HELP__LongSound_help) { |
| 101 | HELP (U"LongSound") |
| 102 | } |
| 103 | |
| 104 | FORM_READ (READ_ONE__LongSound_open, U"Open long sound file", nullptr, true) { |
| 105 | READ_ONE |
| 106 | autoLongSound result = LongSound_open (file); |
| 107 | READ_ONE_END |
| 108 | } |
| 109 | |
| 110 | FORM (PLAY_LongSound_playPart, U"LongSound: Play part", nullptr) { |
| 111 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 112 | REAL (toTime, U"right Time range (s)", U"10.0") |
| 113 | OK |
| 114 | DO |
| 115 | PLAY_EACH (LongSound) |
| 116 | LongSound_playPart (me, fromTime, toTime, nullptr, nullptr); |
| 117 | PLAY_EACH_END |
| 118 | } |
| 119 | |
| 120 | FORM (SAVE_ONE__LongSound_savePartAsAudioFile, U"LongSound: Save part as audio file", nullptr) { |
| 121 | OUTFILE (audioFileName, U"Audio file", U"") |
| 122 | CHOICE (type, U"Type", 3) |
| 123 | { int i; for (i = 1; i <= Melder_NUMBER_OF_AUDIO_FILE_TYPES; i ++) { |
| 124 | OPTION (Melder_audioFileTypeString (i)) |
| 125 | }} |
| 126 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 127 | REAL (toTime, U"right Time range (s)", U"10.0") |
| 128 | OK |
| 129 | DO |
| 130 | SAVE_ONE_BY_NAME (LongSound, audioFileName, U"save part of the selected LongSound object to the audio file") |
| 131 | LongSound_savePartAsAudioFile (me, type, fromTime, toTime, & file, 16); |
| 132 | SAVE_ONE_BY_NAME_END |
| 133 | } |
| 134 | |
| 135 | FORM (NEW_LongSound_to_TextGrid, U"LongSound: To TextGrid...", U"LongSound: To TextGrid...") { |
| 136 | SENTENCE (tierNames, U"Tier names", U"Mary John bell") |
| 137 | SENTENCE (pointTiers, U"Point tiers", U"bell") |
| 138 | OK |
| 139 | DO |
| 140 | CONVERT_EACH_TO_ONE (LongSound) |
| 141 | autoTextGrid result = TextGrid_create (my xmin, my xmax, tierNames, pointTiers); |
| 142 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 143 | } |
| 144 | |
| 145 | DIRECT (EDITOR_ONE__LongSound_view) { |
| 146 | EDITOR_ONE (a,LongSound) |
| 147 | autoSoundEditor editor = SoundEditor_create (ID_AND_FULL_NAME, me); |
| 148 | EDITOR_ONE_END |
| 149 | } |
| 150 | |
| 151 | FORM_SAVE (SAVE_ALL__LongSound_saveAsAifcFile, U"Save as AIFC file", nullptr, U"aifc") { |
| 152 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected LongSound object(s) to the AIFC file") |
| 153 | LongSound_concatenate (list.get(), file, Melder_AIFC, 16); |
| 154 | SAVE_ALL_LISTED_END |
| 155 | } |
| 156 | |
| 157 | FORM_SAVE (SAVE_ALL__LongSound_saveAsAiffFile, U"Save as AIFF file", nullptr, U"aiff") { |
| 158 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected LongSound object(s) to the AIFF file") |
| 159 | LongSound_concatenate (list.get(), file, Melder_AIFF, 16); |
| 160 | SAVE_ALL_LISTED_END |
| 161 | } |
| 162 | |
| 163 | FORM_SAVE (SAVE_ALL__LongSound_saveAsNextSunFile, U"Save as NeXT/Sun file", nullptr, U"au") { |
| 164 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected LongSound object(s) to the NeXT/Sun file") |
| 165 | LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16); |
| 166 | SAVE_ALL_LISTED_END |
| 167 | } |
| 168 | |
| 169 | FORM_SAVE (SAVE_ALL__LongSound_saveAsNistFile, U"Save as NIST file", nullptr, U"nist") { |
| 170 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected LongSound object(s) to the NIST file") |
| 171 | LongSound_concatenate (list.get(), file, Melder_NIST, 16); |
| 172 | SAVE_ALL_LISTED_END |
| 173 | } |
| 174 | |
| 175 | FORM_SAVE (SAVE_ALL__LongSound_saveAsFlacFile, U"Save as FLAC file", nullptr, U"flac") { |
| 176 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected LongSound object(s) to the FLAC file") |
| 177 | LongSound_concatenate (list.get(), file, Melder_FLAC, 16); |
| 178 | SAVE_ALL_LISTED_END |
| 179 | } |
| 180 | |
| 181 | FORM_SAVE (SAVE_ALL__LongSound_saveAsWavFile, U"Save as WAV file", nullptr, U"wav") { |
| 182 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected LongSound object(s) to the WAV file") |
| 183 | LongSound_concatenate (list.get(), file, Melder_WAV, 16); |
| 184 | SAVE_ALL_LISTED_END |
| 185 | } |
| 186 | |
| 187 | FORM_SAVE (SAVE_ONE__LongSound_saveLeftChannelAsAifcFile, U"Save left channel as AIFC file", nullptr, U"aifc") { |
| 188 | SAVE_ONE (LongSound, U"save the left channel of the selected LongSound object to the AIFC file") |
| 189 | LongSound_saveChannelAsAudioFile (me, Melder_AIFC, 0, file); |
| 190 | SAVE_ONE_END |
| 191 | } |
| 192 | |
| 193 | FORM_SAVE (SAVE_ONE__LongSound_saveLeftChannelAsAiffFile, U"Save left channel as AIFF file", nullptr, U"aiff") { |
| 194 | SAVE_ONE (LongSound, U"save the left channel of the selected LongSound object to the AIFF file") |
| 195 | LongSound_saveChannelAsAudioFile (me, Melder_AIFF, 0, file); |
| 196 | SAVE_ONE_END |
| 197 | } |
| 198 | |
| 199 | FORM_SAVE (SAVE_ONE__LongSound_saveLeftChannelAsNextSunFile, U"Save left channel as NeXT/Sun file", nullptr, U"au") { |
| 200 | SAVE_ONE (LongSound, U"save the left channel of the selected LongSound object to the NeXT/Sun file") |
| 201 | LongSound_saveChannelAsAudioFile (me, Melder_NEXT_SUN, 0, file); |
| 202 | SAVE_ONE_END |
| 203 | } |
| 204 | |
| 205 | FORM_SAVE (SAVE_ONE__LongSound_saveLeftChannelAsNistFile, U"Save left channel as NIST file", nullptr, U"nist") { |
| 206 | SAVE_ONE (LongSound, U"save the left channel of the selected LongSound object to the NIST file") |
| 207 | LongSound_saveChannelAsAudioFile (me, Melder_NIST, 0, file); |
| 208 | SAVE_ONE_END |
| 209 | } |
| 210 | |
| 211 | FORM_SAVE (SAVE_ONE__LongSound_saveLeftChannelAsFlacFile, U"Save left channel as FLAC file", nullptr, U"flac") { |
| 212 | SAVE_ONE (LongSound, U"save the left channel of the selected LongSound object to the FLAC file") |
| 213 | LongSound_saveChannelAsAudioFile (me, Melder_FLAC, 0, file); |
| 214 | SAVE_ONE_END |
| 215 | } |
| 216 | |
| 217 | FORM_SAVE (SAVE_ONE__LongSound_saveLeftChannelAsWavFile, U"Save left channel as WAV file", nullptr, U"wav") { |
| 218 | SAVE_ONE (LongSound, U"save the left channel of the selected LongSound object to the WAV file") |
| 219 | LongSound_saveChannelAsAudioFile (me, Melder_WAV, 0, file); |
| 220 | SAVE_ONE_END |
| 221 | } |
| 222 | |
| 223 | FORM_SAVE (SAVE_ONE__LongSound_saveRightChannelAsAifcFile, U"Save right channel as AIFC file", nullptr, U"aifc") { |
| 224 | SAVE_ONE (LongSound, U"save the right channel of the selected LongSound object to the AIFC file") |
| 225 | LongSound_saveChannelAsAudioFile (me, Melder_AIFC, 1, file); |
| 226 | SAVE_ONE_END |
| 227 | } |
| 228 | |
| 229 | FORM_SAVE (SAVE_ONE__LongSound_saveRightChannelAsAiffFile, U"Save right channel as AIFF file", nullptr, U"aiff") { |
| 230 | SAVE_ONE (LongSound, U"save the right channel of the selected LongSound object to the AIFF file") |
| 231 | LongSound_saveChannelAsAudioFile (me, Melder_AIFF, 1, file); |
| 232 | SAVE_ONE_END |
| 233 | } |
| 234 | |
| 235 | FORM_SAVE (SAVE_ONE__LongSound_saveRightChannelAsNextSunFile, U"Save right channel as NeXT/Sun file", nullptr, U"au") { |
| 236 | SAVE_ONE (LongSound, U"save the right channel of the selected LongSound object to the NeXT/Sun file") |
| 237 | LongSound_saveChannelAsAudioFile (me, Melder_NEXT_SUN, 1, file); |
| 238 | SAVE_ONE_END |
| 239 | } |
| 240 | |
| 241 | FORM_SAVE (SAVE_ONE__LongSound_saveRightChannelAsNistFile, U"Save right channel as NIST file", nullptr, U"nist") { |
| 242 | SAVE_ONE (LongSound, U"save the right channel of the selected LongSound object to the NIST file") |
| 243 | LongSound_saveChannelAsAudioFile (me, Melder_NIST, 1, file); |
| 244 | SAVE_ONE_END |
| 245 | } |
| 246 | |
| 247 | FORM_SAVE (SAVE_ONE__LongSound_saveRightChannelAsFlacFile, U"Save right channel as FLAC file", 0, U"flac") { |
| 248 | SAVE_ONE (LongSound, U"save the right channel of the selected LongSound object to the FLAC file") |
| 249 | LongSound_saveChannelAsAudioFile (me, Melder_FLAC, 1, file); |
| 250 | SAVE_ONE_END |
| 251 | } |
| 252 | |
| 253 | FORM_SAVE (SAVE_ONE__LongSound_saveRightChannelAsWavFile, U"Save right channel as WAV file", 0, U"wav") { |
| 254 | SAVE_ONE (LongSound, U"save the right channel of the selected LongSound object to the WAV file") |
| 255 | LongSound_saveChannelAsAudioFile (me, Melder_WAV, 1, file); |
| 256 | SAVE_ONE_END |
| 257 | } |
| 258 | |
| 259 | FORM (SETTINGS__LongSoundSettings, U"LongSound settings", U"LongSound") { |
| 260 | COMMENT (U"This setting determines the maximum number of seconds") |
| 261 | COMMENT (U"for viewing the waveform and playing a sound in the LongSound window.") |
| 262 | COMMENT (U"The LongSound window can become very slow if you set it too high.") |
| 263 | NATURAL (maximumViewablePart, U"Maximum viewable part (seconds)", U"60") |
| 264 | COMMENT (U"Note: this setting works for the next long sound file that you open,") |
| 265 | COMMENT (U"not for currently existing LongSound objects.") |
| 266 | OK |
| 267 | SET_INTEGER (maximumViewablePart, LongSound_getBufferSizePref_seconds ()) |
| 268 | DO |
| 269 | PREFS |
| 270 | LongSound_setBufferSizePref_seconds (maximumViewablePart); |
| 271 | PREFS_END |
| 272 | } |
| 273 | |
| 274 | /********** LONGSOUND & SOUND **********/ |
| 275 | |
| 276 | FORM_SAVE (SAVE_ALL__LongSound_Sound_saveAsAifcFile, U"Save as AIFC file", nullptr, U"aifc") { |
| 277 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected (Long)Sound object(s) to the AIFC file") |
| 278 | LongSound_concatenate (list.get(), file, Melder_AIFC, 16); |
| 279 | SAVE_ALL_LISTED_END |
| 280 | } |
| 281 | |
| 282 | FORM_SAVE (SAVE_ALL__LongSound_Sound_saveAsAiffFile, U"Save as AIFF file", nullptr, U"aiff") { |
| 283 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected (Long)Sound object(s) to the AIFF file") |
| 284 | LongSound_concatenate (list.get(), file, Melder_AIFF, 16); |
| 285 | SAVE_ALL_LISTED_END |
| 286 | } |
| 287 | |
| 288 | FORM_SAVE (SAVE_ALL__LongSound_Sound_saveAsNextSunFile, U"Save as NeXT/Sun file", nullptr, U"au") { |
| 289 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected (Long)Sound object(s) to the NeXT/Sun file") |
| 290 | LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16); |
| 291 | SAVE_ALL_LISTED_END |
| 292 | } |
| 293 | |
| 294 | FORM_SAVE (SAVE_ALL__LongSound_Sound_saveAsNistFile, U"Save as NIST file", nullptr, U"nist") { |
| 295 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected (Long)Sound object(s) to the NIST file") |
| 296 | LongSound_concatenate (list.get(), file, Melder_NIST, 16); |
| 297 | SAVE_ALL_LISTED_END |
| 298 | } |
| 299 | |
| 300 | FORM_SAVE (SAVE_ALL__LongSound_Sound_saveAsFlacFile, U"Save as FLAC file", nullptr, U"flac") { |
| 301 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected (Long)Sound object(s) to the FLAC file") |
| 302 | LongSound_concatenate (list.get(), file, Melder_FLAC, 16); |
| 303 | SAVE_ALL_LISTED_END |
| 304 | } |
| 305 | |
| 306 | FORM_SAVE (SAVE_ALL__LongSound_Sound_saveAsWavFile, U"Save as WAV file", nullptr, U"wav") { |
| 307 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected (Long)Sound object(s) to the WAV file") |
| 308 | LongSound_concatenate (list.get(), file, Melder_WAV, 16); |
| 309 | SAVE_ALL_LISTED_END |
| 310 | } |
| 311 | |
| 312 | /********** SOUND **********/ |
| 313 | |
| 314 | FORM (MODIFY_Sound_add, U"Sound: Add", nullptr) { |
| 315 | COMMENT (U"The following number will be added to the amplitudes of ") |
| 316 | COMMENT (U"all samples of the sound.") |
| 317 | REAL (number, U"Number", U"0.1") |
| 318 | OK |
| 319 | DO |
| 320 | MODIFY_EACH (Sound) |
| 321 | Vector_addScalar (me, number); |
| 322 | MODIFY_EACH_END |
| 323 | } |
| 324 | |
| 325 | FORM (CONVERT_EACH_TO_ONE__Sound_autoCorrelate, U"Sound: autocorrelate", U"Sound: Autocorrelate...") { |
| 326 | CHOICE_ENUM (kSounds_convolve_scaling, amplitudeScaling, |
| 327 | U"Amplitude scaling", kSounds_convolve_scaling::DEFAULT) |
| 328 | CHOICE_ENUM (kSounds_convolve_signalOutsideTimeDomain, signalOutsideTimeDomainIs, |
| 329 | U"Signal outside time domain is...", kSounds_convolve_signalOutsideTimeDomain::DEFAULT) |
| 330 | OK |
| 331 | DO |
| 332 | CONVERT_EACH_TO_ONE (Sound) |
| 333 | autoSound result = Sound_autoCorrelate (me, amplitudeScaling, signalOutsideTimeDomainIs); |
| 334 | CONVERT_EACH_TO_ONE_END (U"ac_", my name.get()) |
| 335 | } |
| 336 | |
| 337 | DIRECT (COMBINE_ALL_TO_ONE__Sounds_combineToStereo) { |
| 338 | COMBINE_ALL_TO_ONE (Sound) |
| 339 | autoSound result = Sounds_combineToStereo (& list); |
| 340 | const integer numberOfChannels = result -> ny; // dereference before transferring |
| 341 | COMBINE_ALL_TO_ONE_END (U"combined_", numberOfChannels) |
| 342 | } |
| 343 | |
| 344 | DIRECT (COMBINE_ALL_TO_ONE__Sounds_combineIntoSoundList) { |
| 345 | COMBINE_ALL_TO_ONE (Sound) |
| 346 | autoSoundList result = SoundList_create (); |
| 347 | for (integer iobject = 1; iobject <= list.size; iobject ++) |
| 348 | result -> addItem_move (Data_copy (list.at [iobject])); |
| 349 | COMBINE_ALL_TO_ONE_END (U"list") |
| 350 | } |
| 351 | |
| 352 | DIRECT (COMBINE_ALL_TO_ONE__Sounds_combineIntoSoundSet) { |
| 353 | COMBINE_ALL_TO_ONE (Sound) |
| 354 | autoSoundSet result = SoundSet_create (); |
| 355 | for (integer iobject = 1; iobject <= list.size; iobject ++) |
| 356 | result -> addItem_move (Data_copy (list.at [iobject])); |
| 357 | COMBINE_ALL_TO_ONE_END (U"ensemble") |
| 358 | } |
| 359 | |
| 360 | DIRECT (COMBINE_ALL_TO_ONE__Sounds_concatenate) { |
| 361 | COMBINE_ALL_LISTED_TO_ONE (Sound, SoundList) |
| 362 | autoSound result = Sounds_concatenate (list.get(), 0.0); |
| 363 | COMBINE_ALL_LISTED_TO_ONE_END (U"chain") |
| 364 | } |
| 365 | |
| 366 | FORM (COMBINE_ALL_TO_ONE__Sounds_concatenateWithOverlap, U"Sounds: Concatenate with overlap", U"Sounds: Concatenate with overlap...") { |
| 367 | POSITIVE (overlap, U"Overlap (s)", U"0.01") |
| 368 | OK |
| 369 | DO |
| 370 | COMBINE_ALL_LISTED_TO_ONE (Sound, SoundList) |
| 371 | autoSound result = Sounds_concatenate (list.get(), overlap); |
| 372 | COMBINE_ALL_LISTED_TO_ONE_END (U"chain") |
| 373 | } |
| 374 | |
| 375 | DIRECT (CONVERT_ALL_TO_MULTIPLE__Sounds_concatenateRecoverably) { |
| 376 | CONVERT_ALL_LISTED_TO_MULTIPLE (Sound, SoundList) |
| 377 | integer numberOfChannels = 0, nx = 0, iinterval = 0; |
| 378 | double dx = 0.0, tmin = 0.0; |
| 379 | for (integer isound = 1; isound <= list->size; isound ++) { |
| 380 | Sound me = list->at [isound]; |
| 381 | if (numberOfChannels == 0) { |
| 382 | numberOfChannels = my ny; |
| 383 | } else if (my ny != numberOfChannels) { |
| 384 | Melder_throw (U"To concatenate sounds, their numbers of channels (mono, stereo) should be equal."); |
| 385 | } |
| 386 | if (dx == 0.0) { |
| 387 | dx = my dx; |
| 388 | } else if (my dx != dx) { |
| 389 | Melder_throw (U"To concatenate sounds, their sampling frequencies should be equal.\n" |
| 390 | "You could resample one or more of the sounds before concatenating."); |
| 391 | } |
| 392 | nx += my nx; |
| 393 | } |
| 394 | autoSound thee = Sound_create (numberOfChannels, 0.0, nx * dx, nx, dx, 0.5 * dx); |
| 395 | autoTextGrid him = TextGrid_create (0.0, nx * dx, U"labels", U""); |
| 396 | nx = 0; |
| 397 | for (integer isound = 1; isound <= list->size; isound ++) { |
| 398 | Sound me = list->at [isound]; |
| 399 | const double tmax = tmin + my nx * dx; |
| 400 | thy z.verticalBand (nx + 1, nx + my nx) <<= my z.all(); |
| 401 | iinterval ++; |
| 402 | if (iinterval > 1) |
| 403 | TextGrid_insertBoundary (him.get(), 1, tmin); |
| 404 | TextGrid_setIntervalText (him.get(), 1, iinterval, my name.get()); |
| 405 | nx += my nx; |
| 406 | tmin = tmax; |
| 407 | } |
| 408 | praat_new (thee.move(), U"chain"); |
| 409 | praat_new (him.move(), U"chain"); |
| 410 | CONVERT_ALL_LISTED_TO_MULTIPLE_END |
| 411 | } |
| 412 | |
| 413 | DIRECT (CONVERT_EACH_TO_ONE__Sound_convertToMono) { |
| 414 | CONVERT_EACH_TO_ONE (Sound) |
| 415 | autoSound result = Sound_convertToMono (me); |
| 416 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_mono") |
| 417 | } |
| 418 | |
| 419 | DIRECT (CONVERT_EACH_TO_ONE__Sound_convertToStereo) { |
| 420 | CONVERT_EACH_TO_ONE (Sound) |
| 421 | autoSound result = Sound_convertToStereo (me); |
| 422 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_stereo") |
| 423 | } |
| 424 | |
| 425 | DIRECT (CONVERT_TWO_TO_ONE__Sounds_convolve_old) { |
| 426 | CONVERT_TWO_TO_ONE (Sound) |
| 427 | autoSound result = Sounds_convolve (me, you, |
| 428 | kSounds_convolve_scaling::SUM, kSounds_convolve_signalOutsideTimeDomain::ZERO); |
| 429 | CONVERT_TWO_TO_ONE_END (my name.get(), U"_", your name.get()) |
| 430 | } |
| 431 | |
| 432 | FORM (CONVERT_TWO_TO_ONE__Sounds_convolve, U"Sounds: Convolve", U"Sounds: Convolve...") { |
| 433 | CHOICE_ENUM (kSounds_convolve_scaling, amplitudeScaling, |
| 434 | U"Amplitude scaling", kSounds_convolve_scaling::DEFAULT) |
| 435 | CHOICE_ENUM (kSounds_convolve_signalOutsideTimeDomain, signalOutsideTimeDomainIs, |
| 436 | U"Signal outside time domain is...", kSounds_convolve_signalOutsideTimeDomain::DEFAULT) |
| 437 | OK |
| 438 | DO |
| 439 | CONVERT_TWO_TO_ONE (Sound) |
| 440 | autoSound result = Sounds_convolve (me, you, amplitudeScaling, signalOutsideTimeDomainIs); |
| 441 | CONVERT_TWO_TO_ONE_END (my name.get(), U"_", your name.get()) |
| 442 | } |
| 443 | |
| 444 | static autoSound common_Sound_create (integer numberOfChannels, double startTime, double endTime, |
| 445 | double samplingFrequency, conststring32 formula, Interpreter interpreter) |
| 446 | { |
| 447 | const double numberOfSamples_real = round ((endTime - startTime) * samplingFrequency); |
| 448 | if (endTime <= startTime) { |
| 449 | if (endTime == startTime) |
| 450 | Melder_appendError (U"A Sound cannot have a duration of zero."); |
| 451 | else |
| 452 | Melder_appendError (U"A Sound cannot have a duration less than zero."); |
| 453 | if (startTime == 0.0) |
| 454 | Melder_throw (U"Please set the end time to something greater than 0 seconds."); |
| 455 | else |
| 456 | Melder_throw (U"Please lower the start time or raise the end time."); |
| 457 | } |
| 458 | if (samplingFrequency <= 0.0) { |
| 459 | Melder_appendError (U"A Sound cannot have a negative sampling frequency."); |
| 460 | Melder_throw (U"Please set the sampling frequency to something greater than zero, e.g. 44100 Hz."); |
| 461 | } |
| 462 | if (numberOfChannels < 1) |
| 463 | Melder_throw (U"A Sound cannot have zero channels."); |
| 464 | if (numberOfSamples_real < 1.0) { |
| 465 | Melder_appendError (U"A Sound cannot have zero samples."); |
| 466 | if (startTime == 0.0) |
| 467 | Melder_throw (U"Please raise the end time."); |
| 468 | else |
| 469 | Melder_throw (U"Please lower the start time or raise the end time."); |
| 470 | } |
| 471 | if (numberOfSamples_real > INT54_MAX) { |
| 472 | Melder_appendError (U"A Sound cannot have ", numberOfSamples_real, U" samples; the maximum is ", |
| 473 | Melder_bigInteger (INT54_MAX), U" samples (or less, depending on your computer's memory)."); |
| 474 | if (startTime == 0.0) |
| 475 | Melder_throw (U"Please lower the end time or the sampling frequency."); |
| 476 | else |
| 477 | Melder_throw (U"Please raise the start time, lower the end time, or lower the sampling frequency."); |
| 478 | } |
| 479 | const integer numberOfSamples = (int64) numberOfSamples_real; |
| 480 | autoSound sound; |
| 481 | try { |
| 482 | sound = Sound_create (numberOfChannels, startTime, endTime, numberOfSamples, 1.0 / samplingFrequency, |
| 483 | startTime + 0.5 * (endTime - startTime - (numberOfSamples - 1) / samplingFrequency)); |
| 484 | } catch (MelderError) { |
| 485 | if (str32str (Melder_getError (), U"memory")) { |
| 486 | Melder_clearError (); |
| 487 | Melder_appendError (U"There is not enough memory to create a Sound that contains ", Melder_bigInteger (numberOfSamples), U" samples."); |
| 488 | if (startTime == 0.0) |
| 489 | Melder_throw (U"You could lower the end time or the sampling frequency and try again."); |
| 490 | else |
| 491 | Melder_throw (U"You could raise the start time or lower the end time or the sampling frequency, and try again."); |
| 492 | } else { |
| 493 | throw; // unexpected error; wait for generic message |
| 494 | } |
| 495 | } |
| 496 | Matrix_formula (sound.get(), formula, interpreter, nullptr); |
| 497 | return sound; |
| 498 | } |
| 499 | |
| 500 | FORM (CREATE_ONE__Sound_create, U"Create mono Sound", U"Create Sound from formula...") { |
| 501 | WORD (name, U"Name", U"sineWithNoise") |
| 502 | REAL (startTime, U"Start time (s)", U"0.0") |
| 503 | REAL (endTime, U"End time (s)", U"1.0") |
| 504 | REAL (samplingFrequency, U"Sampling frequency (Hz)", U"44100") |
| 505 | FORMULA (formula, U"Formula", U"1/2 * sin(2*pi*377*x) + randomGauss(0,0.1)") |
| 506 | OK |
| 507 | DO |
| 508 | CREATE_ONE |
| 509 | autoSound result = common_Sound_create (1, startTime, endTime, samplingFrequency, formula, interpreter); |
| 510 | CREATE_ONE_END (name) |
| 511 | } |
| 512 | |
| 513 | FORM (CREATE_ONE__Sound_createFromFormula, U"Create Sound from formula", U"Create Sound from formula...") { |
| 514 | WORD (name, U"Name", U"sineWithNoise") |
| 515 | CHANNEL (numberOfChannels, U"Number of channels", U"1 (= mono)") |
| 516 | REAL (startTime, U"Start time (s)", U"0.0") |
| 517 | REAL (endTime, U"End time (s)", U"1.0") |
| 518 | REAL (samplingFrequency, U"Sampling frequency (Hz)", U"44100") |
| 519 | FORMULA (formula, U"Formula", U"1/2 * sin(2*pi*377*x) + randomGauss(0,0.1)") |
| 520 | OK |
| 521 | DO |
| 522 | CREATE_ONE |
| 523 | autoSound result = common_Sound_create (numberOfChannels, startTime, endTime, samplingFrequency, formula, interpreter); |
| 524 | CREATE_ONE_END (name) |
| 525 | } |
| 526 | |
| 527 | FORM (CREATE_ONE__Sound_createAsPureTone, U"Create Sound as pure tone", U"Create Sound as pure tone...") { |
| 528 | WORD (name, U"Name", U"tone") |
| 529 | CHANNEL (numberOfChannels, U"Number of channels", U"1 (= mono)") |
| 530 | REAL (startTime, U"Start time (s)", U"0.0") |
| 531 | REAL (endTime, U"End time (s)", U"0.4") |
| 532 | POSITIVE (samplingFrequency, U"Sampling frequency (Hz)", U"44100.0") |
| 533 | POSITIVE (toneFrequency, U"Tone frequency (Hz)", U"440.0") |
| 534 | POSITIVE (amplitude, U"Amplitude (Pa)", U"0.2") |
| 535 | POSITIVE (fadeInDuration, U"Fade-in duration (s)", U"0.01") |
| 536 | POSITIVE (fadeOutDuration, U"Fade-out duration (s)", U"0.01") |
| 537 | OK |
| 538 | DO |
| 539 | CREATE_ONE |
| 540 | autoSound result = Sound_createAsPureTone (numberOfChannels, startTime, endTime, |
| 541 | samplingFrequency, toneFrequency, amplitude, fadeInDuration, fadeOutDuration); |
| 542 | CREATE_ONE_END (name) |
| 543 | } |
| 544 | |
| 545 | FORM (CREATE_ONE__Sound_createAsToneComplex, U"Create Sound as tone complex", U"Create Sound as tone complex...") { |
| 546 | WORD (name, U"Name", U"toneComplex") |
| 547 | REAL (startTime, U"Start time (s)", U"0.0") |
| 548 | REAL (endTime, U"End time (s)", U"1.0") |
| 549 | POSITIVE (samplingFrequency, U"Sampling frequency (Hz)", U"44100.0") |
| 550 | CHOICEx (phase, U"Phase", 2, Sound_TONE_COMPLEX_SINE) |
| 551 | OPTION (U"sine") |
| 552 | OPTION (U"cosine") |
| 553 | POSITIVE (frequencyStep, U"Frequency step (Hz)", U"100.0") |
| 554 | REAL (firstFrequency, U"First frequency (Hz)", U"0.0 (= frequency step)") |
| 555 | REAL (ceiling, U"Ceiling (Hz)", U"0.0 (= Nyquist)") |
| 556 | INTEGER (numberOfComponents, U"Number of components", U"0 (= maximum)") |
| 557 | OK |
| 558 | DO |
| 559 | CREATE_ONE |
| 560 | autoSound result = Sound_createAsToneComplex (startTime, endTime, |
| 561 | samplingFrequency, phase, frequencyStep, firstFrequency, ceiling, numberOfComponents); |
| 562 | CREATE_ONE_END (name) |
| 563 | } |
| 564 | |
| 565 | FORM (CONVERT_TWO_TO_ONE__old_Sounds_crossCorrelate, U"Cross-correlate (short)", nullptr) { |
| 566 | REAL (fromLag, U"From lag (s)", U"-0.1") |
| 567 | REAL (toLag, U"To lag (s)", U"0.1") |
| 568 | BOOLEAN (normalize, U"Normalize", true) |
| 569 | OK |
| 570 | DO |
| 571 | CONVERT_TWO_TO_ONE (Sound) |
| 572 | autoSound result = Sounds_crossCorrelate_short (me, you, fromLag, toLag, normalize); |
| 573 | CONVERT_TWO_TO_ONE_END (U"cc_", my name.get(), U"_", your name.get()) |
| 574 | } |
| 575 | |
| 576 | FORM (CONVERT_TWO_TO_ONE__Sounds_crossCorrelate, U"Sounds: Cross-correlate", U"Sounds: Cross-correlate...") { |
| 577 | CHOICE_ENUM (kSounds_convolve_scaling, amplitudeScaling, |
| 578 | U"Amplitude scaling", kSounds_convolve_scaling::DEFAULT) |
| 579 | CHOICE_ENUM (kSounds_convolve_signalOutsideTimeDomain, signalOutsideTimeDomainIs, |
| 580 | U"Signal outside time domain is...", kSounds_convolve_signalOutsideTimeDomain::DEFAULT) |
| 581 | OK |
| 582 | DO_ALTERNATIVE (CONVERT_TWO_TO_ONE__old_Sounds_crossCorrelate) |
| 583 | CONVERT_TWO_TO_ONE (Sound) |
| 584 | autoSound result = Sounds_crossCorrelate (me, you, amplitudeScaling, signalOutsideTimeDomainIs); |
| 585 | CONVERT_TWO_TO_ONE_END (U"cc_", my name.get(), U"_", your name.get()) |
| 586 | } |
| 587 | |
| 588 | FORM (MODIFY_Sound_deemphasizeInplace, U"Sound: De-emphasize (in-place)", U"Sound: De-emphasize (in-place)...") { |
| 589 | REAL (fromFrequency, U"From frequency (Hz)", U"50.0") |
| 590 | OK |
| 591 | DO |
| 592 | MODIFY_EACH (mutableSound) |
| 593 | Sound_deEmphasize_inplace (me, fromFrequency); |
| 594 | Vector_scale (me, 0.99); |
| 595 | MODIFY_EACH_END |
| 596 | } |
| 597 | |
| 598 | FORM (CONVERT_EACH_TO_ONE__Sound_deepenBandModulation, U"Deepen band modulation", U"Sound: Deepen band modulation...") { |
| 599 | POSITIVE (enhancement, U"Enhancement (dB)", U"20.0") |
| 600 | POSITIVE (fromFrequency, U"From frequency (Hz)", U"300.0") |
| 601 | POSITIVE (toFrequency, U"To frequency (Hz)", U"8000.0") |
| 602 | POSITIVE (slowModulation, U"Slow modulation (Hz)", U"3.0") |
| 603 | POSITIVE (fastModulation, U"Fast modulation (Hz)", U"30.0") |
| 604 | POSITIVE (bandSmoothing, U"Band smoothing (Hz)", U"100.0") |
| 605 | OK |
| 606 | DO |
| 607 | CONVERT_EACH_TO_ONE (Sound) |
| 608 | autoSound result = Sound_deepenBandModulation (me, enhancement, fromFrequency, toFrequency, |
| 609 | slowModulation, fastModulation, bandSmoothing); |
| 610 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_", Melder_roundTowardsZero (enhancement)) |
| 611 | } |
| 612 | |
| 613 | FORM (GRAPHICS_EACH__old_Sound_draw, U"Sound: Draw", nullptr) { |
| 614 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 615 | REAL (toTime, U"right Time range", U"0.0 (= all)") |
| 616 | REAL (fromAmplitude, U"left Amplitude range", U"0.0") |
| 617 | REAL (toAmplitude, U"right Amplitude range", U"0.0 (= auto)") |
| 618 | BOOLEAN (garnish, U"Garnish", true) |
| 619 | OK |
| 620 | DO |
| 621 | GRAPHICS_EACH (Sound) |
| 622 | Sound_draw (me, GRAPHICS, fromTime, toTime, |
| 623 | fromAmplitude, toAmplitude, garnish, U"curve"); |
| 624 | GRAPHICS_EACH_END |
| 625 | } |
| 626 | |
| 627 | FORM (GRAPHICS_EACH__Sound_draw, U"Sound: Draw", nullptr) { |
| 628 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 629 | REAL (toTime, U"right Time range", U"0.0 (= all)") |
| 630 | REAL (fromAmplitude, U"left Amplitude range", U"0.0") |
| 631 | REAL (toAmplitude, U"right Amplitude range", U"0.0 (= auto)") |
| 632 | BOOLEAN (garnish, U"Garnish", true) |
| 633 | COMMENT (U"") |
| 634 | OPTIONMENUSTR (drawingMethod, U"Drawing method", 1) |
| 635 | OPTION (U"curve") |
| 636 | OPTION (U"bars") |
| 637 | OPTION (U"poles") |
| 638 | OPTION (U"speckles") |
| 639 | OK |
| 640 | DO_ALTERNATIVE (GRAPHICS_EACH__old_Sound_draw) |
| 641 | GRAPHICS_EACH (Sound) |
| 642 | Sound_draw (me, GRAPHICS, fromTime, toTime, |
| 643 | fromAmplitude, toAmplitude, garnish, drawingMethod); |
| 644 | GRAPHICS_EACH_END |
| 645 | } |
| 646 | |
| 647 | static void cb_SoundEditor_publication (Editor /* me */, autoDaata publication) { |
| 648 | /* |
| 649 | Keep the gate for error handling. |
| 650 | */ |
| 651 | try { |
| 652 | const bool isaSpectrum = Thing_isa (publication.get(), classSpectrum); |
| 653 | praat_new (publication.move(), U""); |
| 654 | praat_updateSelection (); |
| 655 | if (isaSpectrum) { |
| 656 | integer IOBJECT; |
| 657 | FIND_ONE_WITH_IOBJECT (Spectrum) |
| 658 | autoSpectrumEditor editor2 = SpectrumEditor_create (ID_AND_FULL_NAME, me); |
| 659 | praat_installEditor (editor2.get(), IOBJECT); |
| 660 | editor2.releaseToUser(); |
| 661 | } |
| 662 | } catch (MelderError) { |
| 663 | Melder_flushError (); |
| 664 | } |
| 665 | } |
| 666 | DIRECT (EDITOR_ONE__Sound_viewAndEdit) { |
| 667 | EDITOR_ONE (a,Sound) |
| 668 | autoSoundEditor editor = SoundEditor_create (ID_AND_FULL_NAME, me); |
| 669 | Editor_setPublicationCallback (editor.get(), cb_SoundEditor_publication); |
| 670 | EDITOR_ONE_END |
| 671 | } |
| 672 | |
| 673 | DIRECT (CONVERT_ONE_TO_MULTIPLE__Sound_extractAllChannels) { |
| 674 | CONVERT_ONE_TO_MULTIPLE (Sound) |
| 675 | for (integer channel = 1; channel <= my ny; channel ++) { |
| 676 | autoSound thee = Sound_extractChannel (me, channel); |
| 677 | praat_new (thee.move(), my name.get(), U"_ch", channel); |
| 678 | } |
| 679 | CONVERT_ONE_TO_MULTIPLE_END |
| 680 | } |
| 681 | |
| 682 | FORM (CONVERT_EACH_TO_ONE__Sound_extractChannel, U"Sound: Extract channel", nullptr) { |
| 683 | CHANNEL (channel, U"Channel (number, Left, or Right)", U"1") |
| 684 | OK |
| 685 | DO |
| 686 | CONVERT_EACH_TO_ONE (Sound) |
| 687 | autoSound result = Sound_extractChannel (me, channel); |
| 688 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_ch", channel) |
| 689 | } |
| 690 | |
| 691 | FORM (CONVERT_EACH_TO_ONE__Sound_extractChannels, U"Sound: Extract channels", nullptr) { |
| 692 | NATURALVECTOR (channels, U"Channel numbers", RANGES_, U"1:64") |
| 693 | OK |
| 694 | DO |
| 695 | CONVERT_EACH_TO_ONE (Sound) |
| 696 | autoSound result = Sound_extractChannels (me, channels); |
| 697 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_ch") |
| 698 | } |
| 699 | |
| 700 | DIRECT (CONVERT_EACH_TO_ONE__Sound_extractLeftChannel) { |
| 701 | CONVERT_EACH_TO_ONE (Sound) |
| 702 | autoSound result = Sound_extractChannel (me, 1); |
| 703 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_left") |
| 704 | } |
| 705 | |
| 706 | FORM (CONVERT_EACH_TO_ONE__Sound_extractPart, U"Sound: Extract part", U"Sound: Extract part...") { |
| 707 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 708 | REAL (toTime, U"right Time range (s)", U"0.1") |
| 709 | OPTIONMENU_ENUM (kSound_windowShape, windowShape, U"Window shape", kSound_windowShape::DEFAULT) |
| 710 | POSITIVE (relativeWidth, U"Relative width", U"1.0") |
| 711 | BOOLEAN (preserveTimes, U"Preserve times", false) |
| 712 | OK |
| 713 | DO |
| 714 | CONVERT_EACH_TO_ONE (Sound) |
| 715 | autoSound result = Sound_extractPart (me, fromTime, toTime, |
| 716 | windowShape, relativeWidth, preserveTimes); |
| 717 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_part") |
| 718 | } |
| 719 | |
| 720 | FORM (CONVERT_EACH_TO_ONE__Sound_extractPartForOverlap, U"Sound: Extract part for overlap", nullptr) { |
| 721 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 722 | REAL (toTime, U"right Time range (s)", U"0.1") |
| 723 | POSITIVE (overlap, U"Overlap (s)", U"0.01") |
| 724 | OK |
| 725 | DO |
| 726 | CONVERT_EACH_TO_ONE (Sound) |
| 727 | autoSound result = Sound_extractPartForOverlap (me, fromTime, toTime, overlap); |
| 728 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_part") |
| 729 | } |
| 730 | |
| 731 | DIRECT (CONVERT_EACH_TO_ONE__Sound_extractRightChannel) { |
| 732 | CONVERT_EACH_TO_ONE (Sound) |
| 733 | autoSound result = Sound_extractChannel (me, 2); |
| 734 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_right") |
| 735 | } |
| 736 | |
| 737 | FORM (CONVERT_EACH_TO_ONE__Sound_filter_deemphasis, U"Sound: Filter (de-emphasis)", U"Sound: Filter (de-emphasis)...") { |
| 738 | REAL (fromFrequency, U"From frequency (Hz)", U"50.0") |
| 739 | OK |
| 740 | DO |
| 741 | CONVERT_EACH_TO_ONE (Sound) |
| 742 | autoSound result = Sound_filter_deemphasis (me, fromFrequency); |
| 743 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_deemp") |
| 744 | } |
| 745 | |
| 746 | FORM (CONVERT_EACH_TO_ONE__Sound_filter_formula, U"Sound: Filter (formula)...", U"Formula...") { |
| 747 | COMMENT (U"Frequency-domain filtering with a formula") |
| 748 | COMMENT (U"(uses Sound-to-Spectrum and Spectrum-to-Sound): x is frequency in hertz") |
| 749 | FORMULA (formula, U"Formula", U"if x<500 or x>1000 then 0 else self fi; rectangular band filter") |
| 750 | OK |
| 751 | DO |
| 752 | CONVERT_EACH_TO_ONE (Sound) |
| 753 | autoSound result = Sound_filter_formula (me, formula, interpreter); |
| 754 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_filt") |
| 755 | } |
| 756 | |
| 757 | FORM (CONVERT_EACH_TO_ONE__Sound_filter_oneFormant, U"Sound: Filter (one formant)", U"Sound: Filter (one formant)...") { |
| 758 | REAL (frequency, U"Frequency (Hz)", U"1000.0") |
| 759 | POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100.0") |
| 760 | OK |
| 761 | DO |
| 762 | CONVERT_EACH_TO_ONE (Sound) |
| 763 | autoSound result = Sound_filter_oneFormant (me, frequency, bandwidth); |
| 764 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_filt") |
| 765 | } |
| 766 | |
| 767 | FORM (MODIFY_Sound_filterWithOneFormantInplace, U"Sound: Filter with one formant (in-place)", U"Sound: Filter with one formant (in-place)...") { |
| 768 | REAL (frequency, U"Frequency (Hz)", U"1000.0") |
| 769 | POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100.0") |
| 770 | OK |
| 771 | DO |
| 772 | MODIFY_EACH (Sound) |
| 773 | Sound_filterWithOneFormantInplace (me, frequency, bandwidth); |
| 774 | MODIFY_EACH_END |
| 775 | } |
| 776 | |
| 777 | FORM (CONVERT_EACH_TO_ONE__Sound_filter_passHannBand, U"Sound: Filter (pass Hann band)", U"Sound: Filter (pass Hann band)...") { |
| 778 | REAL (fromFrequency, U"From frequency (Hz)", U"500.0") |
| 779 | REAL (toFrequency, U"To frequency (Hz)", U"1000.0") |
| 780 | POSITIVE (smoothing, U"Smoothing (Hz)", U"100.0") |
| 781 | OK |
| 782 | DO |
| 783 | CONVERT_EACH_TO_ONE (Sound) |
| 784 | autoSound result = Sound_filter_passHannBand (me, fromFrequency, toFrequency, smoothing); |
| 785 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_band") |
| 786 | } |
| 787 | |
| 788 | FORM (CONVERT_EACH_TO_ONE__Sound_filter_preemphasis, U"Sound: Filter (pre-emphasis)", U"Sound: Filter (pre-emphasis)...") { |
| 789 | REAL (fromFrequency, U"From frequency (Hz)", U"50.0") |
| 790 | OK |
| 791 | DO |
| 792 | CONVERT_EACH_TO_ONE (Sound) |
| 793 | autoSound result = Sound_filter_preemphasis (me, fromFrequency); |
| 794 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_preemp") |
| 795 | } |
| 796 | |
| 797 | FORM (CONVERT_EACH_TO_ONE__Sound_filter_stopHannBand, U"Sound: Filter (stop Hann band)", U"Sound: Filter (stop Hann band)...") { |
| 798 | REAL (fromFrequency, U"From frequency (Hz)", U"500.0") |
| 799 | REAL (toFrequency, U"To frequency (Hz)", U"1000.0") |
| 800 | POSITIVE (smoothing, U"Smoothing (Hz)", U"100.0") |
| 801 | OK |
| 802 | DO |
| 803 | CONVERT_EACH_TO_ONE (Sound) |
| 804 | autoSound result = Sound_filter_stopHannBand (me, fromFrequency, toFrequency, smoothing); |
| 805 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_band") |
| 806 | } |
| 807 | |
| 808 | FORM (MODIFY_Sound_formula, U"Sound: Formula", U"Sound: Formula...") { |
| 809 | COMMENT (U"# `x` is the time in seconds, `col` is the sample number.") |
| 810 | COMMENT (U"x = x1 ! time associated with first sample") |
| 811 | COMMENT (U"for col from 1 to ncol") |
| 812 | COMMENT (U" self [col] = ...") |
| 813 | FORMULA (formula, U"Formula", U"self") |
| 814 | COMMENT (U" x = x + dx") |
| 815 | COMMENT (U"endfor") |
| 816 | OK |
| 817 | DO |
| 818 | MODIFY_EACH_WEAK (Sound) |
| 819 | Matrix_formula (me, formula, interpreter, nullptr); |
| 820 | MODIFY_EACH_WEAK_END |
| 821 | } |
| 822 | |
| 823 | FORM (MODIFY_Sound_formula_part, U"Sound: Formula (part)", U"Sound: Formula...") { |
| 824 | REAL (fromTime, U"From time", U"0.0") |
| 825 | REAL (toTime, U"To time", U"0.0 (= all)") |
| 826 | NATURAL (fromChannel, U"From channel", U"1") |
| 827 | NATURAL (toChannel, U"To channel", U"2") |
| 828 | FORMULA (formula, U"Formula", U"2 * self") |
| 829 | OK |
| 830 | DO |
| 831 | MODIFY_EACH_WEAK (Sound) |
| 832 | Matrix_formula_part (me, fromTime, toTime, fromChannel - 0.5, toChannel + 0.5, |
| 833 | formula, interpreter, nullptr); |
| 834 | MODIFY_EACH_WEAK_END |
| 835 | } |
| 836 | |
| 837 | FORM (QUERY_ONE_FOR_REAL__Sound_getAbsoluteExtremum, U"Sound: Get absolute extremum", U"Sound: Get absolute extremum...") { |
| 838 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 839 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 840 | CHOICE_ENUM (kVector_peakInterpolation, peakInterpolationType, |
| 841 | U"Interpolation", kVector_peakInterpolation::SINC70) |
| 842 | OK |
| 843 | DO |
| 844 | QUERY_ONE_FOR_REAL (Sound) |
| 845 | const double result = Vector_getAbsoluteExtremum (me, fromTime, toTime, peakInterpolationType); |
| 846 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 847 | } |
| 848 | |
| 849 | FORM (QUERY_ONE_FOR_REAL__Sound_getEnergy, U"Sound: Get energy", U"Sound: Get energy...") { |
| 850 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 851 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 852 | OK |
| 853 | DO |
| 854 | QUERY_ONE_FOR_REAL (Sound) |
| 855 | const double result = Sound_getEnergy (me, fromTime, toTime); |
| 856 | QUERY_ONE_FOR_REAL_END (U" Pa2 sec") |
| 857 | } |
| 858 | |
| 859 | DIRECT (QUERY_ONE_FOR_REAL__Sound_getEnergyInAir) { |
| 860 | QUERY_ONE_FOR_REAL (Sound) |
| 861 | const double result = Sound_getEnergyInAir (me); |
| 862 | QUERY_ONE_FOR_REAL_END (U" Joule/m2") |
| 863 | } |
| 864 | |
| 865 | FORM (QUERY_ONE_FOR_REAL__Sound_getIndexFromTime, U"Get sample number from time", U"Get sample number from time...") { |
| 866 | REAL (time, U"Time (s)", U"0.5") |
| 867 | OK |
| 868 | DO |
| 869 | QUERY_ONE_FOR_REAL (Sound) |
| 870 | const double result = Sampled_xToIndex (me, time); |
| 871 | QUERY_ONE_FOR_REAL_END (U" (index at time ", time, U" seconds)") |
| 872 | } |
| 873 | |
| 874 | DIRECT (QUERY_ONE_FOR_REAL__Sound_getIntensity_dB) { |
| 875 | QUERY_ONE_FOR_REAL (Sound) |
| 876 | const double result = Sound_getIntensity_dB (me); |
| 877 | QUERY_ONE_FOR_REAL_END (U" dB") |
| 878 | } |
| 879 | |
| 880 | FORM (QUERY_ONE_FOR_REAL__Sound_getMaximum, U"Sound: Get maximum", U"Sound: Get maximum...") { |
| 881 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 882 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 883 | CHOICE_ENUM (kVector_peakInterpolation, peakInterpolationType, |
| 884 | U"Interpolation", kVector_peakInterpolation::SINC70) |
| 885 | OK |
| 886 | DO |
| 887 | QUERY_ONE_FOR_REAL (Sound) |
| 888 | const double result = Vector_getMaximum (me, fromTime, toTime, peakInterpolationType); |
| 889 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 890 | } |
| 891 | |
| 892 | FORM (QUERY_ONE_FOR_REAL__old_Sound_getMean, U"Sound: Get mean", U"Sound: Get mean...") { |
| 893 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 894 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 895 | OK |
| 896 | DO |
| 897 | QUERY_ONE_FOR_REAL (Sound) |
| 898 | const double result = Vector_getMean (me, fromTime, toTime, Vector_CHANNEL_AVERAGE); |
| 899 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 900 | } |
| 901 | |
| 902 | FORM (QUERY_ONE_FOR_REAL__Sound_getMean, U"Sound: Get mean", U"Sound: Get mean...") { |
| 903 | CHANNEL (channel, U"Channel", U"0 (= all)") |
| 904 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 905 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 906 | OK |
| 907 | DO_ALTERNATIVE (QUERY_ONE_FOR_REAL__old_Sound_getMean) |
| 908 | QUERY_ONE_FOR_REAL (Sound) |
| 909 | if (channel > my ny) channel = 1; |
| 910 | const double result = Vector_getMean (me, fromTime, toTime, channel); |
| 911 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 912 | } |
| 913 | |
| 914 | FORM (QUERY_ONE_FOR_REAL__Sound_getMinimum, U"Sound: Get minimum", U"Sound: Get minimum...") { |
| 915 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 916 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 917 | CHOICE_ENUM (kVector_peakInterpolation, peakInterpolationType, |
| 918 | U"Interpolation", kVector_peakInterpolation::SINC70) |
| 919 | OK |
| 920 | DO |
| 921 | QUERY_ONE_FOR_REAL (Sound) |
| 922 | const double result = Vector_getMinimum (me, fromTime, toTime, peakInterpolationType); |
| 923 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 924 | } |
| 925 | |
| 926 | FORM (QUERY_ONE_FOR_REAL__old_Sound_getNearestZeroCrossing, U"Sound: Get nearest zero crossing", U"Sound: Get nearest zero crossing...") { |
| 927 | REAL (time, U"Time (s)", U"0.5") |
| 928 | OK |
| 929 | DO |
| 930 | QUERY_ONE_FOR_REAL (Sound) |
| 931 | /* |
| 932 | We are in an "old" version of this function, |
| 933 | so any error that we would want to post will not surface. |
| 934 | So we just post a warning instead. |
| 935 | */ |
| 936 | if (my ny > 1) { |
| 937 | static bool warningHasBeenPosted = false; |
| 938 | if (! warningHasBeenPosted) { |
| 939 | Melder_warning (U"(Sound: Get nearest zero crossing:) ", me, U" is a stereo sound. We’ll look for a zero crossing only in the first channel.\n" |
| 940 | "This message will not be repeated during this ", Melder_upperCaseAppName(), U" session."); |
| 941 | warningHasBeenPosted = true; |
| 942 | } |
| 943 | } |
| 944 | const double result = Sound_getNearestZeroCrossing (me, time, 1); |
| 945 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 946 | } |
| 947 | |
| 948 | FORM (QUERY_ONE_FOR_REAL__Sound_getNearestZeroCrossing, U"Sound: Get nearest zero crossing", U"Sound: Get nearest zero crossing...") { |
| 949 | CHANNEL (channel, U"Channel (number, Left, or Right)", U"1") |
| 950 | REAL (time, U"Time (s)", U"0.5") |
| 951 | OK |
| 952 | DO_ALTERNATIVE (QUERY_ONE_FOR_REAL__old_Sound_getNearestZeroCrossing) |
| 953 | QUERY_ONE_FOR_REAL (Sound) |
| 954 | Melder_require (channel >= 1, |
| 955 | U"The channel number should be at least 1."); |
| 956 | Melder_require (channel <= my ny, |
| 957 | U"The channel number should be at most the number of channels (", my ny, U")."); |
| 958 | const double result = Sound_getNearestZeroCrossing (me, time, channel); |
| 959 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 960 | } |
| 961 | |
| 962 | DIRECT (QUERY_ONE_FOR_INTEGER__Sound_getNumberOfChannels) { |
| 963 | QUERY_ONE_FOR_INTEGER (Sound) |
| 964 | const integer result = my ny; |
| 965 | QUERY_ONE_FOR_INTEGER_END (result == 1 ? U" channel (mono)" : result == 2 ? U" channels (stereo)" : U" channels") |
| 966 | } |
| 967 | |
| 968 | DIRECT (QUERY_ONE_FOR_INTEGER__Sound_getNumberOfSamples) { |
| 969 | QUERY_ONE_FOR_INTEGER (Sound) |
| 970 | const integer result = my nx; |
| 971 | QUERY_ONE_FOR_INTEGER_END (U" samples") |
| 972 | } |
| 973 | |
| 974 | FORM (QUERY_ONE_FOR_REAL__Sound_getPower, U"Sound: Get power", U"Sound: Get power...") { |
| 975 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 976 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 977 | OK |
| 978 | DO |
| 979 | QUERY_ONE_FOR_REAL (Sound) |
| 980 | const double result = Sound_getPower (me, fromTime, toTime); |
| 981 | QUERY_ONE_FOR_REAL_END (U" Pa2") |
| 982 | } |
| 983 | |
| 984 | DIRECT (QUERY_ONE_FOR_REAL__Sound_getPowerInAir) { |
| 985 | QUERY_ONE_FOR_REAL (Sound) |
| 986 | const double result = Sound_getPowerInAir (me); |
| 987 | QUERY_ONE_FOR_REAL_END (U" Watt/m2") |
| 988 | } |
| 989 | |
| 990 | FORM (QUERY_ONE_FOR_REAL__Sound_getRootMeanSquare, U"Sound: Get root-mean-square", U"Sound: Get root-mean-square...") { |
| 991 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 992 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 993 | OK |
| 994 | DO |
| 995 | QUERY_ONE_FOR_REAL (Sound) |
| 996 | const double result = Sound_getRootMeanSquare (me, fromTime, toTime); |
| 997 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 998 | } |
| 999 | |
| 1000 | DIRECT (QUERY_ONE_FOR_REAL__Sound_getSamplePeriod) { |
| 1001 | QUERY_ONE_FOR_REAL (Sound) |
| 1002 | const double result = my dx; |
| 1003 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 1004 | } |
| 1005 | |
| 1006 | DIRECT (QUERY_ONE_FOR_REAL__Sound_getSampleRate) { |
| 1007 | QUERY_ONE_FOR_REAL (Sound) |
| 1008 | const double result = 1.0 / my dx; |
| 1009 | QUERY_ONE_FOR_REAL_END (U" Hz") |
| 1010 | } |
| 1011 | |
| 1012 | FORM (QUERY_ONE_FOR_REAL__old_Sound_getStandardDeviation, U"Sound: Get standard deviation", U"Sound: Get standard deviation...") { |
| 1013 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 1014 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 1015 | OK |
| 1016 | DO |
| 1017 | QUERY_ONE_FOR_REAL (Sound) |
| 1018 | const double result = Vector_getStandardDeviation (me, fromTime, toTime, Vector_CHANNEL_AVERAGE); |
| 1019 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 1020 | } |
| 1021 | |
| 1022 | FORM (QUERY_ONE_FOR_REAL__Sound_getStandardDeviation, U"Sound: Get standard deviation", U"Sound: Get standard deviation...") { |
| 1023 | CHANNEL (channel, U"Channel", U"0 (= average)") |
| 1024 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 1025 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 1026 | OK |
| 1027 | DO_ALTERNATIVE (QUERY_ONE_FOR_REAL__old_Sound_getStandardDeviation) |
| 1028 | QUERY_ONE_FOR_REAL (Sound) |
| 1029 | if (channel > my ny) channel = 1; |
| 1030 | const double result = Vector_getStandardDeviation (me, fromTime, toTime, channel); |
| 1031 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 1032 | } |
| 1033 | |
| 1034 | FORM (QUERY_ONE_FOR_REAL__Sound_getTimeFromIndex, U"Get time from sample number", U"Get time from sample number...") { |
| 1035 | INTEGER (sampleNumber, U"Sample number", U"100") |
| 1036 | OK |
| 1037 | DO |
| 1038 | QUERY_ONE_FOR_REAL (Sound) |
| 1039 | const double result = Sampled_indexToX (me, sampleNumber); |
| 1040 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 1041 | } |
| 1042 | |
| 1043 | DIRECT (NUMVEC_Sound_listAllSampleTimes) { |
| 1044 | QUERY_ONE_FOR_REAL_VECTOR (Sound) |
| 1045 | autoVEC result = Sampled_listAllXValues (me); |
| 1046 | QUERY_ONE_FOR_REAL_VECTOR_END |
| 1047 | } |
| 1048 | |
| 1049 | FORM (QUERY_ONE_FOR_REAL__Sound_getTimeOfMaximum, U"Sound: Get time of maximum", U"Sound: Get time of maximum...") { |
| 1050 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 1051 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 1052 | CHOICE_ENUM (kVector_peakInterpolation, peakInterpolationType, |
| 1053 | U"Interpolation", kVector_peakInterpolation::SINC70) |
| 1054 | OK |
| 1055 | DO |
| 1056 | QUERY_ONE_FOR_REAL (Sound) |
| 1057 | const double result = Vector_getXOfMaximum (me, fromTime, toTime, peakInterpolationType); |
| 1058 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 1059 | } |
| 1060 | |
| 1061 | FORM (QUERY_ONE_FOR_REAL__Sound_getTimeOfMinimum, U"Sound: Get time of minimum", U"Sound: Get time of minimum...") { |
| 1062 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 1063 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 1064 | CHOICE_ENUM (kVector_peakInterpolation, peakInterpolationType, |
| 1065 | U"Interpolation", kVector_peakInterpolation::SINC70) |
| 1066 | OK |
| 1067 | DO |
| 1068 | QUERY_ONE_FOR_REAL (Sound) |
| 1069 | const double result = Vector_getXOfMinimum (me, fromTime, toTime, peakInterpolationType); |
| 1070 | QUERY_ONE_FOR_REAL_END (U" seconds") |
| 1071 | } |
| 1072 | |
| 1073 | FORM (QUERY_ONE_FOR_REAL__old_Sound_getValueAtIndex, U"Sound: Get value at sample number", U"Sound: Get value at sample number...") { |
| 1074 | INTEGER (sampleNumber, U"Sample number", U"100") |
| 1075 | OK |
| 1076 | DO |
| 1077 | QUERY_ONE_FOR_REAL (Sound) |
| 1078 | const double result = sampleNumber < 1 || sampleNumber > my nx ? undefined : |
| 1079 | my ny == 1 ? my z [1] [sampleNumber] : 0.5 * (my z [1] [sampleNumber] + my z [2] [sampleNumber]); |
| 1080 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 1081 | } |
| 1082 | |
| 1083 | FORM (QUERY_ONE_FOR_REAL__Sound_getValueAtIndex, U"Sound: Get value at sample number", U"Sound: Get value at sample number...") { |
| 1084 | CHANNEL (channel, U"Channel", U"0 (= average)") |
| 1085 | INTEGER (sampleNumber, U"Sample number", U"100") |
| 1086 | OK |
| 1087 | DO_ALTERNATIVE (QUERY_ONE_FOR_REAL__old_Sound_getValueAtIndex) |
| 1088 | QUERY_ONE_FOR_REAL (Sound) |
| 1089 | if (channel > my ny) channel = 1; |
| 1090 | const double result = sampleNumber < 1 || sampleNumber > my nx ? undefined : |
| 1091 | Sampled_getValueAtSample (me, sampleNumber, channel, 0); |
| 1092 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 1093 | } |
| 1094 | |
| 1095 | FORM (QUERY_ONE_FOR_REAL__old_Sound_getValueAtTime, U"Sound: Get value at time", U"Sound: Get value at time...") { |
| 1096 | REAL (time, U"Time (s)", U"0.5") |
| 1097 | CHOICE_ENUM (kVector_valueInterpolation, valueInterpolationType, |
| 1098 | U"Interpolation", kVector_valueInterpolation::SINC70) |
| 1099 | OK |
| 1100 | DO |
| 1101 | QUERY_ONE_FOR_REAL (Sound) |
| 1102 | const double result = Vector_getValueAtX (me, time, Vector_CHANNEL_AVERAGE, valueInterpolationType); |
| 1103 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 1104 | } |
| 1105 | |
| 1106 | FORM (QUERY_ONE_FOR_REAL__Sound_getValueAtTime, U"Sound: Get value at time", U"Sound: Get value at time...") { |
| 1107 | CHANNEL (channel, U"Channel", U"0 (= average)") |
| 1108 | REAL (time, U"Time (s)", U"0.5") |
| 1109 | CHOICE_ENUM (kVector_valueInterpolation, valueInterpolationType, |
| 1110 | U"Interpolation", kVector_valueInterpolation::SINC70) |
| 1111 | OK |
| 1112 | DO_ALTERNATIVE (QUERY_ONE_FOR_REAL__old_Sound_getValueAtTime) |
| 1113 | QUERY_ONE_FOR_REAL (Sound) |
| 1114 | if (channel > my ny) channel = 1; |
| 1115 | const double result = Vector_getValueAtX (me, time, channel, valueInterpolationType); |
| 1116 | QUERY_ONE_FOR_REAL_END (U" Pascal") |
| 1117 | } |
| 1118 | |
| 1119 | DIRECT (HELP__Sound_help) { |
| 1120 | HELP (U"Sound") |
| 1121 | } |
| 1122 | |
| 1123 | FORM (CONVERT_EACH_TO_ONE__Sound_lengthen_overlapAdd, U"Sound: Lengthen (overlap-add)", U"Sound: Lengthen (overlap-add)...") { |
| 1124 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1125 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1126 | POSITIVE (factor, U"Factor", U"1.5") |
| 1127 | OK |
| 1128 | DO |
| 1129 | Melder_require (pitchFloor < pitchCeiling, |
| 1130 | U"The pitch ceiling should be greater than the pitch floor."); |
| 1131 | CONVERT_EACH_TO_ONE (Sound) |
| 1132 | autoSound result = Sound_lengthen_overlapAdd (me, pitchFloor, pitchCeiling, factor); |
| 1133 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_", Melder_fixed (factor, 2)); |
| 1134 | } |
| 1135 | |
| 1136 | FORM (MODIFY_Sound_multiply, U"Sound: Multiply", nullptr) { |
| 1137 | REAL (multiplicationFactor, U"Multiplication factor", U"1.5") |
| 1138 | OK |
| 1139 | DO |
| 1140 | MODIFY_EACH (Sound) |
| 1141 | Vector_multiplyByScalar (me, multiplicationFactor); |
| 1142 | MODIFY_EACH_END |
| 1143 | } |
| 1144 | |
| 1145 | FORM (MODIFY_Sound_multiplyByWindow, U"Sound: Multiply by window", U"Sound: Multiply by window...") { |
| 1146 | OPTIONMENU_ENUM (kSound_windowShape, windowShape, U"Window shape", kSound_windowShape::HANNING) |
| 1147 | OK |
| 1148 | DO |
| 1149 | MODIFY_EACH (mutableSound) |
| 1150 | Sound_multiplyByWindow (me, windowShape); |
| 1151 | MODIFY_EACH_END |
| 1152 | } |
| 1153 | |
| 1154 | FORM (MODIFY_Sound_overrideSamplingFrequency, U"Sound: Override sampling frequency", nullptr) { |
| 1155 | POSITIVE (newSamplingFrequency, U"New sampling frequency (Hz)", U"16000.0") |
| 1156 | OK |
| 1157 | DO |
| 1158 | MODIFY_EACH (mutableSound) |
| 1159 | Sound_overrideSamplingFrequency (me, newSamplingFrequency); |
| 1160 | MODIFY_EACH_END |
| 1161 | } |
| 1162 | |
| 1163 | DIRECT (PLAY_EACH__Sound_play) { |
| 1164 | FIND_ALL_LISTED (Sound, SoundList) |
| 1165 | SoundList_play (list.get(), nullptr, nullptr); |
| 1166 | END_NO_NEW_DATA |
| 1167 | } |
| 1168 | |
| 1169 | FORM (MODIFY_Sound_preemphasizeInplace, U"Sound: Pre-emphasize (in-place)", U"Sound: Pre-emphasize (in-place)...") { |
| 1170 | REAL (fromFrequency, U"From frequency (Hz)", U"50.0") |
| 1171 | OK |
| 1172 | DO |
| 1173 | MODIFY_EACH (Sound) |
| 1174 | Sound_preEmphasize_inplace (me, fromFrequency); |
| 1175 | Vector_scale (me, 0.99); |
| 1176 | MODIFY_EACH_END |
| 1177 | } |
| 1178 | |
| 1179 | FORM_READ (READ_MULTIPLE__Sound_readSeparateChannelsFromSoundFile, U"Read separate channels from sound file", nullptr, true) { |
| 1180 | READ_MULTIPLE |
| 1181 | autoSound sound = Sound_readFromSoundFile (file); |
| 1182 | char32 name [300]; |
| 1183 | Melder_sprint (name,300, MelderFile_name (file)); |
| 1184 | char32 *lastPeriod = str32rchr (name, U'.'); |
| 1185 | if (lastPeriod) |
| 1186 | *lastPeriod = U'\0'; |
| 1187 | for (integer ichan = 1; ichan <= sound -> ny; ichan ++) { |
| 1188 | autoSound thee = Sound_extractChannel (sound.get(), ichan); |
| 1189 | praat_new (thee.move(), name, U"_ch", ichan); |
| 1190 | } |
| 1191 | READ_MULTIPLE_END |
| 1192 | } |
| 1193 | |
| 1194 | FORM_READ (READ_ONE__Sound_readFromRawAlawFile, U"Read Sound from raw Alaw file", nullptr, true) { |
| 1195 | READ_ONE |
| 1196 | autoSound result = Sound_readFromRawAlawFile (file); |
| 1197 | READ_ONE_END |
| 1198 | } |
| 1199 | |
| 1200 | static SoundRecorder theReferenceToTheOnlySoundRecorder; |
| 1201 | static int thePreviousNumberOfChannels; |
| 1202 | |
| 1203 | static void cb_SoundRecorder_destruction (SoundRecorder /* me */) { |
| 1204 | theReferenceToTheOnlySoundRecorder = nullptr; |
| 1205 | } |
| 1206 | static void cb_SoundRecorder_publication (Editor /* me */, autoDaata publication) { |
| 1207 | try { |
| 1208 | praat_new (publication.move()); |
| 1209 | } catch (MelderError) { |
| 1210 | Melder_flushError (); |
| 1211 | } |
| 1212 | praat_updateSelection (); |
| 1213 | } |
| 1214 | static void do_Sound_record (int numberOfChannels) { |
| 1215 | if (theReferenceToTheOnlySoundRecorder && numberOfChannels == thePreviousNumberOfChannels) { |
| 1216 | Editor_raise (theReferenceToTheOnlySoundRecorder); |
| 1217 | } else { |
| 1218 | forget (theReferenceToTheOnlySoundRecorder); |
| 1219 | autoSoundRecorder recorder = SoundRecorder_create (numberOfChannels); |
| 1220 | Editor_setDestructionCallback (recorder.get(), cb_SoundRecorder_destruction); |
| 1221 | Editor_setPublicationCallback (recorder.get(), cb_SoundRecorder_publication); |
| 1222 | theReferenceToTheOnlySoundRecorder = recorder.get(); |
| 1223 | recorder.releaseToUser(); |
| 1224 | thePreviousNumberOfChannels = numberOfChannels; |
| 1225 | } |
| 1226 | } |
| 1227 | DIRECT (SINGLETON_CREATION_WINDOW__Sound_recordMono) { |
| 1228 | SINGLETON_CREATION_WINDOW (a,Sound) |
| 1229 | do_Sound_record (1); |
| 1230 | SINGLETON_CREATION_WINDOW_END |
| 1231 | } |
| 1232 | DIRECT (SINGLETON_CREATION_WINDOW__Sound_recordStereo) { |
| 1233 | SINGLETON_CREATION_WINDOW (a,Sound) |
| 1234 | do_Sound_record (2); |
| 1235 | SINGLETON_CREATION_WINDOW_END |
| 1236 | } |
| 1237 | |
| 1238 | FORM (RECORD_ONE__Sound_record_fixedTime, U"Record Sound", nullptr) { |
| 1239 | COMMENT (U"This menu command is usually hidden,") |
| 1240 | COMMENT (U" because its behaviour is platform-dependent.") |
| 1241 | COMMENT (U"The combination of “microphone” and “48000 Hz” is likely") |
| 1242 | COMMENT (U" to work on all computers.") |
| 1243 | COMMENT (U"The “Gain” and “Balance” settings tend to be obsolete") |
| 1244 | COMMENT (U" and may not work at all on your computer.") |
| 1245 | CHOICE (inputSource, U"Input source", 1) |
| 1246 | OPTION (U"microphone") |
| 1247 | OPTION (U"line") |
| 1248 | REAL (gain, U"Gain (0-1)", U"1.0") |
| 1249 | REAL (balance, U"Balance (0-1)", U"0.5") |
| 1250 | OPTIONMENUSTR (samplingFrequency, U"Sampling frequency (Hz)", 6) |
| 1251 | OPTION (U"8000") |
| 1252 | OPTION (U"11025") |
| 1253 | OPTION (U"16000") |
| 1254 | OPTION (U"22050") |
| 1255 | OPTION (U"32000") |
| 1256 | OPTION (U"44100") |
| 1257 | OPTION (U"48000") |
| 1258 | OPTION (U"96000") |
| 1259 | POSITIVE (duration, U"Duration (seconds)", U"1.0") |
| 1260 | OK |
| 1261 | DO |
| 1262 | RECORD_ONE |
| 1263 | autoSound result = Sound_record_fixedTime (inputSource, |
| 1264 | gain, balance, Melder_atof (samplingFrequency), duration); |
| 1265 | RECORD_ONE_END (U"untitled") |
| 1266 | } |
| 1267 | |
| 1268 | extern "C" void* Praat_Sound_resample (void* sound, double newSamplingFrequency, int precision); |
| 1269 | #if 0 |
| 1270 | void* Praat_Sound_resample (void* sound, double newSamplingFrequency, int precision) { |
| 1271 | try { |
| 1272 | if (newSamplingFrequency <= 0.0) Melder_throw (U"`newSamplingFrequency` should be positive."); |
| 1273 | if (precision <= 0) Melder_throw (U"`precision` should be greater than 0."); |
| 1274 | autoSound thee = Sound_resample ((Sound) sound, newSamplingFrequency, precision); |
| 1275 | return (void*) thee.releaseToAmbiguousOwner(); |
| 1276 | } catch (MelderError) { |
| 1277 | Melder_flushError (U"Praat: Sound_resample: not performed."); |
| 1278 | return NULL; |
| 1279 | } |
| 1280 | } |
| 1281 | #elif 0 |
| 1282 | typedef struct { |
| 1283 | int type; |
| 1284 | union { void* _object; double _double; int _int; }; |
| 1285 | } PraatLibArg; |
| 1286 | #define PraatLibArg_OBJECT 0 |
| 1287 | #define PraatLibArg_DOUBLE 1 |
| 1288 | #define PraatLibArg_INT 2 |
| 1289 | extern "C" void* praatlib_do (const char *commandTitle, PraatLibArg args [], int narg); |
| 1290 | void* Praat_Sound_resample (void* sound, double newSamplingFrequency, int precision) { |
| 1291 | PraatLibArg args [3]; |
| 1292 | args [0]. type = PraatLibArg_OBJECT; |
| 1293 | args [0]. _object = sound; |
| 1294 | args [1]. type = PraatLibArg_DOUBLE; |
| 1295 | args [1]. _double = newSamplingFrequency; |
| 1296 | args [2]. type = PraatLibArg_INT; |
| 1297 | args [2]. _int = precision; |
| 1298 | return praatlib_do ("Sound: Resample...", args, 3); |
| 1299 | } |
| 1300 | #endif |
| 1301 | |
| 1302 | FORM (CONVERT_EACH_TO_ONE__Sound_resample, U"Sound: Resample", U"Sound: Resample...") { |
| 1303 | POSITIVE (newSamplingFrequency, U"New sampling frequency (Hz)", U"10000.0") |
| 1304 | NATURAL (precision, U"Precision (samples)", U"50") |
| 1305 | OK |
| 1306 | DO |
| 1307 | CONVERT_EACH_TO_ONE (Sound) |
| 1308 | autoSound result = Sound_resample (me, newSamplingFrequency, precision); |
| 1309 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_", Melder_iround (newSamplingFrequency)); |
| 1310 | } |
| 1311 | |
| 1312 | DIRECT (MODIFY_Sound_reverse) { |
| 1313 | MODIFY_EACH (Sound) |
| 1314 | Sound_reverse (me, 0.0, 0.0); |
| 1315 | MODIFY_EACH_END |
| 1316 | } |
| 1317 | |
| 1318 | FORM_SAVE (SAVE_ALL__Sound_saveAs24BitWavFile, U"Save as 24-bit WAV file", nullptr, U"wav") { |
| 1319 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the 24-bit WAV file") |
| 1320 | LongSound_concatenate (list.get(), file, Melder_WAV, 24); |
| 1321 | SAVE_ALL_LISTED_END |
| 1322 | } |
| 1323 | |
| 1324 | FORM_SAVE (SAVE_ALL__Sound_saveAs32BitWavFile, U"Save as 32-bit WAV file", nullptr, U"wav") { |
| 1325 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the 32-bit WAV file") |
| 1326 | LongSound_concatenate (list.get(), file, Melder_WAV, 32); |
| 1327 | SAVE_ALL_LISTED_END |
| 1328 | } |
| 1329 | |
| 1330 | FORM (MODIFY_Sound_scalePeak, U"Sound: Scale peak", U"Sound: Scale peak...") { |
| 1331 | POSITIVE (newAbsolutePeak, U"New absolute peak", U"0.99") |
| 1332 | OK |
| 1333 | DO |
| 1334 | MODIFY_EACH (Sound) |
| 1335 | Vector_scale (me, newAbsolutePeak); |
| 1336 | MODIFY_EACH_END |
| 1337 | } |
| 1338 | |
| 1339 | FORM (MODIFY_Sound_scaleIntensity, U"Sound: Scale intensity", U"Sound: Scale intensity...") { |
| 1340 | POSITIVE (newAverageIntensity, U"New average intensity (dB SPL)", U"70.0") |
| 1341 | OK |
| 1342 | DO |
| 1343 | MODIFY_EACH (Sound) |
| 1344 | Sound_scaleIntensity (me, newAverageIntensity); |
| 1345 | MODIFY_EACH_END |
| 1346 | } |
| 1347 | |
| 1348 | FORM (MODIFY_old_Sound_setValueAtIndex, U"Sound: Set value at sample number", U"Sound: Set value at sample number...") { |
| 1349 | NATURAL (sampleNumber, U"Sample number", U"100") |
| 1350 | REAL (newValue, U"New value", U"0.0") |
| 1351 | OK |
| 1352 | DO |
| 1353 | MODIFY_EACH (Sound) |
| 1354 | if (sampleNumber > my nx) |
| 1355 | Melder_throw (U"The sample number should not exceed the number of samples, which is ", my nx, U"."); |
| 1356 | for (integer channel = 1; channel <= my ny; channel ++) |
| 1357 | my z [channel] [sampleNumber] = newValue; |
| 1358 | MODIFY_EACH_END |
| 1359 | } |
| 1360 | |
| 1361 | FORM (MODIFY_Sound_setValueAtIndex, U"Sound: Set value at sample number", U"Sound: Set value at sample number...") { |
| 1362 | CHANNEL (channel, U"Channel", U"0 (= all)") |
| 1363 | NATURAL (sampleNumber, U"Sample number", U"100") |
| 1364 | REAL (newValue, U"New value", U"0.0") |
| 1365 | OK |
| 1366 | DO_ALTERNATIVE (MODIFY_old_Sound_setValueAtIndex) |
| 1367 | MODIFY_EACH (Sound) |
| 1368 | if (sampleNumber > my nx) |
| 1369 | Melder_throw (U"The sample number should not exceed the number of samples, which is ", my nx, U"."); |
| 1370 | if (channel > my ny) channel = 1; |
| 1371 | if (channel > 0) { |
| 1372 | my z [channel] [sampleNumber] = newValue; |
| 1373 | } else { |
| 1374 | for (channel = 1; channel <= my ny; channel ++) |
| 1375 | my z [channel] [sampleNumber] = newValue; |
| 1376 | } |
| 1377 | MODIFY_EACH_END |
| 1378 | } |
| 1379 | |
| 1380 | FORM (MODIFY_Sound_setPartToZero, U"Sound: Set part to zero", nullptr) { |
| 1381 | REAL (fromTime, U"left Time range (s)", U"0.0") |
| 1382 | REAL (toTime, U"right Time range (s)", U"0.0 (= all)") |
| 1383 | CHOICEx (cut, U"Cut", 2, 0) |
| 1384 | OPTION (U"at exactly these times") |
| 1385 | OPTION (U"at nearest zero crossing") |
| 1386 | OK |
| 1387 | DO |
| 1388 | MODIFY_EACH (Sound) |
| 1389 | Sound_setZero (me, fromTime, toTime, cut); |
| 1390 | MODIFY_EACH_END |
| 1391 | } |
| 1392 | |
| 1393 | DIRECT (MODIFY_Sound_subtractMean) { |
| 1394 | MODIFY_EACH (Sound) |
| 1395 | Vector_subtractMean (me); |
| 1396 | MODIFY_EACH_END |
| 1397 | } |
| 1398 | |
| 1399 | DIRECT (MODIFY_Sound_shiftTimesToBetweenZeroAndPhysicalDuration) { |
| 1400 | MODIFY_EACH (Sound) |
| 1401 | Sound_shiftTimesToBetweenZeroAndPhysicalDuration (me); |
| 1402 | MODIFY_EACH_END |
| 1403 | } |
| 1404 | |
| 1405 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Manipulation, U"Sound: To Manipulation", U"Manipulation") { |
| 1406 | POSITIVE (timeStep, U"Time step (s)", U"0.01") |
| 1407 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1408 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1409 | OK |
| 1410 | DO |
| 1411 | Melder_require (pitchCeiling > pitchFloor, |
| 1412 | U"The pitch ceiling should be greater than the pitch floor."); |
| 1413 | CONVERT_EACH_TO_ONE (Sound) |
| 1414 | autoManipulation result = Sound_to_Manipulation (me, timeStep, pitchFloor, pitchCeiling); |
| 1415 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1416 | } |
| 1417 | |
| 1418 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Cochleagram, U"Sound: To Cochleagram", nullptr) { |
| 1419 | POSITIVE (timeStep, U"Time step (s)", U"0.01") |
| 1420 | POSITIVE (frequencyResolution, U"Frequency resolution (Bark)", U"0.1") |
| 1421 | POSITIVE (windowLength, U"Window length (s)", U"0.03") |
| 1422 | REAL (forwardMaskingTime, U"Forward-masking time (s)", U"0.03") |
| 1423 | OK |
| 1424 | DO |
| 1425 | CONVERT_EACH_TO_ONE (Sound) |
| 1426 | autoCochleagram result = Sound_to_Cochleagram (me, timeStep, |
| 1427 | frequencyResolution, windowLength, forwardMaskingTime); |
| 1428 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1429 | } |
| 1430 | |
| 1431 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Cochleagram_edb, U"Sound: To Cochleagram (De Boer, Meddis & Hewitt)", nullptr) { |
| 1432 | POSITIVE (timeStep, U"Time step (s)", U"0.01") |
| 1433 | POSITIVE (frequencyResolution, U"Frequency resolution (Bark)", U"0.1") |
| 1434 | BOOLEAN (hasSynapse, U"Has synapse", true) |
| 1435 | COMMENT (U"Meddis synapse properties") |
| 1436 | POSITIVE (replenishmentRate, U" replenishment rate (/sec)", U"5.05") |
| 1437 | POSITIVE (lossRate, U" loss rate (/sec)", U"2500.0") |
| 1438 | POSITIVE (returnRate, U" return rate (/sec)", U"6580.0") |
| 1439 | POSITIVE (reprocessingRate, U" reprocessing rate (/sec)", U"66.31") |
| 1440 | OK |
| 1441 | DO |
| 1442 | CONVERT_EACH_TO_ONE (Sound) |
| 1443 | autoCochleagram result = Sound_to_Cochleagram_edb (me, timeStep, frequencyResolution, hasSynapse, |
| 1444 | replenishmentRate, lossRate, returnRate, reprocessingRate); |
| 1445 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1446 | } |
| 1447 | |
| 1448 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Formant_burg, U"Sound: To Formant (Burg method)", U"Sound: To Formant (burg)...") { |
| 1449 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1450 | POSITIVE (maximumNumberOfFormants, U"Max. number of formants", U"5.0") |
| 1451 | REAL (formantCeiling, U"Formant ceiling (Hz)", U"5500.0 (= adult female)") |
| 1452 | POSITIVE (windowLength, U"Window length (s)", U"0.025") |
| 1453 | POSITIVE (preEmphasisFrom, U"Pre-emphasis from (Hz)", U"50.0") |
| 1454 | OK |
| 1455 | DO |
| 1456 | CONVERT_EACH_TO_ONE (Sound) |
| 1457 | autoFormant result = Sound_to_Formant_burg (me, timeStep, |
| 1458 | maximumNumberOfFormants, formantCeiling, windowLength, preEmphasisFrom); |
| 1459 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1460 | } |
| 1461 | |
| 1462 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Formant_keepAll, U"Sound: To Formant (keep all)", U"Sound: To Formant (keep all)...") { |
| 1463 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1464 | POSITIVE (maximumNumberOfFormants, U"Max. number of formants", U"5.0") |
| 1465 | REAL (formantCeiling, U"Formant ceiling (Hz)", U"5500.0 (= adult female)") |
| 1466 | POSITIVE (windowLength, U"Window length (s)", U"0.025") |
| 1467 | POSITIVE (preEmphasisFrom, U"Pre-emphasis from (Hz)", U"50.0") |
| 1468 | OK |
| 1469 | DO |
| 1470 | CONVERT_EACH_TO_ONE (Sound) |
| 1471 | autoFormant result = Sound_to_Formant_keepAll (me, timeStep, |
| 1472 | maximumNumberOfFormants, formantCeiling, windowLength, preEmphasisFrom); |
| 1473 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1474 | } |
| 1475 | |
| 1476 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Formant_willems, U"Sound: To Formant (split Levinson (Willems))", U"Sound: To Formant (sl)...") { |
| 1477 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1478 | POSITIVE (numberOfFormants, U"Number of formants", U"5.0") |
| 1479 | REAL (formantCeiling, U"Formant ceiling (Hz)", U"5500.0 (= adult female)") |
| 1480 | POSITIVE (windowLength, U"Window length (s)", U"0.025") |
| 1481 | POSITIVE (preEmphasisFrom, U"Pre-emphasis from (Hz)", U"50.0") |
| 1482 | OK |
| 1483 | DO |
| 1484 | CONVERT_EACH_TO_ONE (Sound) |
| 1485 | autoFormant result = Sound_to_Formant_willems (me, timeStep, |
| 1486 | numberOfFormants, formantCeiling, windowLength, preEmphasisFrom); |
| 1487 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1488 | } |
| 1489 | |
| 1490 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Harmonicity_ac, U"Sound: To Harmonicity (ac)", U"Sound: To Harmonicity (ac)...") { |
| 1491 | POSITIVE (timeStep, U"Time step (s)", U"0.01") |
| 1492 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1493 | REAL (silenceThreshold, U"Silence threshold", U"0.1") |
| 1494 | POSITIVE (periodsPerWindow, U"Periods per window", U"4.5") |
| 1495 | OK |
| 1496 | DO |
| 1497 | Melder_require (periodsPerWindow >= 3.0, |
| 1498 | U"The number of periods per window must be at least 3.0."); |
| 1499 | CONVERT_EACH_TO_ONE (Sound) |
| 1500 | autoHarmonicity result = Sound_to_Harmonicity_ac (me, timeStep, |
| 1501 | pitchFloor, silenceThreshold, periodsPerWindow); |
| 1502 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1503 | } |
| 1504 | |
| 1505 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Harmonicity_cc, U"Sound: To Harmonicity (cc)", U"Sound: To Harmonicity (cc)...") { |
| 1506 | POSITIVE (timeStep, U"Time step (s)", U"0.01") |
| 1507 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1508 | REAL (silenceThreshold, U"Silence threshold", U"0.1") |
| 1509 | POSITIVE (periodsPerWindow, U"Periods per window", U"1.0") |
| 1510 | OK |
| 1511 | DO |
| 1512 | CONVERT_EACH_TO_ONE (Sound) |
| 1513 | autoHarmonicity result = Sound_to_Harmonicity_cc (me, timeStep, |
| 1514 | pitchFloor, silenceThreshold, periodsPerWindow); |
| 1515 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1516 | } |
| 1517 | |
| 1518 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Harmonicity_gne, U"Sound: To Harmonicity (gne)", nullptr) { |
| 1519 | POSITIVE (minimumFrequency, U"Minimum frequency (Hz)", U"500.0") |
| 1520 | POSITIVE (maximumFrequency, U"Maximum frequency (Hz)", U"4500.0") |
| 1521 | POSITIVE (bandwidth, U"Bandwidth (Hz)", U"1000.0") |
| 1522 | POSITIVE (step, U"Step (Hz)", U"80.0") |
| 1523 | OK |
| 1524 | DO |
| 1525 | CONVERT_EACH_TO_ONE (Sound) |
| 1526 | autoMatrix result = Sound_to_Harmonicity_GNE (me, minimumFrequency, |
| 1527 | maximumFrequency, bandwidth, step); |
| 1528 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1529 | } |
| 1530 | |
| 1531 | FORM (CONVERT_EACH_TO_ONE__old_Sound_to_Intensity, U"Sound: To Intensity", U"Sound: To Intensity...") { |
| 1532 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"100.0") |
| 1533 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1534 | OK |
| 1535 | DO |
| 1536 | CONVERT_EACH_TO_ONE (Sound) |
| 1537 | autoIntensity result = Sound_to_Intensity (me, |
| 1538 | pitchFloor, timeStep, false); |
| 1539 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1540 | } |
| 1541 | |
| 1542 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Intensity, U"Sound: To Intensity", U"Sound: To Intensity...") { |
| 1543 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"100.0") |
| 1544 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1545 | BOOLEAN (subtractMean, U"Subtract mean", true) |
| 1546 | OK |
| 1547 | DO_ALTERNATIVE (CONVERT_EACH_TO_ONE__old_Sound_to_Intensity) |
| 1548 | CONVERT_EACH_TO_ONE (Sound) |
| 1549 | autoIntensity result = Sound_to_Intensity (me, |
| 1550 | pitchFloor, timeStep, subtractMean); |
| 1551 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1552 | } |
| 1553 | |
| 1554 | FORM (CONVERT_EACH_TO_ONE__Sound_to_IntensityTier, U"Sound: To IntensityTier", nullptr) { |
| 1555 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"100.0") |
| 1556 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1557 | BOOLEAN (subtractMean, U"Subtract mean", true) |
| 1558 | OK |
| 1559 | DO |
| 1560 | CONVERT_EACH_TO_ONE (Sound) |
| 1561 | autoIntensityTier result = Sound_to_IntensityTier (me, |
| 1562 | pitchFloor, timeStep, subtractMean); |
| 1563 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1564 | } |
| 1565 | |
| 1566 | DIRECT (CONVERT_EACH_TO_ONE__Sound_to_IntervalTier) { |
| 1567 | CONVERT_EACH_TO_ONE (Sound) |
| 1568 | autoIntervalTier result = IntervalTier_create (my xmin, my xmax); |
| 1569 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1570 | } |
| 1571 | |
| 1572 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Ltas, U"Sound: To long-term average spectrum", nullptr) { |
| 1573 | POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100") |
| 1574 | OK |
| 1575 | DO |
| 1576 | CONVERT_EACH_TO_ONE (Sound) |
| 1577 | autoLtas result = Sound_to_Ltas (me, bandwidth); |
| 1578 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1579 | } |
| 1580 | |
| 1581 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Ltas_pitchCorrected, U"Sound: To Ltas (pitch-corrected)", U"Sound: To Ltas (pitch-corrected)...") { |
| 1582 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1583 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1584 | POSITIVE (maximumFrequency, U"Maximum frequency (Hz)", U"5000.0") |
| 1585 | POSITIVE (bandwidth, U"Bandwidth (Hz)", U"100.0") |
| 1586 | REAL (shortestPeriod, U"Shortest period (s)", U"0.0001") |
| 1587 | REAL (longestPeriod, U"Longest period (s)", U"0.02") |
| 1588 | POSITIVE (maximumPeriodFactor, U"Maximum period factor", U"1.3") |
| 1589 | OK |
| 1590 | DO |
| 1591 | Melder_require (pitchCeiling > pitchFloor, |
| 1592 | U"Your pitch ceiling should be greater than your pitch floor."); |
| 1593 | CONVERT_EACH_TO_ONE (Sound) |
| 1594 | autoLtas result = Sound_to_Ltas_pitchCorrected (me, pitchFloor, pitchCeiling, |
| 1595 | maximumFrequency, bandwidth, shortestPeriod, longestPeriod, maximumPeriodFactor); |
| 1596 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1597 | } |
| 1598 | |
| 1599 | DIRECT (CONVERT_EACH_TO_ONE__Sound_downto_Matrix) { |
| 1600 | CONVERT_EACH_TO_ONE (Sound) |
| 1601 | autoMatrix result = Sound_to_Matrix (me); |
| 1602 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1603 | } |
| 1604 | |
| 1605 | DIRECT (CONVERT_TWO_TO_ONE__Sounds_to_ParamCurve) { |
| 1606 | CONVERT_TWO_TO_ONE (Sound) |
| 1607 | autoParamCurve result = ParamCurve_create (me, you); |
| 1608 | CONVERT_TWO_TO_ONE_END (my name.get(), U"_", your name.get()) |
| 1609 | } |
| 1610 | |
| 1611 | DIRECT (HELP__How_to_choose_a_pitch_analysis_method) { |
| 1612 | HELP (U"how to choose a pitch analysis method") |
| 1613 | } |
| 1614 | |
| 1615 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch, U"Sound: To Pitch", U"Sound: To Pitch...") { |
| 1616 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1617 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1618 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1619 | OK |
| 1620 | DO |
| 1621 | CONVERT_EACH_TO_ONE (Sound) |
| 1622 | autoPitch result = Sound_to_Pitch (me, timeStep, pitchFloor, pitchCeiling); |
| 1623 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1624 | } |
| 1625 | |
| 1626 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch_ac, U"Sound: To Pitch (ac)", U"Sound: To Pitch (ac)...") { |
| 1627 | COMMENT (U"Finding the candidates...") |
| 1628 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1629 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1630 | NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15") |
| 1631 | BOOLEAN (veryAccurate, U"Very accurate", false) |
| 1632 | COMMENT (U"Finding a path...") |
| 1633 | REAL (silenceThreshold, U"Silence threshold", U"0.03") |
| 1634 | REAL (voicingThreshold, U"Voicing threshold", U"0.45") |
| 1635 | REAL (octaveCost, U"Octave cost", U"0.01") |
| 1636 | REAL (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 1637 | REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14") |
| 1638 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1639 | OK |
| 1640 | DO |
| 1641 | Melder_require (maximumNumberOfCandidates > 1, |
| 1642 | U"Your maximum number of candidates should be greater than 1."); |
| 1643 | CONVERT_EACH_TO_ONE (Sound) |
| 1644 | autoPitch result = Sound_to_Pitch_rawAc (me, |
| 1645 | timeStep, pitchFloor, pitchCeiling, |
| 1646 | maximumNumberOfCandidates, veryAccurate, |
| 1647 | silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost |
| 1648 | ); |
| 1649 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1650 | } |
| 1651 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch_cc, U"Sound: To Pitch (cc)", U"Sound: To Pitch (cc)...") { |
| 1652 | COMMENT (U"Finding the candidates...") |
| 1653 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1654 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1655 | NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15") |
| 1656 | BOOLEAN (veryAccurate, U"Very accurate", false) |
| 1657 | COMMENT (U"Finding a path...") |
| 1658 | REAL (silenceThreshold, U"Silence threshold", U"0.03") |
| 1659 | REAL (voicingThreshold, U"Voicing threshold", U"0.45") |
| 1660 | REAL (octaveCost, U"Octave cost", U"0.01") |
| 1661 | REAL (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 1662 | REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14") |
| 1663 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1664 | OK |
| 1665 | DO |
| 1666 | Melder_require (maximumNumberOfCandidates > 1, |
| 1667 | U"Your maximum number of candidates should be greater than 1."); |
| 1668 | CONVERT_EACH_TO_ONE (Sound) |
| 1669 | autoPitch result = Sound_to_Pitch_rawCc (me, |
| 1670 | timeStep, pitchFloor, pitchCeiling, |
| 1671 | maximumNumberOfCandidates, veryAccurate, |
| 1672 | silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost |
| 1673 | ); |
| 1674 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1675 | } |
| 1676 | |
| 1677 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch_rawAutocorrelation, U"Sound: To Pitch (raw autocorrelation)", U"Sound: To Pitch (raw autocorrelation)...") { |
| 1678 | HEADING (U"Where to search...") |
| 1679 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1680 | POSITIVE (pitchFloor, U"left Pitch floor and ceiling (Hz)", U"75.0") |
| 1681 | POSITIVE (pitchCeiling, U"right Pitch floor and ceiling (Hz)", U"600.0") |
| 1682 | HEADING (U"How to find the candidates...") |
| 1683 | NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15") |
| 1684 | BOOLEAN (veryAccurate, U"Very accurate", false) |
| 1685 | HEADING (U"How to find a path through the candidates...") |
| 1686 | REAL (silenceThreshold, U"Silence threshold", U"0.03") |
| 1687 | REAL (voicingThreshold, U"Voicing threshold", U"0.45") |
| 1688 | REAL (octaveCost, U"Octave cost", U"0.01") |
| 1689 | REAL (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 1690 | REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14") |
| 1691 | OK |
| 1692 | DO |
| 1693 | Melder_require (maximumNumberOfCandidates > 1, |
| 1694 | U"Your maximum number of candidates should be greater than 1."); |
| 1695 | CONVERT_EACH_TO_ONE (Sound) |
| 1696 | autoPitch result = Sound_to_Pitch_rawAc (me, |
| 1697 | timeStep, pitchFloor, pitchCeiling, |
| 1698 | maximumNumberOfCandidates, veryAccurate, |
| 1699 | silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost |
| 1700 | ); |
| 1701 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1702 | } |
| 1703 | |
| 1704 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch_rawCrossCorrelation, U"Sound: To Pitch (raw cross-correlation)", U"Sound: To Pitch (raw cross-correlation)...") { |
| 1705 | HEADING (U"Where to search...") |
| 1706 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1707 | POSITIVE (pitchFloor, U"left Pitch floor and ceiling (Hz)", U"75.0") |
| 1708 | POSITIVE (pitchCeiling, U"right Pitch floor and ceiling (Hz)", U"600.0") |
| 1709 | HEADING (U"How to find the candidates...") |
| 1710 | NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15") |
| 1711 | BOOLEAN (veryAccurate, U"Very accurate", false) |
| 1712 | HEADING (U"How to find a path through the candidates...") |
| 1713 | REAL (silenceThreshold, U"Silence threshold", U"0.03") |
| 1714 | REAL (voicingThreshold, U"Voicing threshold", U"0.45") |
| 1715 | REAL (octaveCost, U"Octave cost", U"0.01") |
| 1716 | REAL (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 1717 | REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14") |
| 1718 | OK |
| 1719 | DO |
| 1720 | Melder_require (maximumNumberOfCandidates > 1, |
| 1721 | U"Your maximum number of candidates should be greater than 1."); |
| 1722 | CONVERT_EACH_TO_ONE (Sound) |
| 1723 | autoPitch result = Sound_to_Pitch_rawCc (me, |
| 1724 | timeStep, pitchFloor, pitchCeiling, |
| 1725 | maximumNumberOfCandidates, veryAccurate, |
| 1726 | silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost |
| 1727 | ); |
| 1728 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1729 | } |
| 1730 | |
| 1731 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch_filteredAutocorrelation, U"Sound: To Pitch (filtered autocorrelation)", U"Sound: To Pitch (filtered autocorrelation)...") { |
| 1732 | HEADING (U"Where to search...") |
| 1733 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1734 | POSITIVE (pitchFloor, U"left Pitch floor and top (Hz)", U"50.0") |
| 1735 | POSITIVE (pitchTop, U"right Pitch floor and top (Hz)", U"800.0") |
| 1736 | HEADING (U"How to find the candidates...") |
| 1737 | NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15") |
| 1738 | BOOLEAN (veryAccurate, U"Very accurate", false) |
| 1739 | HEADING (U"How to preprocess the sound...") |
| 1740 | POSITIVE (attenuationAtTop, U"Attenuation at top", U"0.03") |
| 1741 | HEADING (U"How to find a path through the candidates...") |
| 1742 | REAL (silenceThreshold, U"Silence threshold", U"0.09") |
| 1743 | REAL (voicingThreshold, U"Voicing threshold", U"0.50") |
| 1744 | REAL (octaveCost, U"Octave cost", U"0.055") |
| 1745 | REAL (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 1746 | REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14") |
| 1747 | OK |
| 1748 | DO |
| 1749 | Melder_require (maximumNumberOfCandidates > 1, |
| 1750 | U"Your maximum number of candidates should be greater than 1."); |
| 1751 | CONVERT_EACH_TO_ONE (Sound) |
| 1752 | autoPitch result = Sound_to_Pitch_filteredAc (me, |
| 1753 | timeStep, pitchFloor, pitchTop, |
| 1754 | maximumNumberOfCandidates, veryAccurate, attenuationAtTop, |
| 1755 | silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost |
| 1756 | ); |
| 1757 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1758 | } |
| 1759 | |
| 1760 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Pitch_filteredCrossCorrelation, U"Sound: To Pitch (filtered cross-correlation)", U"Sound: To Pitch (filtered cross-correlation)...") { |
| 1761 | HEADING (U"Where to search...") |
| 1762 | REAL (timeStep, U"Time step (s)", U"0.0 (= auto)") |
| 1763 | POSITIVE (pitchFloor, U"left Pitch floor and top (Hz)", U"50.0") |
| 1764 | POSITIVE (pitchTop, U"right Pitch floor and top (Hz)", U"800.0") |
| 1765 | HEADING (U"How to find the candidates...") |
| 1766 | NATURAL (maximumNumberOfCandidates, U"Max. number of candidates", U"15") |
| 1767 | BOOLEAN (veryAccurate, U"Very accurate", false) |
| 1768 | HEADING (U"How to preprocess the sound...") |
| 1769 | POSITIVE (attenuationAtTop, U"Attenuation at top", U"0.03") |
| 1770 | HEADING (U"How to find a path through the candidates...") |
| 1771 | REAL (silenceThreshold, U"Silence threshold", U"0.09") |
| 1772 | REAL (voicingThreshold, U"Voicing threshold", U"0.50") |
| 1773 | REAL (octaveCost, U"Octave cost", U"0.055") |
| 1774 | REAL (octaveJumpCost, U"Octave-jump cost", U"0.35") |
| 1775 | REAL (voicedUnvoicedCost, U"Voiced / unvoiced cost", U"0.14") |
| 1776 | OK |
| 1777 | DO |
| 1778 | Melder_require (maximumNumberOfCandidates > 1, |
| 1779 | U"Your maximum number of candidates should be greater than 1."); |
| 1780 | CONVERT_EACH_TO_ONE (Sound) |
| 1781 | autoPitch result = Sound_to_Pitch_filteredCc (me, |
| 1782 | timeStep, pitchFloor, pitchTop, |
| 1783 | maximumNumberOfCandidates, veryAccurate, attenuationAtTop, |
| 1784 | silenceThreshold, voicingThreshold, octaveCost, octaveJumpCost, voicedUnvoicedCost |
| 1785 | ); |
| 1786 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1787 | } |
| 1788 | |
| 1789 | FORM (CONVERT_EACH_TO_ONE__Sound_to_PointProcess_extrema, U"Sound: To PointProcess (extrema)", nullptr) { |
| 1790 | CHANNEL (channel, U"Channel (number, Left, or Right)", U"1") |
| 1791 | BOOLEAN (includeMaxima, U"Include maxima", true) |
| 1792 | BOOLEAN (includeMinima, U"Include minima", false) |
| 1793 | CHOICE_ENUM (kVector_peakInterpolation, peakInterpolationType, |
| 1794 | U"Interpolation", kVector_peakInterpolation::SINC70) |
| 1795 | OK |
| 1796 | DO |
| 1797 | CONVERT_EACH_TO_ONE (Sound) |
| 1798 | autoPointProcess result = Sound_to_PointProcess_extrema (me, channel > my ny ? 1 : channel, |
| 1799 | peakInterpolationType, includeMaxima, includeMinima); |
| 1800 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1801 | } |
| 1802 | |
| 1803 | FORM (CONVERT_EACH_TO_ONE__Sound_to_PointProcess_periodic_cc, U"Sound: To PointProcess (periodic, cc)", U"Sound: To PointProcess (periodic, cc)...") { |
| 1804 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1805 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1806 | OK |
| 1807 | DO |
| 1808 | Melder_require (pitchCeiling > pitchFloor, |
| 1809 | U"Your pitch ceiling should be greater than your pitch floor."); |
| 1810 | CONVERT_EACH_TO_ONE (Sound) |
| 1811 | autoPointProcess result = Sound_to_PointProcess_periodic_cc (me, pitchFloor, pitchCeiling); |
| 1812 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1813 | } |
| 1814 | |
| 1815 | FORM (CONVERT_EACH_TO_ONE__Sound_to_PointProcess_periodic_peaks, U"Sound: To PointProcess (periodic, peaks)", U"Sound: To PointProcess (periodic, peaks)...") { |
| 1816 | POSITIVE (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 1817 | POSITIVE (pitchCeiling, U"Pitch ceiling (Hz)", U"600.0") |
| 1818 | BOOLEAN (includeMaxima, U"Include maxima", true) |
| 1819 | BOOLEAN (includeMinima, U"Include minima", false) |
| 1820 | OK |
| 1821 | DO |
| 1822 | Melder_require (pitchCeiling > pitchFloor, |
| 1823 | U"Your pitch ceiling should be greater than your pitch floor."); |
| 1824 | CONVERT_EACH_TO_ONE (Sound) |
| 1825 | autoPointProcess result = Sound_to_PointProcess_periodic_peaks (me, |
| 1826 | pitchFloor, pitchCeiling, includeMaxima, includeMinima); |
| 1827 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1828 | } |
| 1829 | |
| 1830 | FORM (CONVERT_EACH_TO_ONE__Sound_to_PointProcess_zeroes, U"Get zeroes", nullptr) { |
| 1831 | CHANNEL (channel, U"Channel (number, Left, or Right)", U"1") |
| 1832 | BOOLEAN (includeRaisers, U"Include raisers", true) |
| 1833 | BOOLEAN (includeFallers, U"Include fallers", false) |
| 1834 | OK |
| 1835 | DO |
| 1836 | CONVERT_EACH_TO_ONE (Sound) |
| 1837 | autoPointProcess result = Sound_to_PointProcess_zeroes (me, channel > my ny ? 1 : channel, |
| 1838 | includeRaisers, includeFallers); |
| 1839 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1840 | } |
| 1841 | |
| 1842 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Spectrogram, U"Sound: To Spectrogram", U"Sound: To Spectrogram...") { |
| 1843 | POSITIVE (windowLength, U"Window length (s)", U"0.005") |
| 1844 | POSITIVE (maximumFrequency, U"Maximum frequency (Hz)", U"5000.0") |
| 1845 | POSITIVE (timeStep, U"Time step (s)", U"0.002") |
| 1846 | POSITIVE (frequencyStep, U"Frequency step (Hz)", U"20.0") |
| 1847 | CHOICE_ENUM (kSound_to_Spectrogram_windowShape, windowShape, |
| 1848 | U"Window shape", kSound_to_Spectrogram_windowShape::DEFAULT) |
| 1849 | OK |
| 1850 | DO |
| 1851 | CONVERT_EACH_TO_ONE (Sound) |
| 1852 | autoSpectrogram result = Sound_to_Spectrogram_e (me, windowLength, |
| 1853 | maximumFrequency, timeStep, frequencyStep, windowShape, 8.0, 8.0); |
| 1854 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1855 | } |
| 1856 | |
| 1857 | FORM (CONVERT_EACH_TO_ONE__Sound_to_Spectrum, U"Sound: To Spectrum", U"Sound: To Spectrum...") { |
| 1858 | BOOLEAN (fast, U"Fast", true) |
| 1859 | OK |
| 1860 | DO |
| 1861 | CONVERT_EACH_TO_ONE (Sound) |
| 1862 | autoSpectrum result = Sound_to_Spectrum (me, fast); |
| 1863 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1864 | } |
| 1865 | |
| 1866 | DIRECT (CONVERT_EACH_TO_ONE__Sound_to_Spectrum_dft) { |
| 1867 | CONVERT_EACH_TO_ONE (Sound) |
| 1868 | autoSpectrum result = Sound_to_Spectrum (me, false); |
| 1869 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1870 | } |
| 1871 | |
| 1872 | DIRECT (CONVERT_EACH_TO_ONE__Sound_to_Spectrum_fft) { |
| 1873 | CONVERT_EACH_TO_ONE (Sound) |
| 1874 | autoSpectrum result = Sound_to_Spectrum (me, true); |
| 1875 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1876 | } |
| 1877 | |
| 1878 | FORM (CONVERT_EACH_TO_ONE__Sound_to_TextGrid, U"Sound: To TextGrid", U"Sound: To TextGrid...") { |
| 1879 | SENTENCE (allTierNames, U"All tier names", U"Mary John bell") |
| 1880 | SENTENCE (whichOfTheseArePointTiers, U"Which of these are point tiers?", U"bell") |
| 1881 | OK |
| 1882 | DO |
| 1883 | CONVERT_EACH_TO_ONE (Sound) |
| 1884 | autoTextGrid result = TextGrid_create (my xmin, my xmax, allTierNames, whichOfTheseArePointTiers); |
| 1885 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1886 | } |
| 1887 | |
| 1888 | FORM (CONVERT_EACH_TO_ONE__Sound_to_TextGrid_speechActivity_silero, |
| 1889 | U"Sound: To TextGrid (speech activity, Silero)", |
| 1890 | U"Sound: To TextGrid (speech activity, Silero)...") |
| 1891 | { |
| 1892 | NONNEGATIVE (speechProbabilityThreshold, U"Speech probability threshold (0-1)", VadDefaults::speechThreshold) |
| 1893 | NONNEGATIVE (minNonSpeechDuration, U"Min. gap between speech segments (s)", VadDefaults::minNonSpeechDuration) |
| 1894 | NONNEGATIVE (minSpeechDuration, U"Min. speech segment (s)", VadDefaults::minSpeechDuration) |
| 1895 | NONNEGATIVE (speechPad, U"Padding around speech segments (s)", VadDefaults::speechPad) |
| 1896 | WORD (nonSpeechLabel, U"Non-speech interval label", VadDefaults::nonSpeechLabel) |
| 1897 | WORD (speechLabel, U"Speech interval label", VadDefaults::speechLabel) |
| 1898 | OK |
| 1899 | DO |
| 1900 | CONVERT_EACH_TO_ONE (Sound) |
| 1901 | autoTextGrid result = Sound_to_TextGrid_speechActivity_silero (me, speechProbabilityThreshold, |
| 1902 | minNonSpeechDuration, minSpeechDuration, speechPad, nonSpeechLabel, speechLabel); |
| 1903 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1904 | } |
| 1905 | |
| 1906 | DIRECT (CONVERT_EACH_TO_ONE__Sound_to_TextTier) { |
| 1907 | CONVERT_EACH_TO_ONE (Sound) |
| 1908 | autoTextTier result = TextTier_create (my xmin, my xmax); |
| 1909 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 1910 | } |
| 1911 | |
| 1912 | FORM (SETTINGS__SoundRecordingSettings, U"Sound recording settings", U"SoundRecorder") { |
| 1913 | NATURAL (bufferSize, U"Buffer size (MB)", U"60") |
| 1914 | OPTIONMENU_ENUM (kMelder_inputSoundSystem, inputSoundSystem, |
| 1915 | U"Input sound system", kMelder_inputSoundSystem::DEFAULT) |
| 1916 | OK |
| 1917 | SET_INTEGER (bufferSize, SoundRecorder_getBufferSizePref_MB ()) |
| 1918 | SET_ENUM (inputSoundSystem, kMelder_inputSoundSystem, MelderAudio_getInputSoundSystem()) |
| 1919 | DO |
| 1920 | PREFS |
| 1921 | if (bufferSize > 1000) |
| 1922 | Melder_throw (U"Buffer size cannot exceed 1000 megabytes."); |
| 1923 | SoundRecorder_setBufferSizePref_MB (bufferSize); |
| 1924 | MelderAudio_setInputSoundSystem (inputSoundSystem); |
| 1925 | PREFS_END |
| 1926 | } |
| 1927 | |
| 1928 | FORM (SETTINGS__SoundPlayingSettings, U"Sound playing settings", nullptr) { |
| 1929 | COMMENT (U"The following determines how sounds are played.") |
| 1930 | COMMENT (U"Between parentheses, you find what you can do simultaneously.") |
| 1931 | COMMENT (U"Decrease asynchronicity if sound plays with discontinuities.") |
| 1932 | OPTIONMENU_ENUM (kMelder_asynchronicityLevel, maximumAsynchronicity, |
| 1933 | U"Maximum asynchronicity", kMelder_asynchronicityLevel::DEFAULT) |
| 1934 | REAL (silenceBefore, U"Silence before (s)", U"" stringize(kMelderAudio_outputSilenceBefore_DEFAULT)) |
| 1935 | REAL (silenceAfter, U"Silence after (s)", U"" stringize(kMelderAudio_outputSilenceAfter_DEFAULT)) |
| 1936 | OPTIONMENU_ENUM (kMelder_outputSoundSystem, outputSoundSystem, |
| 1937 | U"Output sound system", kMelder_outputSoundSystem::DEFAULT) |
| 1938 | OK |
| 1939 | SET_ENUM (maximumAsynchronicity, kMelder_asynchronicityLevel, MelderAudio_getOutputMaximumAsynchronicity ()) |
| 1940 | SET_REAL (silenceBefore, MelderAudio_getOutputSilenceBefore ()) |
| 1941 | SET_REAL (silenceAfter, MelderAudio_getOutputSilenceAfter ()) |
| 1942 | SET_ENUM (outputSoundSystem, kMelder_outputSoundSystem, MelderAudio_getOutputSoundSystem()) |
| 1943 | DO |
| 1944 | PREFS |
| 1945 | MelderAudio_stopPlaying (MelderAudio_IMPLICIT); |
| 1946 | MelderAudio_setOutputMaximumAsynchronicity (maximumAsynchronicity); |
| 1947 | MelderAudio_setOutputSilenceBefore (silenceBefore); |
| 1948 | MelderAudio_setOutputSilenceAfter (silenceAfter); |
| 1949 | MelderAudio_setOutputSoundSystem (outputSoundSystem); |
| 1950 | PREFS_END |
| 1951 | } |
| 1952 | |
| 1953 | #ifdef HAVE_PULSEAUDIO |
| 1954 | void pulseAudio_serverReport (); |
| 1955 | DIRECT (INFO_NONE__Praat_reportSoundServerProperties) { |
| 1956 | INFO_NONE |
| 1957 | pulseAudio_serverReport (); |
| 1958 | INFO_NONE_END |
| 1959 | } |
| 1960 | #endif |
| 1961 | |
| 1962 | FORM_SAVE (SAVE_ALL__Sound_saveAsAifcFile, U"Save as AIFC file", nullptr, U"aifc") { |
| 1963 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the AIFC file") |
| 1964 | LongSound_concatenate (list.get(), file, Melder_AIFC, 16); |
| 1965 | SAVE_ALL_LISTED_END |
| 1966 | } |
| 1967 | |
| 1968 | FORM_SAVE (SAVE_ALL__Sound_saveAsAiffFile, U"Save as AIFF file", nullptr, U"aiff") { |
| 1969 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the AIFF file") |
| 1970 | LongSound_concatenate (list.get(), file, Melder_AIFF, 16); |
| 1971 | SAVE_ALL_LISTED_END |
| 1972 | } |
| 1973 | |
| 1974 | FORM_SAVE (SAVE_ALL__Sound_saveAsFlacFile, U"Save as FLAC file", nullptr, U"flac") { |
| 1975 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the FLAC file") |
| 1976 | LongSound_concatenate (list.get(), file, Melder_FLAC, 16); |
| 1977 | SAVE_ALL_LISTED_END |
| 1978 | } |
| 1979 | |
| 1980 | FORM_SAVE (SAVE_ONE__Sound_saveAsKayFile, U"Save as Kay sound file", nullptr, U"kay") { |
| 1981 | SAVE_ONE (Sound, U"save the selected Sound object to the Kay sound file") |
| 1982 | Sound_saveAsKayFile (me, file); |
| 1983 | SAVE_ONE_END |
| 1984 | } |
| 1985 | |
| 1986 | FORM_SAVE (SAVE_ALL__Sound_saveAsNextSunFile, U"Save as NeXT/Sun file", nullptr, U"au") { |
| 1987 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the NeXT/Sun file") |
| 1988 | LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16); |
| 1989 | SAVE_ALL_LISTED_END |
| 1990 | } |
| 1991 | |
| 1992 | FORM_SAVE (SAVE_ALL__Sound_saveAsNistFile, U"Save as NIST file", nullptr, U"nist") { |
| 1993 | SAVE_ALL_LISTED (SampledXY, SoundAndLongSoundList, U"save the selected Sound object(s) to the NIST file") |
| 1994 | LongSound_concatenate (list.get(), file, Melder_NIST, 16); |
| 1995 | SAVE_ALL_LISTED_END |
| 1996 | } |
| 1997 | |
| 1998 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw8bitSignedFile, U"Save as raw 8-bit signed sound file", nullptr, U"8sig") { |
| 1999 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 8-bit signed sound file") |
| 2000 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_8_SIGNED); |
| 2001 | SAVE_ONE_END |
| 2002 | } |
| 2003 | |
| 2004 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw8bitUnsignedFile, U"Save as raw 8-bit unsigned sound file", nullptr, U"8uns") { |
| 2005 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 8-bit unsigned sound file") |
| 2006 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_8_UNSIGNED); |
| 2007 | SAVE_ONE_END |
| 2008 | } |
| 2009 | |
| 2010 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw16bitBigEndianFile, U"Save as raw 16-bit big-endian sound file", nullptr, U"16be") { |
| 2011 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 16-bit big-endian sound file") |
| 2012 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_16_BIG_ENDIAN); |
| 2013 | SAVE_ONE_END |
| 2014 | } |
| 2015 | |
| 2016 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw16bitLittleEndianFile, U"Save as raw 16-bit little-endian sound file", nullptr, U"16le") { |
| 2017 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 16-bit little-endian sound file") |
| 2018 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_16_LITTLE_ENDIAN); |
| 2019 | SAVE_ONE_END |
| 2020 | } |
| 2021 | |
| 2022 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw24bitBigEndianFile, U"Save as raw 24-bit big-endian sound file", nullptr, U"24be") { |
| 2023 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 24-bit big-endian sound file") |
| 2024 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_24_BIG_ENDIAN); |
| 2025 | SAVE_ONE_END |
| 2026 | } |
| 2027 | |
| 2028 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw24bitLittleEndianFile, U"Save as raw 24-bit little-endian sound file", nullptr, U"24le") { |
| 2029 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 24-bit little-endian sound file") |
| 2030 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_24_LITTLE_ENDIAN); |
| 2031 | SAVE_ONE_END |
| 2032 | } |
| 2033 | |
| 2034 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw32bitBigEndianFile, U"Save as raw 32-bit big-endian sound file", nullptr, U"32be") { |
| 2035 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 32-bit big-endian sound file") |
| 2036 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_32_BIG_ENDIAN); |
| 2037 | SAVE_ONE_END |
| 2038 | } |
| 2039 | |
| 2040 | FORM_SAVE (SAVE_ONE__Sound_saveAsRaw32bitLittleEndianFile, U"Save as raw 32-bit little-endian sound file", nullptr, U"32le") { |
| 2041 | SAVE_ONE (Sound, U"save the selected Sound object to the raw 32-bit little-endian sound file") |
| 2042 | Sound_saveAsRawSoundFile (me, file, Melder_LINEAR_32_LITTLE_ENDIAN); |
| 2043 | SAVE_ONE_END |
| 2044 | } |
| 2045 | |
| 2046 | FORM_SAVE (SAVE_ONE__Sound_saveAsSesamFile, U"Save as Sesam file", nullptr, U"sdf") { |
| 2047 | SAVE_ONE (Sound, U"save the selected Sound object to the Sesam file") |
| 2048 | Sound_saveAsSesamFile (me, file); |
| 2049 | SAVE_ONE_END |
| 2050 | } |
| 2051 | |
| 2052 | FORM_SAVE (SAVE_ALL__Sound_saveAsStereoAifcFile, U"Save as stereo AIFC file", nullptr, U"aifc") { |
| 2053 | SAVE_ALL (Sound, U"save the selected Sound objects to the stereo AIFC file") |
| 2054 | autoSound stereo = Sounds_combineToStereo (& list); |
| 2055 | Sound_saveAsAudioFile (stereo.get(), file, Melder_AIFC, 16); |
| 2056 | SAVE_ALL_END |
| 2057 | } |
| 2058 | |
| 2059 | FORM_SAVE (SAVE_ALL__Sound_saveAsStereoAiffFile, U"Save as stereo AIFF file", nullptr, U"aiff") { |
| 2060 | SAVE_ALL (Sound, U"save the selected Sound objects to the stereo AIFF file") |
| 2061 | autoSound stereo = Sounds_combineToStereo (& list); |
| 2062 | Sound_saveAsAudioFile (stereo.get(), file, Melder_AIFF, 16); |
| 2063 | SAVE_ALL_END |
| 2064 | } |
| 2065 | |
| 2066 | FORM_SAVE (SAVE_ALL__Sound_saveAsStereoNextSunFile, U"Save as stereo NeXT/Sun file", nullptr, U"au") { |
| 2067 | SAVE_ALL (Sound, U"save the selected Sound objects to the stereo NeXT/Sun file") |
| 2068 | autoSound stereo = Sounds_combineToStereo (& list); |
| 2069 | Sound_saveAsAudioFile (stereo.get(), file, Melder_NEXT_SUN, 16); |
| 2070 | SAVE_ALL_END |
| 2071 | } |
| 2072 | |
| 2073 | FORM_SAVE (SAVE_ALL__Sound_saveAsStereoNistFile, U"Save as stereo NIST file", nullptr, U"nist") { |
| 2074 | SAVE_ALL (Sound, U"save the selected Sound objects to the stereo NIST file") |
| 2075 | autoSound stereo = Sounds_combineToStereo (& list); |
| 2076 | Sound_saveAsAudioFile (stereo.get(), file, Melder_NIST, 16); |
| 2077 | SAVE_ALL_END |
| 2078 | } |
| 2079 | |
| 2080 | FORM_SAVE (SAVE_ALL__Sound_saveAsStereoFlacFile, U"Save as stereo FLAC file", nullptr, U"flac") { |
| 2081 | SAVE_ALL (Sound, U"save the selected Sound objects to the stereo FLAC file") |
| 2082 | autoSound stereo = Sounds_combineToStereo (& list); |
| 2083 | Sound_saveAsAudioFile (stereo.get(), file, Melder_FLAC, 16); |
| 2084 | SAVE_ALL_END |
| 2085 | } |
| 2086 | |
| 2087 | FORM_SAVE (SAVE_ALL__Sound_saveAsStereoWavFile, U"Save as stereo WAV file", nullptr, U"wav") { |
| 2088 | SAVE_ALL (Sound, U"save the selected Sound objects to the stereo WAV file") |
| 2089 | autoSound stereo = Sounds_combineToStereo (& list); |
| 2090 | Sound_saveAsAudioFile (stereo.get(), file, Melder_WAV, 16); |
| 2091 | SAVE_ALL_END |
| 2092 | } |
| 2093 | |
| 2094 | FORM_SAVE (SAVE_ALL__Sound_saveAsSunAudioFile, U"Save as NeXT/Sun file", nullptr, U"au") { |
| 2095 | SAVE_ALL_LISTED (Sound, SoundAndLongSoundList, U"save the selected Sound object(s) to the NeXT/Sun file") |
| 2096 | LongSound_concatenate (list.get(), file, Melder_NEXT_SUN, 16); |
| 2097 | SAVE_ALL_LISTED_END |
| 2098 | } |
| 2099 | |
| 2100 | FORM_SAVE (SAVE_ALL__Sound_saveAsWavFile, U"Save as WAV file", nullptr, U"wav") { |
| 2101 | SAVE_ALL_LISTED (Sound, SoundAndLongSoundList, U"save the selected Sound object(s) to the WAV file") |
| 2102 | LongSound_concatenate (list.get(), file, Melder_WAV, 16); |
| 2103 | SAVE_ALL_LISTED_END |
| 2104 | } |
| 2105 | |
| 2106 | /***** SOUNDLIST *****/ |
| 2107 | |
| 2108 | DIRECT (CONVERT_EACH_TO_MULTIPLE__SoundList_extractAllSounds) { |
| 2109 | CONVERT_EACH_TO_MULTIPLE (SoundList) |
| 2110 | autoSoundList result = Data_copy (me); |
| 2111 | result -> classInfo = classCollection; // YUCK, in order to force automatic unpacking |
| 2112 | praat_new (result.move(), U"dummy"); |
| 2113 | CONVERT_EACH_TO_MULTIPLE_END |
| 2114 | } |
| 2115 | |
| 2116 | /***** SOUNDSET *****/ |
| 2117 | |
| 2118 | DIRECT (CONVERT_EACH_TO_MULTIPLE__SoundSet_extractAllSounds) { |
| 2119 | CONVERT_EACH_TO_MULTIPLE (SoundSet) |
| 2120 | autoSoundSet result = Data_copy (me); |
| 2121 | result -> classInfo = classCollection; // YUCK, in order to force automatic unpacking |
| 2122 | praat_new (result.move(), U"dummy"); |
| 2123 | CONVERT_EACH_TO_MULTIPLE_END |
| 2124 | } |
| 2125 | |
| 2126 | FORM (CONVERT_ONE_AND_ONE_TO_MULTIPLE__SoundSet_Table_getRandomizedPatterns, U"SoundSet & Table: Get randomized patterns", nullptr) { |
| 2127 | SENTENCE (columnName, U"Column name", U"") |
| 2128 | NATURAL (numberOfPatterns, U"Number of patterns", U"1000") |
| 2129 | NATURAL (inputSize, U"Input size (number of samples)", U"8000") |
| 2130 | NATURAL (outputSize, U"Output size (number of classes)", U"5") |
| 2131 | OK |
| 2132 | DO |
| 2133 | CONVERT_ONE_AND_ONE_TO_MULTIPLE (SoundSet, Table) |
| 2134 | autoPatternList inputs, outputs; |
| 2135 | SoundSet_Table_getRandomizedPatterns (me, you, columnName, numberOfPatterns, inputSize, outputSize, |
| 2136 | & inputs, & outputs); |
| 2137 | praat_new (inputs.move(), U"inputs"); |
| 2138 | praat_new (outputs.move(), U"outputs"); |
| 2139 | CONVERT_ONE_AND_ONE_TO_MULTIPLE_END |
| 2140 | } |
| 2141 | |
| 2142 | /***** STOP *****/ |
| 2143 | |
| 2144 | DIRECT (PLAY__stopPlayingSound) { |
| 2145 | PLAY_NONE |
| 2146 | MelderAudio_stopPlaying (MelderAudio_IMPLICIT); |
| 2147 | PLAY_NONE_END |
| 2148 | } |
| 2149 | |
| 2150 | /***** Help menus *****/ |
| 2151 | |
| 2152 | DIRECT (HELP__AnnotationTutorial) { |
| 2153 | HELP (U"Intro 7. Annotation") |
| 2154 | } |
| 2155 | |
| 2156 | DIRECT (HELP__FilteringTutorial) { |
| 2157 | HELP (U"Filtering") |
| 2158 | } |
| 2159 | |
| 2160 | /***** file recognizers *****/ |
| 2161 | |
| 2162 | static autoDaata soundFileRecognizer (integer nread, const char *header, MelderFile file) { |
| 2163 | if (nread < 16) |
| 2164 | return autoDaata (); |
| 2165 | if (strnequ (header, "FORM", 4) && strnequ (header + 8, "AIF", 3)) |
| 2166 | return Sound_readFromSoundFile (file); |
| 2167 | if (strnequ (header, "RIFF", 4) && (strnequ (header + 8, "WAVE", 4) || strnequ (header + 8, "CDDA", 4))) |
| 2168 | return Sound_readFromSoundFile (file); |
| 2169 | if (strnequ (header, ".snd", 4)) |
| 2170 | return Sound_readFromSoundFile (file); |
| 2171 | if (strnequ (header, "NIST_1A", 7)) |
| 2172 | return Sound_readFromSoundFile (file); |
| 2173 | if (strnequ (header, "fLaC", 4)) |
| 2174 | return Sound_readFromSoundFile (file); // Erez Volk, March 2007 |
| 2175 | if ((Melder_endsWith_caseAware (MelderFile_name (file), U".mp3")) |
| 2176 | && mp3_recognize (nread, header)) |
| 2177 | return Sound_readFromSoundFile (file); // Erez Volk, May 2007 |
| 2178 | return autoDaata (); |
| 2179 | } |
| 2180 | |
| 2181 | static autoDaata movieFileRecognizer (integer nread, const char * /* header */, MelderFile file) { |
| 2182 | conststring32 fileName = MelderFile_name (file); |
| 2183 | if (nread < 512 || (! Melder_endsWith_caseAware (fileName, U".mov") && |
| 2184 | ! Melder_endsWith_caseAware (fileName, U".avi"))) |
| 2185 | return autoDaata (); |
| 2186 | Melder_throw (U"This Praat version cannot open movie files."); |
| 2187 | return autoDaata (); |
| 2188 | } |
| 2189 | |
| 2190 | static autoDaata sesamFileRecognizer (integer nread, const char * /* header */, MelderFile file) { |
| 2191 | conststring32 fileName = MelderFile_name (file); |
| 2192 | if (nread < 512 || (! Melder_endsWith_caseAware (fileName, U".sdf"))) |
| 2193 | return autoDaata (); |
| 2194 | return Sound_readFromSesamFile (file); |
| 2195 | } |
| 2196 | |
| 2197 | static autoDaata bellLabsFileRecognizer (integer nread, const char *header, MelderFile file) { |
| 2198 | if (nread < 16 || ! strnequ (& header [0], "SIG\n", 4)) |
| 2199 | return autoDaata (); |
| 2200 | return Sound_readFromBellLabsFile (file); |
| 2201 | } |
| 2202 | |
| 2203 | static autoDaata kayFileRecognizer (integer nread, const char *header, MelderFile file) { |
| 2204 | if (nread <= 12 || ! strnequ (& header [0], "FORMDS16", 8)) |
| 2205 | return autoDaata (); |
| 2206 | return Sound_readFromAnyKayFile (file); |
| 2207 | } |
| 2208 | |
| 2209 | /***** override play and record buttons in manuals *****/ |
| 2210 | |
| 2211 | static autoSound melderSound, melderSoundFromFile; |
| 2212 | static Sound last; |
| 2213 | static int recordProc (double duration) { |
| 2214 | if (last == melderSound.get()) |
| 2215 | last = nullptr; |
| 2216 | MelderAudio_stopPlaying (MelderAudio_IMPLICIT); |
| 2217 | melderSound = Sound_record_fixedTime (1, 1.0, 0.5, 44100, duration); |
| 2218 | if (! melderSound) |
| 2219 | return 0; |
| 2220 | last = melderSound.get(); |
| 2221 | return 1; |
| 2222 | } |
| 2223 | static int recordFromFileProc (MelderFile file) { |
| 2224 | if (last == melderSoundFromFile.get()) |
| 2225 | last = nullptr; |
| 2226 | Melder_warningOff (); // like "missing samples" |
| 2227 | melderSoundFromFile = Data_readFromFile (file).static_cast_move <structSound>(); |
| 2228 | Melder_warningOn (); |
| 2229 | if (! melderSoundFromFile) |
| 2230 | return 0; |
| 2231 | if (! Thing_isa (melderSoundFromFile.get(), classSound)) { |
| 2232 | melderSoundFromFile. reset(); |
| 2233 | return 0; |
| 2234 | } |
| 2235 | last = melderSoundFromFile.get(); |
| 2236 | Sound_play (melderSoundFromFile.get(), nullptr, nullptr); |
| 2237 | return 1; |
| 2238 | } |
| 2239 | static void playProc () { |
| 2240 | if (melderSound) { |
| 2241 | Sound_play (melderSound.get(), nullptr, nullptr); |
| 2242 | last = melderSound.get(); |
| 2243 | } |
| 2244 | } |
| 2245 | static void playReverseProc () { |
| 2246 | /*if (melderSound) Sound_playReverse (melderSound);*/ |
| 2247 | } |
| 2248 | static int publishPlayedProc () { |
| 2249 | if (! last) |
| 2250 | return 0; |
| 2251 | autoSound sound = Data_copy (last); |
| 2252 | return Data_publish (sound.move()); |
| 2253 | } |
| 2254 | |
| 2255 | /***** buttons *****/ |
| 2256 | |
| 2257 | void praat_Sound_init () { |
| 2258 | Thing_recognizeClassesByName (classSound, classLongSound, classSoundList, classSoundSet); |
| 2259 | |
| 2260 | Data_recognizeFileType (soundFileRecognizer); |
| 2261 | Data_recognizeFileType (movieFileRecognizer); |
| 2262 | Data_recognizeFileType (sesamFileRecognizer); |
| 2263 | Data_recognizeFileType (bellLabsFileRecognizer); |
| 2264 | Data_recognizeFileType (kayFileRecognizer); |
| 2265 | |
| 2266 | structSoundArea :: f_preferences (); |
| 2267 | structSoundAnalysisArea :: f_preferences (); |
| 2268 | |
| 2269 | SoundRecorder_preferences (); |
| 2270 | structSoundRecorder :: f_preferences (); |
| 2271 | structFunctionEditor :: f_preferences (); |
| 2272 | LongSound_preferences (); |
| 2273 | |
| 2274 | Melder_setRecordProc (recordProc); |
| 2275 | Melder_setRecordFromFileProc (recordFromFileProc); |
| 2276 | Melder_setPlayProc (playProc); |
| 2277 | Melder_setPlayReverseProc (playReverseProc); |
| 2278 | Melder_setPublishPlayedProc (publishPlayedProc); |
| 2279 | |
| 2280 | praat_addMenuCommand (U"Objects", U"New", U"Record mono Sound...", nullptr, GuiMenu_ATTRACTIVE | 'R' | GuiMenu_NO_API, |
| 2281 | SINGLETON_CREATION_WINDOW__Sound_recordMono); |
| 2282 | praat_addMenuCommand (U"Objects", U"New", U"Record stereo Sound...", nullptr, GuiMenu_NO_API, |
| 2283 | SINGLETON_CREATION_WINDOW__Sound_recordStereo); |
| 2284 | praat_addMenuCommand (U"Objects", U"New", U"Record Sound (fixed time)...", nullptr, GuiMenu_HIDDEN | GuiMenu_FORCE_API, |
| 2285 | RECORD_ONE__Sound_record_fixedTime); |
| 2286 | praat_addMenuCommand (U"Objects", U"New", U"Sound", nullptr, 0, nullptr); |
| 2287 | praat_addMenuCommand (U"Objects", U"New", U"Create Sound as pure tone...", nullptr, 1, |
| 2288 | CREATE_ONE__Sound_createAsPureTone); |
| 2289 | praat_addMenuCommand (U"Objects", U"New", U"Create Sound from formula...", nullptr, 1, |
| 2290 | CREATE_ONE__Sound_createFromFormula); |
| 2291 | praat_addMenuCommand (U"Objects", U"New", U"Create Sound...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2007, |
| 2292 | CREATE_ONE__Sound_create); // replace with Create Sound from formula: arg1, 1, arg2, arg3, arg4, arg5 |
| 2293 | praat_addMenuCommand (U"Objects", U"New", U"-- create sound advanced --", nullptr, 1, nullptr); |
| 2294 | praat_addMenuCommand (U"Objects", U"New", U"Create Sound as tone complex... || Create Sound from tone complex...", nullptr, 1, |
| 2295 | CREATE_ONE__Sound_createAsToneComplex); // alternative COMPATIBILITY <= 2013 |
| 2296 | |
| 2297 | praat_addMenuCommand (U"Objects", U"Open", U"-- read sound --", nullptr, 0, nullptr); |
| 2298 | praat_addMenuCommand (U"Objects", U"Open", U"Open long sound file...", nullptr, 'L', READ_ONE__LongSound_open); |
| 2299 | praat_addMenuCommand (U"Objects", U"Open", U"Read separate channels from sound file... || Read two Sounds from stereo file...", nullptr, 0, |
| 2300 | READ_MULTIPLE__Sound_readSeparateChannelsFromSoundFile); // alternative COMPATIBILITY <= 2010 |
| 2301 | praat_addMenuCommand (U"Objects", U"Open", U"Read from special sound file", nullptr, 0, nullptr); |
| 2302 | praat_addMenuCommand (U"Objects", U"Open", U"Read Sound from raw Alaw file...", nullptr, GuiMenu_DEPTH_1, READ_ONE__Sound_readFromRawAlawFile); |
| 2303 | |
| 2304 | praat_addMenuCommand (U"Objects", U"Goodies", U"-- sound goodies --", nullptr, 0, nullptr); |
| 2305 | praat_addMenuCommand (U"Objects", U"Goodies", U"Stop playing sound", nullptr, GuiMenu_ESCAPE, |
| 2306 | PLAY__stopPlayingSound); |
| 2307 | praat_addMenuCommand (U"Objects", U"Settings", U"-- sound settings --", nullptr, 0, nullptr); |
| 2308 | praat_addMenuCommand (U"Objects", U"Settings", U"Sound recording settings... || Sound recording preferences...", nullptr, 0, |
| 2309 | SETTINGS__SoundRecordingSettings); // alternative GuiMenu_DEPRECATED_2023 |
| 2310 | praat_addMenuCommand (U"Objects", U"Settings", U"Sound playing settings... || Sound playing preferences...", nullptr, 0, |
| 2311 | SETTINGS__SoundPlayingSettings); // alternative GuiMenu_DEPRECATED_2023 |
| 2312 | praat_addMenuCommand (U"Objects", U"Settings", U"LongSound settings... || LongSound preferences...", nullptr, 0, |
| 2313 | SETTINGS__LongSoundSettings); // alternative GuiMenu_DEPRECATED_2023 |
| 2314 | #ifdef HAVE_PULSEAUDIO |
| 2315 | praat_addMenuCommand (U"Objects", U"Technical", U"Report sound server properties", U"Report system properties", 0, |
| 2316 | INFO_NONE__Praat_reportSoundServerProperties); |
| 2317 | #endif |
| 2318 | |
| 2319 | praat_addAction1 (classLongSound, 0, U"LongSound help", nullptr, 0, |
| 2320 | HELP__LongSound_help); |
| 2321 | praat_addAction1 (classLongSound, 1, U"View || Open", nullptr, GuiMenu_ATTRACTIVE, |
| 2322 | EDITOR_ONE__LongSound_view); // alternative COMPATIBILITY <= 2011 |
| 2323 | praat_addAction1 (classLongSound, 0, U"Play part...", nullptr, 0, PLAY_LongSound_playPart); |
| 2324 | praat_addAction1 (classLongSound, 1, U"Query -", nullptr, 0, nullptr); |
| 2325 | praat_TimeFunction_query_init (classLongSound); |
| 2326 | praat_addAction1 (classLongSound, 1, U"Sampling", nullptr, 1, nullptr); |
| 2327 | praat_addAction1 (classLongSound, 1, U"Get number of samples", nullptr, 2, INTEGER_LongSound_getNumberOfSamples); |
| 2328 | praat_addAction1 (classLongSound, 1, U"Get sampling period || Get sample duration || Get sample period", |
| 2329 | nullptr, 2, REAL_LongSound_getSamplePeriod); // alternatives COMPATIBILITY <= 2004 |
| 2330 | praat_addAction1 (classLongSound, 1, U"Get sampling frequency || Get sample rate", |
| 2331 | nullptr, 2, REAL_LongSound_getSampleRate); // alternative COMPATIBILITY <= 2004 |
| 2332 | praat_addAction1 (classLongSound, 1, U"-- get time discretization --", nullptr, 2, nullptr); |
| 2333 | praat_addAction1 (classLongSound, 1, U"Get time from sample number... || Get time from index...", |
| 2334 | nullptr, 2, REAL_LongSound_getTimeFromIndex); // alternative COMPATIBILITY <= 2004 |
| 2335 | praat_addAction1 (classLongSound, 1, U"Get sample number from time... || Get index from time...", |
| 2336 | nullptr, 2, REAL_LongSound_getIndexFromTime); // alternative COMPATIBILITY <= 2004 |
| 2337 | praat_addAction1 (classLongSound, 0, U"Annotate -", nullptr, 0, nullptr); |
| 2338 | praat_addAction1 (classLongSound, 0, U"Annotation tutorial", nullptr, 1, |
| 2339 | HELP__AnnotationTutorial); |
| 2340 | praat_addAction1 (classLongSound, 0, U"-- to text grid --", nullptr, 1, nullptr); |
| 2341 | praat_addAction1 (classLongSound, 0, U"To TextGrid...", nullptr, 1, NEW_LongSound_to_TextGrid); |
| 2342 | praat_addAction1 (classLongSound, 0, U"Convert to Sound", nullptr, 0, nullptr); |
| 2343 | praat_addAction1 (classLongSound, 0, U"Extract part...", nullptr, 0, NEW_LongSound_extractPart); |
| 2344 | praat_addAction1 (classLongSound, 0, U"Concatenate?", nullptr, 0, |
| 2345 | INFO_NONE__LongSound_concatenate); |
| 2346 | praat_addAction1 (classLongSound, 0, U"Save as WAV file... || Write to WAV file...", |
| 2347 | nullptr, 0, SAVE_ALL__LongSound_saveAsWavFile); // alternative COMPATIBILITY <= 2011 |
| 2348 | praat_addAction1 (classLongSound, 0, U"Save as AIFF file... || Write to AIFF file...", |
| 2349 | nullptr, 0, SAVE_ALL__LongSound_saveAsAiffFile); |
| 2350 | praat_addAction1 (classLongSound, 0, U"Save as AIFC file... || Write to AIFC file...", |
| 2351 | nullptr, 0, SAVE_ALL__LongSound_saveAsAifcFile); |
| 2352 | praat_addAction1 (classLongSound, 0, U"Save as NeXT/Sun file... || Write to NeXT/Sun file...", |
| 2353 | nullptr, 0, SAVE_ALL__LongSound_saveAsNextSunFile); |
| 2354 | praat_addAction1 (classLongSound, 0, U"Save as NIST file... || Write to NIST file...", |
| 2355 | nullptr, 0, SAVE_ALL__LongSound_saveAsNistFile); |
| 2356 | praat_addAction1 (classLongSound, 0, U"Save as FLAC file... || Write to FLAC file...", |
| 2357 | nullptr, 0, SAVE_ALL__LongSound_saveAsFlacFile); |
| 2358 | praat_addAction1 (classLongSound, 1, U"Save left channel as WAV file... || Write left channel to WAV file...", |
| 2359 | nullptr, 0, SAVE_ONE__LongSound_saveLeftChannelAsWavFile); |
| 2360 | praat_addAction1 (classLongSound, 1, U"Save left channel as AIFF file... || Write left channel to AIFF file...", |
| 2361 | nullptr, 0, SAVE_ONE__LongSound_saveLeftChannelAsAiffFile); |
| 2362 | praat_addAction1 (classLongSound, 1, U"Save left channel as AIFC file... || Write left channel to AIFC file...", |
| 2363 | nullptr, 0, SAVE_ONE__LongSound_saveLeftChannelAsAifcFile); |
| 2364 | praat_addAction1 (classLongSound, 1, U"Save left channel as NeXT/Sun file... || Write left channel to NeXT/Sun file...", |
| 2365 | nullptr, 0, SAVE_ONE__LongSound_saveLeftChannelAsNextSunFile); |
| 2366 | praat_addAction1 (classLongSound, 1, U"Save left channel as NIST file... || Write left channel to NIST file...", |
| 2367 | nullptr, 0, SAVE_ONE__LongSound_saveLeftChannelAsNistFile); |
| 2368 | praat_addAction1 (classLongSound, 1, U"Save left channel as FLAC file... || Write left channel to FLAC file...", |
| 2369 | nullptr, 0, SAVE_ONE__LongSound_saveLeftChannelAsFlacFile); |
| 2370 | praat_addAction1 (classLongSound, 1, U"Save right channel as WAV file... || Write right channel to WAV file...", |
| 2371 | nullptr, 0, SAVE_ONE__LongSound_saveRightChannelAsWavFile); |
| 2372 | praat_addAction1 (classLongSound, 1, U"Save right channel as AIFF file... || Write right channel to AIFF file...", |
| 2373 | nullptr, 0, SAVE_ONE__LongSound_saveRightChannelAsAiffFile); |
| 2374 | praat_addAction1 (classLongSound, 1, U"Save right channel as AIFC file... || Write right channel to AIFC file...", |
| 2375 | nullptr, 0, SAVE_ONE__LongSound_saveRightChannelAsAifcFile); |
| 2376 | praat_addAction1 (classLongSound, 1, U"Save right channel as NeXT/Sun file... || Write right channel to NeXT/Sun file...", |
| 2377 | nullptr, 0, SAVE_ONE__LongSound_saveRightChannelAsNextSunFile); |
| 2378 | praat_addAction1 (classLongSound, 1, U"Save right channel as NIST file... || Write right channel to NIST file...", |
| 2379 | nullptr, 0, SAVE_ONE__LongSound_saveRightChannelAsNistFile); |
| 2380 | praat_addAction1 (classLongSound, 1, U"Save right channel as FLAC file... || Write right channel to FLAC file...", |
| 2381 | nullptr, 0, SAVE_ONE__LongSound_saveRightChannelAsFlacFile); |
| 2382 | praat_addAction1 (classLongSound, 1, U"Save part as audio file... || Write part to audio file...", |
| 2383 | nullptr, 0, SAVE_ONE__LongSound_savePartAsAudioFile); |
| 2384 | |
| 2385 | praat_addAction1 (classSound, 0, U"Save as WAV file... || Write to WAV file...", |
| 2386 | nullptr, 0, SAVE_ALL__Sound_saveAsWavFile); // alternative COMPATIBILITY <= 2011 |
| 2387 | praat_addAction1 (classSound, 0, U"Save as AIFF file... || Write to AIFF file...", |
| 2388 | nullptr, 0, SAVE_ALL__Sound_saveAsAiffFile); |
| 2389 | praat_addAction1 (classSound, 0, U"Save as AIFC file... || Write to AIFC file...", |
| 2390 | nullptr, 0, SAVE_ALL__Sound_saveAsAifcFile); |
| 2391 | praat_addAction1 (classSound, 0, U"Save as NeXT/Sun file... || Write to NeXT/Sun file...", |
| 2392 | nullptr, 0, SAVE_ALL__Sound_saveAsNextSunFile); |
| 2393 | praat_addAction1 (classSound, 0, U"Save as Sun audio file... || Write to Sun audio file...", |
| 2394 | nullptr, GuiMenu_HIDDEN, SAVE_ALL__Sound_saveAsSunAudioFile); |
| 2395 | praat_addAction1 (classSound, 0, U"Save as NIST file... || Write to NIST file...", |
| 2396 | nullptr, 0, SAVE_ALL__Sound_saveAsNistFile); |
| 2397 | praat_addAction1 (classSound, 0, U"Save as FLAC file... || Write to FLAC file...", |
| 2398 | nullptr, 0, SAVE_ALL__Sound_saveAsFlacFile); |
| 2399 | praat_addAction1 (classSound, 1, U"Save as Kay sound file... || Write to Kay sound file...", |
| 2400 | nullptr, 0, SAVE_ONE__Sound_saveAsKayFile); |
| 2401 | praat_addAction1 (classSound, 1, U"Save as Sesam file... || Write to Sesam file...", |
| 2402 | nullptr, GuiMenu_HIDDEN, SAVE_ONE__Sound_saveAsSesamFile); |
| 2403 | praat_addAction1 (classSound, 0, U"Save as 24-bit WAV file...", nullptr, 0, |
| 2404 | SAVE_ALL__Sound_saveAs24BitWavFile); |
| 2405 | praat_addAction1 (classSound, 0, U"Save as 32-bit WAV file...", nullptr, 0, |
| 2406 | SAVE_ALL__Sound_saveAs32BitWavFile); |
| 2407 | praat_addAction1 (classSound, 2, U"Write to stereo WAV file...", nullptr, GuiMenu_DEPRECATED_2007, |
| 2408 | SAVE_ALL__Sound_saveAsStereoWavFile); // replace with "Combine to stereo" and "Save to WAV file..." |
| 2409 | praat_addAction1 (classSound, 2, U"Write to stereo AIFF file...", nullptr, GuiMenu_DEPRECATED_2007, |
| 2410 | SAVE_ALL__Sound_saveAsStereoAiffFile); // replace with "Combine to stereo" and "Save to AIFF file..." |
| 2411 | praat_addAction1 (classSound, 2, U"Write to stereo AIFC file...", nullptr, GuiMenu_DEPRECATED_2007, |
| 2412 | SAVE_ALL__Sound_saveAsStereoAifcFile); // replace with "Combine to stereo" and "Save to AIFC file..." |
| 2413 | praat_addAction1 (classSound, 2, U"Write to stereo NeXT/Sun file...", nullptr, GuiMenu_DEPRECATED_2007, |
| 2414 | SAVE_ALL__Sound_saveAsStereoNextSunFile); // replace with "Combine to stereo" and "Save to NeXT/Sun file..." |
| 2415 | praat_addAction1 (classSound, 2, U"Write to stereo NIST file...", nullptr, GuiMenu_DEPRECATED_2007, |
| 2416 | SAVE_ALL__Sound_saveAsStereoNistFile); // replace with "Combine to stereo" and "Save to NIST file..." |
| 2417 | praat_addAction1 (classSound, 2, U"Write to stereo FLAC file...", nullptr, GuiMenu_DEPRECATED_2007, |
| 2418 | SAVE_ALL__Sound_saveAsStereoFlacFile); // replace with "Combine to stereo" and "Save to FLAC file..." |
| 2419 | //praat_addAction1 (classSound, 1, U"Save as raw sound file", nullptr, 0, nullptr); |
| 2420 | praat_addAction1 (classSound, 1, U"Save as raw 8-bit signed file... || Write to raw 8-bit signed file...", |
| 2421 | nullptr, 0, SAVE_ONE__Sound_saveAsRaw8bitSignedFile); |
| 2422 | praat_addAction1 (classSound, 1, U"Save as raw 8-bit unsigned file... || Write to raw 8-bit unsigned file...", |
| 2423 | nullptr, 0, SAVE_ONE__Sound_saveAsRaw8bitUnsignedFile); |
| 2424 | praat_addAction1 (classSound, 1, U"Save as raw 16-bit big-endian file...", nullptr, 0, |
| 2425 | SAVE_ONE__Sound_saveAsRaw16bitBigEndianFile); |
| 2426 | praat_addAction1 (classSound, 1, U"Save as raw 16-bit little-endian file...", nullptr, 0, |
| 2427 | SAVE_ONE__Sound_saveAsRaw16bitLittleEndianFile); |
| 2428 | praat_addAction1 (classSound, 1, U"Save as raw 24-bit big-endian file...", nullptr, 0, |
| 2429 | SAVE_ONE__Sound_saveAsRaw24bitBigEndianFile); |
| 2430 | praat_addAction1 (classSound, 1, U"Save as raw 24-bit little-endian file...", nullptr, 0, |
| 2431 | SAVE_ONE__Sound_saveAsRaw24bitLittleEndianFile); |
| 2432 | praat_addAction1 (classSound, 1, U"Save as raw 32-bit big-endian file...", nullptr, 0, |
| 2433 | SAVE_ONE__Sound_saveAsRaw32bitBigEndianFile); |
| 2434 | praat_addAction1 (classSound, 1, U"Save as raw 32-bit little-endian file...", nullptr, 0, |
| 2435 | SAVE_ONE__Sound_saveAsRaw32bitLittleEndianFile); |
| 2436 | praat_addAction1 (classSound, 0, U"Sound help", nullptr, 0, |
| 2437 | HELP__Sound_help); |
| 2438 | praat_addAction1 (classSound, 1, U"View & Edit || Edit || Open", |
| 2439 | nullptr, GuiMenu_ATTRACTIVE | GuiMenu_NO_API, EDITOR_ONE__Sound_viewAndEdit); |
| 2440 | praat_addAction1 (classSound, 0, U"Play", nullptr, 0, |
| 2441 | PLAY_EACH__Sound_play); |
| 2442 | praat_addAction1 (classSound, 1, U"Draw -", nullptr, 0, nullptr); |
| 2443 | praat_addAction1 (classSound, 0, U"Draw...", nullptr, 1, |
| 2444 | GRAPHICS_EACH__Sound_draw); |
| 2445 | praat_addAction1 (classSound, 1, U"Query -", nullptr, 0, nullptr); |
| 2446 | praat_TimeFunction_query_init (classSound); |
| 2447 | praat_addAction1 (classSound, 1, U"Get number of channels", nullptr, 1, |
| 2448 | QUERY_ONE_FOR_INTEGER__Sound_getNumberOfChannels); |
| 2449 | praat_addAction1 (classSound, 1, U"Query time sampling", nullptr, 1, nullptr); |
| 2450 | praat_addAction1 (classSound, 1, U"Get number of samples", nullptr, 2, |
| 2451 | QUERY_ONE_FOR_INTEGER__Sound_getNumberOfSamples); |
| 2452 | praat_addAction1 (classSound, 1, U"Get sampling period || Get sample duration || Get sample period", |
| 2453 | nullptr, 2, QUERY_ONE_FOR_REAL__Sound_getSamplePeriod); // alternatives COMPATIBILITY <= 2004 |
| 2454 | praat_addAction1 (classSound, 1, U"Get sampling frequency || Get sample rate", |
| 2455 | nullptr, 2, QUERY_ONE_FOR_REAL__Sound_getSampleRate); // alternative COMPATIBILITY <= 2004 |
| 2456 | praat_addAction1 (classSound, 1, U"-- get time discretization --", nullptr, 2, nullptr); |
| 2457 | praat_addAction1 (classSound, 1, U"Get time from sample number... || Get time from index...", |
| 2458 | nullptr, 2, QUERY_ONE_FOR_REAL__Sound_getTimeFromIndex); // alternative COMPATIBILITY <= 2004 |
| 2459 | praat_addAction1 (classSound, 1, U"List all sample times || Get sample times", |
| 2460 | nullptr, 2, NUMVEC_Sound_listAllSampleTimes); // alternative GuiMenu_DEPRECATED_2004 |
| 2461 | praat_addAction1 (classSound, 1, U"Get sample number from time... || Get index from time...", |
| 2462 | nullptr, 2, QUERY_ONE_FOR_REAL__Sound_getIndexFromTime); // alternative COMPATIBILITY <= 2004 |
| 2463 | praat_addAction1 (classSound, 1, U"-- get content --", nullptr, 1, nullptr); |
| 2464 | praat_addAction1 (classSound, 1, U"Get value at time...", nullptr, 1, |
| 2465 | QUERY_ONE_FOR_REAL__Sound_getValueAtTime); |
| 2466 | praat_addAction1 (classSound, 1, U"Get value at sample number... || Get value at index...", |
| 2467 | nullptr, 1, QUERY_ONE_FOR_REAL__Sound_getValueAtIndex); // alternative COMPATIBILITY <= 2004 |
| 2468 | praat_addAction1 (classSound, 1, U"-- get shape --", nullptr, 1, nullptr); |
| 2469 | praat_addAction1 (classSound, 1, U"Get minimum...", nullptr, 1, |
| 2470 | QUERY_ONE_FOR_REAL__Sound_getMinimum); |
| 2471 | praat_addAction1 (classSound, 1, U"Get time of minimum...", nullptr, 1, |
| 2472 | QUERY_ONE_FOR_REAL__Sound_getTimeOfMinimum); |
| 2473 | praat_addAction1 (classSound, 1, U"Get maximum...", nullptr, 1, |
| 2474 | QUERY_ONE_FOR_REAL__Sound_getMaximum); |
| 2475 | praat_addAction1 (classSound, 1, U"Get time of maximum...", nullptr, 1, |
| 2476 | QUERY_ONE_FOR_REAL__Sound_getTimeOfMaximum); |
| 2477 | praat_addAction1 (classSound, 1, U"Get absolute extremum...", nullptr, 1, |
| 2478 | QUERY_ONE_FOR_REAL__Sound_getAbsoluteExtremum); |
| 2479 | praat_addAction1 (classSound, 1, U"Get nearest zero crossing...", nullptr, 1, |
| 2480 | QUERY_ONE_FOR_REAL__Sound_getNearestZeroCrossing); |
| 2481 | praat_addAction1 (classSound, 1, U"-- get statistics --", nullptr, 1, nullptr); |
| 2482 | praat_addAction1 (classSound, 1, U"Get mean...", nullptr, 1, |
| 2483 | QUERY_ONE_FOR_REAL__Sound_getMean); |
| 2484 | praat_addAction1 (classSound, 1, U"Get root-mean-square...", nullptr, 1, |
| 2485 | QUERY_ONE_FOR_REAL__Sound_getRootMeanSquare); |
| 2486 | praat_addAction1 (classSound, 1, U"Get standard deviation...", nullptr, 1, |
| 2487 | QUERY_ONE_FOR_REAL__Sound_getStandardDeviation); |
| 2488 | praat_addAction1 (classSound, 1, U"-- get energy --", nullptr, 1, nullptr); |
| 2489 | praat_addAction1 (classSound, 1, U"Get energy...", nullptr, 1, |
| 2490 | QUERY_ONE_FOR_REAL__Sound_getEnergy); |
| 2491 | praat_addAction1 (classSound, 1, U"Get power...", nullptr, 1, |
| 2492 | QUERY_ONE_FOR_REAL__Sound_getPower); |
| 2493 | praat_addAction1 (classSound, 1, U"-- get energy in air --", nullptr, 1, nullptr); |
| 2494 | praat_addAction1 (classSound, 1, U"Get energy in air", nullptr, 1, |
| 2495 | QUERY_ONE_FOR_REAL__Sound_getEnergyInAir); |
| 2496 | praat_addAction1 (classSound, 1, U"Get power in air", nullptr, 1, |
| 2497 | QUERY_ONE_FOR_REAL__Sound_getPowerInAir); |
| 2498 | praat_addAction1 (classSound, 1, U"Get intensity (dB)", nullptr, 1, |
| 2499 | QUERY_ONE_FOR_REAL__Sound_getIntensity_dB); |
| 2500 | praat_addAction1 (classSound, 0, U"Modify -", nullptr, 0, nullptr); |
| 2501 | praat_TimeFunction_modify_init (classSound); |
| 2502 | praat_addAction1 (classSound, 0, U"-- modify generic --", nullptr, 1, nullptr); |
| 2503 | praat_addAction1 (classSound, 0, U"Reverse", nullptr, 1, MODIFY_Sound_reverse); |
| 2504 | praat_addAction1 (classSound, 0, U"Formula...", nullptr, 1, MODIFY_Sound_formula); |
| 2505 | praat_addAction1 (classSound, 0, U"Formula (part)...", nullptr, 1, MODIFY_Sound_formula_part); |
| 2506 | praat_addAction1 (classSound, 0, U"-- add & mul --", nullptr, 1, nullptr); |
| 2507 | praat_addAction1 (classSound, 0, U"Add...", nullptr, 1, MODIFY_Sound_add); |
| 2508 | praat_addAction1 (classSound, 0, U"Shift times to between zero and physical duration", U"Shift times to...", 3, MODIFY_Sound_shiftTimesToBetweenZeroAndPhysicalDuration); |
| 2509 | praat_addAction1 (classSound, 0, U"Subtract mean", nullptr, 1, MODIFY_Sound_subtractMean); |
| 2510 | praat_addAction1 (classSound, 0, U"Multiply...", nullptr, 1, MODIFY_Sound_multiply); |
| 2511 | praat_addAction1 (classSound, 0, U"Multiply by window...", nullptr, 1, MODIFY_Sound_multiplyByWindow); |
| 2512 | praat_addAction1 (classSound, 0, U"Scale peak... || Scale...", |
| 2513 | nullptr, 1, MODIFY_Sound_scalePeak); // alternative COMPATIBILITY <= 2004 |
| 2514 | praat_addAction1 (classSound, 0, U"Scale intensity...", nullptr, 1, MODIFY_Sound_scaleIntensity); |
| 2515 | praat_addAction1 (classSound, 0, U"-- set --", nullptr, 1, nullptr); |
| 2516 | praat_addAction1 (classSound, 0, U"Set value at sample number... || Set value at index...", |
| 2517 | nullptr, 1, MODIFY_Sound_setValueAtIndex); // alternative COMPATIBILITY <= 2004 |
| 2518 | praat_addAction1 (classSound, 0, U"Set part to zero...", nullptr, 1, MODIFY_Sound_setPartToZero); |
| 2519 | praat_addAction1 (classSound, 0, U"-- modify hack --", nullptr, 1, nullptr); |
| 2520 | praat_addAction1 (classSound, 0, U"Override sampling frequency... || Override sample rate...", |
| 2521 | nullptr, 1, MODIFY_Sound_overrideSamplingFrequency); // alternative COMPATIBILITY <= 2004 |
| 2522 | praat_addAction1 (classSound, 0, U"-- in-place filters --", nullptr, 1, nullptr); |
| 2523 | praat_addAction1 (classSound, 0, U"In-place filters", nullptr, 1, nullptr); |
| 2524 | praat_addAction1 (classSound, 0, U"Filter with one formant (in-place)... || Filter with one formant (in-line)...", |
| 2525 | nullptr, 2, MODIFY_Sound_filterWithOneFormantInplace); // alternative COMPATIBILITY <= 2017 |
| 2526 | praat_addAction1 (classSound, 0, U"Pre-emphasize (in-place)... || Pre-emphasize (in-line)...", |
| 2527 | nullptr, 2, MODIFY_Sound_preemphasizeInplace); |
| 2528 | praat_addAction1 (classSound, 0, U"De-emphasize (in-place)... || De-emphasize (in-line)...", |
| 2529 | nullptr, 2, MODIFY_Sound_deemphasizeInplace); |
| 2530 | praat_addAction1 (classSound, 0, U"Annotate -", nullptr, 0, nullptr); |
| 2531 | praat_addAction1 (classSound, 0, U"Annotation tutorial", nullptr, 1, |
| 2532 | HELP__AnnotationTutorial); |
| 2533 | praat_addAction1 (classSound, 0, U"-- to text grid --", nullptr, 1, nullptr); |
| 2534 | praat_addAction1 (classSound, 0, U"To TextGrid...", nullptr, 1, |
| 2535 | CONVERT_EACH_TO_ONE__Sound_to_TextGrid); |
| 2536 | praat_addAction1 (classSound, 0, U"To TextGrid (speech activity, Silero)...", nullptr, 1, |
| 2537 | CONVERT_EACH_TO_ONE__Sound_to_TextGrid_speechActivity_silero); |
| 2538 | praat_addAction1 (classSound, 0, U"To TextTier", nullptr, GuiMenu_DEPTH_1 | GuiMenu_HIDDEN, |
| 2539 | CONVERT_EACH_TO_ONE__Sound_to_TextTier); |
| 2540 | praat_addAction1 (classSound, 0, U"To IntervalTier", nullptr, GuiMenu_DEPTH_1 | GuiMenu_HIDDEN, |
| 2541 | CONVERT_EACH_TO_ONE__Sound_to_IntervalTier); |
| 2542 | praat_addAction1 (classSound, 0, U"Analyse periodicity -", nullptr, 0, nullptr); |
| 2543 | praat_addAction1 (classSound, 0, U"How to choose a pitch analysis method", nullptr, 1, |
| 2544 | HELP__How_to_choose_a_pitch_analysis_method); |
| 2545 | praat_addAction1 (classSound, 0, U"-- pitch --", nullptr, 1, nullptr); |
| 2546 | praat_addAction1 (classSound, 0, U"To Pitch...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_HIDDEN, |
| 2547 | CONVERT_EACH_TO_ONE__Sound_to_Pitch); |
| 2548 | praat_addAction1 (classSound, 0, U"To Pitch (filtered autocorrelation)... || To Pitch (filtered ac)...", nullptr, 1, |
| 2549 | CONVERT_EACH_TO_ONE__Sound_to_Pitch_filteredAutocorrelation); |
| 2550 | praat_addAction1 (classSound, 0, U"To Pitch (raw cross-correlation)... || To Pitch (raw cc)...", nullptr, 1, |
| 2551 | CONVERT_EACH_TO_ONE__Sound_to_Pitch_rawCrossCorrelation); |
| 2552 | praat_addAction1 (classSound, 0, U"To Pitch (raw autocorrelation)... || To Pitch (raw ac)...", nullptr, 1, |
| 2553 | CONVERT_EACH_TO_ONE__Sound_to_Pitch_rawAutocorrelation); |
| 2554 | praat_addAction1 (classSound, 0, U"To Pitch (filtered cross-correlation)... || To Pitch (filtered cc)...", nullptr, 1, |
| 2555 | CONVERT_EACH_TO_ONE__Sound_to_Pitch_filteredCrossCorrelation); |
| 2556 | praat_addAction1 (classSound, 0, U"To Pitch (ac)...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_HIDDEN, |
| 2557 | CONVERT_EACH_TO_ONE__Sound_to_Pitch_ac); |
| 2558 | praat_addAction1 (classSound, 0, U"To Pitch (cc)...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_HIDDEN, |
| 2559 | CONVERT_EACH_TO_ONE__Sound_to_Pitch_cc); |
| 2560 | |
| 2561 | praat_addAction1 (classSound, 0, U"To PointProcess (periodic, cc)...", nullptr, 1, |
| 2562 | CONVERT_EACH_TO_ONE__Sound_to_PointProcess_periodic_cc); |
| 2563 | praat_addAction1 (classSound, 0, U"To PointProcess (periodic, peaks)...", nullptr, 1, |
| 2564 | CONVERT_EACH_TO_ONE__Sound_to_PointProcess_periodic_peaks); |
| 2565 | praat_addAction1 (classSound, 0, U"-- points --", nullptr, 1, nullptr); |
| 2566 | praat_addAction1 (classSound, 0, U"To PointProcess (extrema)...", nullptr, 1, |
| 2567 | CONVERT_EACH_TO_ONE__Sound_to_PointProcess_extrema); |
| 2568 | praat_addAction1 (classSound, 0, U"To PointProcess (zeroes)...", nullptr, 1, |
| 2569 | CONVERT_EACH_TO_ONE__Sound_to_PointProcess_zeroes); |
| 2570 | praat_addAction1 (classSound, 0, U"-- hnr --", nullptr, 1, nullptr); |
| 2571 | praat_addAction1 (classSound, 0, U"To Harmonicity (cc)...", nullptr, 1, |
| 2572 | CONVERT_EACH_TO_ONE__Sound_to_Harmonicity_cc); |
| 2573 | praat_addAction1 (classSound, 0, U"To Harmonicity (ac)...", nullptr, 1, |
| 2574 | CONVERT_EACH_TO_ONE__Sound_to_Harmonicity_ac); |
| 2575 | praat_addAction1 (classSound, 0, U"To Harmonicity (gne)...", nullptr, 1, |
| 2576 | CONVERT_EACH_TO_ONE__Sound_to_Harmonicity_gne); |
| 2577 | praat_addAction1 (classSound, 0, U"-- autocorrelation --", nullptr, 1, nullptr); |
| 2578 | praat_addAction1 (classSound, 0, U"Autocorrelate...", nullptr, 1, |
| 2579 | CONVERT_EACH_TO_ONE__Sound_autoCorrelate); |
| 2580 | praat_addAction1 (classSound, 0, U"Analyse spectrum -", nullptr, 0, nullptr); |
| 2581 | praat_addAction1 (classSound, 0, U"To Spectrum...", nullptr, 1, |
| 2582 | CONVERT_EACH_TO_ONE__Sound_to_Spectrum); |
| 2583 | praat_addAction1 (classSound, 0, U"To Spectrum (fft)", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2004, |
| 2584 | CONVERT_EACH_TO_ONE__Sound_to_Spectrum_fft); // replace with To Spectrum: 1 |
| 2585 | praat_addAction1 (classSound, 0, U"To Spectrum", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2004, |
| 2586 | CONVERT_EACH_TO_ONE__Sound_to_Spectrum_fft); // replace with To Spectrum: 1 |
| 2587 | praat_addAction1 (classSound, 0, U"To Spectrum (dft)", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2004, |
| 2588 | CONVERT_EACH_TO_ONE__Sound_to_Spectrum_dft); // replace with To Spectrum: 0 |
| 2589 | praat_addAction1 (classSound, 0, U"To Ltas...", nullptr, 1, |
| 2590 | CONVERT_EACH_TO_ONE__Sound_to_Ltas); |
| 2591 | praat_addAction1 (classSound, 0, U"To Ltas (pitch-corrected)...", nullptr, 1, |
| 2592 | CONVERT_EACH_TO_ONE__Sound_to_Ltas_pitchCorrected); |
| 2593 | praat_addAction1 (classSound, 0, U"-- spectrotemporal --", nullptr, 1, nullptr); |
| 2594 | praat_addAction1 (classSound, 0, U"To Spectrogram...", nullptr, 1, |
| 2595 | CONVERT_EACH_TO_ONE__Sound_to_Spectrogram); |
| 2596 | praat_addAction1 (classSound, 0, U"To Cochleagram...", nullptr, 1, |
| 2597 | CONVERT_EACH_TO_ONE__Sound_to_Cochleagram); |
| 2598 | praat_addAction1 (classSound, 0, U"To Cochleagram (edb)...", nullptr, GuiMenu_DEPTH_1 | GuiMenu_HIDDEN, |
| 2599 | CONVERT_EACH_TO_ONE__Sound_to_Cochleagram_edb); |
| 2600 | praat_addAction1 (classSound, 0, U"-- formants --", nullptr, 1, nullptr); |
| 2601 | praat_addAction1 (classSound, 0, U"To Formant (burg)...", nullptr, 1, |
| 2602 | CONVERT_EACH_TO_ONE__Sound_to_Formant_burg); |
| 2603 | praat_addAction1 (classSound, 0, U"To Formant (hack)", nullptr, 1, nullptr); |
| 2604 | praat_addAction1 (classSound, 0, U"To Formant (keep all)...", nullptr, 2, |
| 2605 | CONVERT_EACH_TO_ONE__Sound_to_Formant_keepAll); |
| 2606 | praat_addAction1 (classSound, 0, U"To Formant (sl)...", nullptr, 2, |
| 2607 | CONVERT_EACH_TO_ONE__Sound_to_Formant_willems); |
| 2608 | praat_addAction1 (classSound, 0, U"To Intensity...", nullptr, 0, |
| 2609 | CONVERT_EACH_TO_ONE__Sound_to_Intensity); |
| 2610 | praat_addAction1 (classSound, 0, U"To IntensityTier...", nullptr, GuiMenu_HIDDEN, |
| 2611 | CONVERT_EACH_TO_ONE__Sound_to_IntensityTier); |
| 2612 | praat_addAction1 (classSound, 0, U"Manipulate -", nullptr, 0, nullptr); |
| 2613 | praat_addAction1 (classSound, 0, U"To Manipulation...", nullptr, 1, |
| 2614 | CONVERT_EACH_TO_ONE__Sound_to_Manipulation); |
| 2615 | praat_addAction1 (classSound, 0, U"Convert -", nullptr, 0, nullptr); |
| 2616 | praat_addAction1 (classSound, 0, U"Convert to mono", nullptr, 1, |
| 2617 | CONVERT_EACH_TO_ONE__Sound_convertToMono); |
| 2618 | praat_addAction1 (classSound, 0, U"Convert to stereo", nullptr, 1, |
| 2619 | CONVERT_EACH_TO_ONE__Sound_convertToStereo); |
| 2620 | praat_addAction1 (classSound, 0, U"Extract all channels", nullptr, 1, |
| 2621 | CONVERT_ONE_TO_MULTIPLE__Sound_extractAllChannels); |
| 2622 | praat_addAction1 (classSound, 0, U"Extract one channel...", nullptr, 1, |
| 2623 | CONVERT_EACH_TO_ONE__Sound_extractChannel); |
| 2624 | praat_addAction1 (classSound, 0, U"Extract left channel", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2010, |
| 2625 | CONVERT_EACH_TO_ONE__Sound_extractLeftChannel); // replace with Extract one channel: 1 |
| 2626 | praat_addAction1 (classSound, 0, U"Extract right channel", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2010, |
| 2627 | CONVERT_EACH_TO_ONE__Sound_extractRightChannel); // replace with Extract one channel: 2 |
| 2628 | praat_addAction1 (classSound, 0, U"Extract channels...", nullptr, 1, |
| 2629 | CONVERT_EACH_TO_ONE__Sound_extractChannels); |
| 2630 | praat_addAction1 (classSound, 0, U"Extract part...", nullptr, 1, |
| 2631 | CONVERT_EACH_TO_ONE__Sound_extractPart); |
| 2632 | praat_addAction1 (classSound, 0, U"Extract part for overlap...", nullptr, 1, |
| 2633 | CONVERT_EACH_TO_ONE__Sound_extractPartForOverlap); |
| 2634 | praat_addAction1 (classSound, 0, U"Resample...", nullptr, 1, |
| 2635 | CONVERT_EACH_TO_ONE__Sound_resample); |
| 2636 | praat_addAction1 (classSound, 0, U"-- enhance --", nullptr, 1, nullptr); |
| 2637 | praat_addAction1 (classSound, 0, U"Lengthen (overlap-add)... || Lengthen (PSOLA)...", nullptr, 1, |
| 2638 | CONVERT_EACH_TO_ONE__Sound_lengthen_overlapAdd); // alternative COMPATIBILITY <= 2007 |
| 2639 | praat_addAction1 (classSound, 0, U"Deepen band modulation...", nullptr, 1, |
| 2640 | CONVERT_EACH_TO_ONE__Sound_deepenBandModulation); |
| 2641 | praat_addAction1 (classSound, 0, U"-- cast --", nullptr, 1, nullptr); |
| 2642 | praat_addAction1 (classSound, 0, U"Down to Matrix", nullptr, 1, |
| 2643 | CONVERT_EACH_TO_ONE__Sound_downto_Matrix); |
| 2644 | praat_addAction1 (classSound, 0, U"Filter -", nullptr, 0, nullptr); |
| 2645 | praat_addAction1 (classSound, 0, U"Filtering tutorial", nullptr, 1, |
| 2646 | HELP__FilteringTutorial); |
| 2647 | praat_addAction1 (classSound, 0, U"-- frequency-domain filter --", nullptr, 1, nullptr); |
| 2648 | praat_addAction1 (classSound, 0, U"Filter (pass Hann band)...", nullptr, 1, |
| 2649 | CONVERT_EACH_TO_ONE__Sound_filter_passHannBand); |
| 2650 | praat_addAction1 (classSound, 0, U"Filter (stop Hann band)...", nullptr, 1, |
| 2651 | CONVERT_EACH_TO_ONE__Sound_filter_stopHannBand); |
| 2652 | praat_addAction1 (classSound, 0, U"Filter (formula)...", nullptr, 1, |
| 2653 | CONVERT_EACH_TO_ONE__Sound_filter_formula); |
| 2654 | praat_addAction1 (classSound, 0, U"-- time-domain filter --", nullptr, 1, nullptr); |
| 2655 | praat_addAction1 (classSound, 0, U"Filter (one formant)...", nullptr, 1, |
| 2656 | CONVERT_EACH_TO_ONE__Sound_filter_oneFormant); |
| 2657 | praat_addAction1 (classSound, 0, U"Filter (pre-emphasis)...", nullptr, 1, |
| 2658 | CONVERT_EACH_TO_ONE__Sound_filter_preemphasis); |
| 2659 | praat_addAction1 (classSound, 0, U"Filter (de-emphasis)...", nullptr, 1, |
| 2660 | CONVERT_EACH_TO_ONE__Sound_filter_deemphasis); |
| 2661 | praat_addAction1 (classSound, 0, U"Combine -", nullptr, 0, nullptr); |
| 2662 | praat_addAction1 (classSound, 0, U"Combine to stereo", nullptr, 1, |
| 2663 | COMBINE_ALL_TO_ONE__Sounds_combineToStereo); |
| 2664 | praat_addAction1 (classSound, 0, U"Combine into SoundList", nullptr, 1, |
| 2665 | COMBINE_ALL_TO_ONE__Sounds_combineIntoSoundList); |
| 2666 | praat_addAction1 (classSound, 0, U"Combine into SoundSet", nullptr, 1, |
| 2667 | COMBINE_ALL_TO_ONE__Sounds_combineIntoSoundSet); |
| 2668 | praat_addAction1 (classSound, 0, U"Concatenate", nullptr, 1, |
| 2669 | COMBINE_ALL_TO_ONE__Sounds_concatenate); |
| 2670 | praat_addAction1 (classSound, 0, U"Concatenate recoverably", nullptr, 1, |
| 2671 | CONVERT_ALL_TO_MULTIPLE__Sounds_concatenateRecoverably); |
| 2672 | praat_addAction1 (classSound, 0, U"Concatenate with overlap...", nullptr, 1, |
| 2673 | COMBINE_ALL_TO_ONE__Sounds_concatenateWithOverlap); |
| 2674 | praat_addAction1 (classSound, 2, U"Convolve...", nullptr, 1, |
| 2675 | CONVERT_TWO_TO_ONE__Sounds_convolve); |
| 2676 | praat_addAction1 (classSound, 2, U"Convolve", nullptr, GuiMenu_DEPTH_1 | GuiMenu_DEPRECATED_2010, |
| 2677 | CONVERT_TWO_TO_ONE__Sounds_convolve_old); // replace with Convolve: "sum", "zero" |
| 2678 | praat_addAction1 (classSound, 2, U"Cross-correlate...", nullptr, 1, |
| 2679 | CONVERT_TWO_TO_ONE__Sounds_crossCorrelate); |
| 2680 | praat_addAction1 (classSound, 2, U"To ParamCurve", nullptr, 1, |
| 2681 | CONVERT_TWO_TO_ONE__Sounds_to_ParamCurve); |
| 2682 | |
| 2683 | praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as WAV file... || Write to WAV file...", |
| 2684 | nullptr, 0, SAVE_ALL__LongSound_Sound_saveAsWavFile); // alternative COMPATIBILITY <= 2011 |
| 2685 | praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as AIFF file... || Write to AIFF file...", |
| 2686 | nullptr, 0, SAVE_ALL__LongSound_Sound_saveAsAiffFile); |
| 2687 | praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as AIFC file... || Write to AIFC file...", |
| 2688 | nullptr, 0, SAVE_ALL__LongSound_Sound_saveAsAifcFile); |
| 2689 | praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as NeXT/Sun file... || Write to NeXT/Sun file...", |
| 2690 | nullptr, 0, SAVE_ALL__LongSound_Sound_saveAsNextSunFile); |
| 2691 | praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as NIST file... || Write to NIST file...", |
| 2692 | nullptr, 0, SAVE_ALL__LongSound_Sound_saveAsNistFile); |
| 2693 | praat_addAction2 (classLongSound, 0, classSound, 0, U"Save as FLAC file... || Write to FLAC file...", |
| 2694 | nullptr, 0, SAVE_ALL__LongSound_Sound_saveAsFlacFile); |
| 2695 | |
| 2696 | praat_addAction1 (classSoundList, 1, U"Extract all Sounds", nullptr, 0, |
| 2697 | CONVERT_EACH_TO_MULTIPLE__SoundList_extractAllSounds); |
| 2698 | |
| 2699 | praat_addAction1 (classSoundSet, 1, U"Extract all Sounds", nullptr, 0, |
| 2700 | CONVERT_EACH_TO_MULTIPLE__SoundSet_extractAllSounds); |
| 2701 | praat_addAction2 (classSoundSet, 1, classTable, 1, U"Get randomized patterns...", nullptr, 0, |
| 2702 | CONVERT_ONE_AND_ONE_TO_MULTIPLE__SoundSet_Table_getRandomizedPatterns); |
| 2703 | } |
| 2704 | |
| 2705 | /* End of file praat_Sound.cpp */ |