| 1 | /* praat_sensors_init.cpp |
| 2 | * |
| 3 | * Copyright (C) 2023 David Weenink |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include <string.h> |
| 20 | #include "Electroglottogram.h"cxx . . $ `<file>/sensors/Electroglottogram.h`/ |
| 21 | |
| 22 | #include "EMA.h"cxx . . $ `<file>/sensors/EMA.h`/ |
| 23 | #include "EMArawData.h"cxx . . $ `<file>/sensors/EMArawData.h`/ |
| 24 | #include "praat_sensors_init.h"cxx . . $ `<file>/sensors/praat_sensors_init.h`/ |
| 25 | #include "Sound_extensions.h"cxx . . $ `<file>/dwtools/Sound_extensions.h`/ |
| 26 | |
| 27 | static autoDaatacxx . . $ autoDaata# CarstensEMA50xV3PosFileRecognizercxx . . $ CarstensEMA50xV3PosFileRecognizer(c32780b24c371669). (integercxx . . $ integer# nread, const char *header, MelderFilecxx . . $ MelderFile# file) { |
| 28 | if (nread > 69 && strnequcxx . . $ `melder/melder_string32.h:70:9`! (header, "AG50xDATA_V00", 13) && |
| 29 | (strstr (header, "NumberOfChannels=") != nullptr) && |
| 30 | (strstr (header, "SamplingFrequencyHz=") != nullptr) && |
| 31 | (strstr (header, "Calf_Channel_0") == nullptr)) |
| 32 | return EMA_readFromCarstensEMA50xPosFilecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21). (file); |
| 33 | else |
| 34 | return autoDaatacxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8). (); |
| 35 | } |
| 36 | |
| 37 | static autoDaatacxx . . $ autoDaata# CarstensEMA50xV3AmpFileRecognizercxx . . $ CarstensEMA50xV3AmpFileRecognizer(c32780b24c371669). (integercxx . . $ integer# nread, const char *header, MelderFilecxx . . $ MelderFile# file) { |
| 38 | if (nread > 69 && strnequcxx . . $ `melder/melder_string32.h:70:9`! (header, "AG50xDATA_V00", 13) && |
| 39 | (strstr (header, "NumberOfChannels=") != nullptr) && |
| 40 | (strstr (header, "SamplingFrequencyHz=") != nullptr) && |
| 41 | (strstr (header, "Calf_Channel_0") != nullptr)) |
| 42 | return EMArawData_readFromCarstensEMA50xAmpFilecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21). (file); |
| 43 | else |
| 44 | return autoDaatacxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8). (); |
| 45 | } |
| 46 | |
| 47 | /******************** Electroglottogram ********************************************/ |
| 48 | |
| 49 | FORMcxx . . $ `sys/praatM.h:79:9`! (CONVERT_EACH_TO_ONE__Electroglottogram_highPassFilter, U"Electroglottogram: High-pass filter", U"Electroglottogram: High-pass filter...") { |
| 50 | REALcxx . . $ `sys/praatM.h:92:9`! (fromFrequency, U"From frequency (Hz)", U"100.0") |
| 51 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (smoothing, U"Smoothing (Hz)", U"100.0") |
| 52 | OKcxx . . $ `sys/praatM.h:327:9`! |
| 53 | DOcxx . . $ `sys/praatM.h:354:9`! |
| 54 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Electroglottogram) |
| 55 | autoElectroglottogramcxx . . $ autoElectroglottogram# result = Electroglottogram_highPassFiltercxx . . $ Electroglottogram_highPassFilter(2671f9865a5ef66a). (me, fromFrequency, smoothing); |
| 56 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get(), U"_filtered") |
| 57 | } |
| 58 | |
| 59 | FORMcxx . . $ `sys/praatM.h:79:9`! (CONVERT_EACH_TO_ONE__Electroglottogram_to_TextGrid_closedGlottis, U"Electroglottogram: To TextGrid (closed glottis)", |
| 60 | U"Electroglottogram: To TextGrid (closed glottis)...") { |
| 61 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 62 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (pitchCeiling, U"Pitch ceiling (Hz)", U"500.0") |
| 63 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (closingThreshold, U"Closing threshold", U"0.30") |
| 64 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (peakThresholdFraction, U"Peak threshold (0-1)", U"0.05") |
| 65 | OKcxx . . $ `sys/praatM.h:327:9`! |
| 66 | DOcxx . . $ `sys/praatM.h:354:9`! |
| 67 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (closingThreshold < 1.0, |
| 68 | U"The closing threshold should be smaller than 1."); |
| 69 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Electroglottogram) |
| 70 | autoTextGridcxx . . $ autoTextGrid# result = Electroglottogram_to_TextGrid_closedGlottiscxx . . $ Electroglottogram_to_TextGrid_closedGlottis(5f0193a427665836). (me, pitchFloor, pitchCeiling, |
| 71 | closingThreshold, peakThresholdFraction |
| 72 | ); |
| 73 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get()) |
| 74 | } |
| 75 | |
| 76 | FORMcxx . . $ `sys/praatM.h:79:9`! (CONVERT_EACH_TO_ONE__Electroglottogram_to_AmplitudeTier_levels, U"Electroglottogram: To AmplitudeTier (levels)", U"") { |
| 77 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (pitchFloor, U"Pitch floor (Hz)", U"75.0") |
| 78 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (pitchCeiling, U"Pitch ceiling (Hz)", U"500.0") |
| 79 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (closingThreshold, U"Closing threshold", U"0.30") |
| 80 | BOOLEANcxx . . $ `sys/praatM.h:130:9`! (wantPeaks, U"Peaks", 0) |
| 81 | BOOLEANcxx . . $ `sys/praatM.h:130:9`! (wantValleys, U"Valleys", 0) |
| 82 | OKcxx . . $ `sys/praatM.h:327:9`! |
| 83 | DOcxx . . $ `sys/praatM.h:354:9`! |
| 84 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Electroglottogram) |
| 85 | autoAmplitudeTiercxx . . $ autoAmplitudeTier# peakscxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8)., valleyscxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 86 | autoAmplitudeTiercxx . . $ autoAmplitudeTier# result = Electroglottogram_to_AmplitudeTier_levelscxx . . $ Electroglottogram_to_AmplitudeTier_levels(26855ed933eba4b0). (me, pitchFloor, pitchCeiling, |
| 87 | closingThreshold, & peaks, & valleys |
| 88 | ); |
| 89 | if (wantPeaks) |
| 90 | praat_newcxx . . $ praat_new(7e14453ab0f22ea). (peakscxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), mycxx . . $ `melder/melder.h:44:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"_peaks"cxx . . $ MelderArg#MelderArg(ff00d524ab0355ec).); |
| 91 | if (wantValleys) |
| 92 | praat_newcxx . . $ praat_new(7e14453ab0f22ea). (valleyscxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), mycxx . . $ `melder/melder.h:44:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"_valleys"cxx . . $ MelderArg#MelderArg(ff00d524ab0355ec).); |
| 93 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get()) |
| 94 | } |
| 95 | |
| 96 | FORMcxx . . $ `sys/praatM.h:79:9`! (CONVERT_EACH_TO_ONE__Electroglottogram_derivative, U"Electroglottogram: Derivative", U"Electroglottogram: Derivative...") { |
| 97 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (lowPassFrequency, U"Low-pass frequency (Hz)", U"5000.0") |
| 98 | POSITIVEcxx . . $ `sys/praatM.h:104:9`! (smoothing, U"Smoothing (Hz)", U"100.0") |
| 99 | REALcxx . . $ `sys/praatM.h:92:9`! (newAbsolutePeak, U"New absolute peak", U"0.0 (= don't scale)") |
| 100 | OKcxx . . $ `sys/praatM.h:327:9`! |
| 101 | DOcxx . . $ `sys/praatM.h:354:9`! |
| 102 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Electroglottogram) |
| 103 | autoSoundcxx . . $ autoSound# result = Sound_derivativecxx . . $ Sound_derivative(14181e1c5f839e03). (me, lowPassFrequency, smoothing, newAbsolutePeak); |
| 104 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get(), U"_derivative") |
| 105 | } |
| 106 | |
| 107 | FORMcxx . . $ `sys/praatM.h:79:9`! (CONVERT_EACH_TO_ONE__Electroglottogram_firstCentralDifference, U"Electroglottogram: First central difference", U"Electroglottogram: First central difference...") { |
| 108 | REALcxx . . $ `sys/praatM.h:92:9`! (scalePeak, U"New absolute peak", U"0.0 (= don't scale)") |
| 109 | OKcxx . . $ `sys/praatM.h:327:9`! |
| 110 | DOcxx . . $ `sys/praatM.h:354:9`! |
| 111 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Electroglottogram) |
| 112 | autoSoundcxx . . $ autoSound# result = Electroglottogram_firstCentralDifferencecxx . . $ Electroglottogram_firstCentralDifference(f4a160f94e6bf470). (me, scalePeak); |
| 113 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get(), U"_cdiff") |
| 114 | } |
| 115 | |
| 116 | DIRECTcxx . . $ `sys/praatM.h:412:9`! (CONVERT_EACH_TO_ONE__Electroglottogram_to_Sound) { |
| 117 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Electroglottogram) |
| 118 | autoSoundcxx . . $ autoSound# result = Electroglottogram_to_Soundcxx . . $ Electroglottogram_to_Sound(6d3c54e5a4940ed). (me); |
| 119 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get()) |
| 120 | } |
| 121 | |
| 122 | FORMcxx . . $ `sys/praatM.h:79:9`! (CONVERT_EACH_TO_ONE__Sound_extractElectroglottogram, U"Sound: Extract Electroglottogram", U"Sound: Extract Electroglottogram...") { |
| 123 | NATURALcxx . . $ `sys/praatM.h:120:9`! (channelNumber, U"Channel number", U"1") |
| 124 | BOOLEANcxx . . $ `sys/praatM.h:130:9`! (invert, U"Invert", 0) |
| 125 | OKcxx . . $ `sys/praatM.h:327:9`! |
| 126 | DOcxx . . $ `sys/praatM.h:354:9`! |
| 127 | CONVERT_EACH_TO_ONEcxx . . $ `sys/praatM.h:1119:9`! (Sound) |
| 128 | autoElectroglottogramcxx . . $ autoElectroglottogram# result = Sound_extractElectroglottogramcxx . . $ Sound_extractElectroglottogram(4ea7eb8653411c6d). (me, channelNumber, invert); |
| 129 | CONVERT_EACH_TO_ONE_ENDcxx . . $ `sys/praatM.h:1121:9`! (mycxx . . $ `melder/melder.h:44:9`! name.get()) |
| 130 | } |
| 131 | |
| 132 | void praat_uvafon_sensors_initcxx . . $ praat_uvafon_sensors_init(49f6e7a06ebc5aa8). () { |
| 133 | Thing_recognizeClassesByNamecxx . . $ Thing_recognizeClassesByName(f327490b5edb0dcb). (classElectroglottogramcxx . . $ classElectroglottogram., classEMAcxx . . $ classEMA., classEMArawDatacxx . . $ classEMArawData.); |
| 134 | |
| 135 | Data_recognizeFileTypecxx . . $ Data_recognizeFileType(7ed4186908013b3d). (CarstensEMA50xV3PosFileRecognizercxx . . $ CarstensEMA50xV3PosFileRecognizer(c32780b24c371669).); |
| 136 | Data_recognizeFileTypecxx . . $ Data_recognizeFileType(7ed4186908013b3d). (CarstensEMA50xV3AmpFileRecognizercxx . . $ CarstensEMA50xV3AmpFileRecognizer(c32780b24c371669).); |
| 137 | |
| 138 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classElectroglottogram, 0, U"High-pass filter...", nullptr, 0, |
| 139 | CONVERT_EACH_TO_ONE__Electroglottogram_highPassFilter); |
| 140 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classElectroglottogram, 0, U"To TextGrid (closed glottis)... || Get closed glottis intervals...", nullptr, 0, |
| 141 | CONVERT_EACH_TO_ONE__Electroglottogram_to_TextGrid_closedGlottis); |
| 142 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classElectroglottogram, 0, U"To AmplitudeTier (levels)...", nullptr, 0, |
| 143 | CONVERT_EACH_TO_ONE__Electroglottogram_to_AmplitudeTier_levels); |
| 144 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classElectroglottogram, 0, U"Derivative...", nullptr, 0, |
| 145 | CONVERT_EACH_TO_ONE__Electroglottogram_derivative); |
| 146 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classElectroglottogram, 0, U"First central difference...", nullptr, 0, |
| 147 | CONVERT_EACH_TO_ONE__Electroglottogram_firstCentralDifference); |
| 148 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classElectroglottogram, 0, U"To Sound", nullptr, 0, |
| 149 | CONVERT_EACH_TO_ONE__Electroglottogram_to_Sound); |
| 150 | |
| 151 | praat_addAction1cxx . . $ `sys/praat.h:72:9`! (classSound, 0, U"Extract Electroglottogram...", U"Extract part for overlap...", 1, |
| 152 | CONVERT_EACH_TO_ONE__Sound_extractElectroglottogram); |
| 153 | |
| 154 | } |
| 155 | |
| 156 | /* End of file praat_sensors_init.cpp */ |
| 157 |