| 1 | /* Sound_to_Formant_mt.cpp |
| 2 | * |
| 3 | * Copyright (C) 2024-2025 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 "Sound_to_Formant_mt.h"cxx . . $ `<file>/LPC/Sound_to_Formant_mt.h`/ |
| 20 | #include "Sound_extensions.h"cxx . . $ `<file>/dwtools/Sound_extensions.h`/ |
| 21 | #include "SoundFrames.h"cxx . . $ `<file>/dwtools/SoundFrames.h`/ |
| 22 | #include "Sound_and_LPC.h"cxx . . $ `<file>/LPC/Sound_and_LPC.h`/ |
| 23 | #include "LPC_and_Formant.h"cxx . . $ `<file>/LPC/LPC_and_Formant.h`/ |
| 24 | |
| 25 | static void Sound_to_Formant_commoncxx . . $ Sound_to_Formant_common(a052fee722c7f721). (constSoundcxx . . $ constSound# inputSound, double& dt, double numberOfFormants_real, double maximumFrequency, |
| 26 | double effectiveAnalysisWidth, double preEmphasisFrequency, double safetyMargin, |
| 27 | autoFormantcxx . . $ autoFormant#& outputFormant, autoLPCcxx . . $ autoLPC#& outputLPC, autoSoundcxx . . $ autoSound#& sound) |
| 28 | { |
| 29 | try { |
| 30 | if (dt <= 0.0) |
| 31 | dt = effectiveAnalysisWidth / 4.0; |
| 32 | autoSoundcxx . . $ autoSound# resampled = Sound_resampleAndOrPreemphasizecxx . . $ Sound_resampleAndOrPreemphasize(50b0edb6f91cc1e7). (inputSound, maximumFrequency, 50, preEmphasisFrequency); |
| 33 | const integercxx . . $ integer# numberOfPoles = 2.0 * numberOfFormants_real; |
| 34 | const double physicalAnalysisWidth = getPhysicalAnalysisWidth2cxx . . $ getPhysicalAnalysisWidth2(746d57f737047cdc). (effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2.); |
| 35 | integercxx . . $ integer# numberOfFrames; |
| 36 | double t1; |
| 37 | Sampled_shortTermAnalysiscxx . . $ Sampled_shortTermAnalysis(77f703705034c8a). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), physicalAnalysisWidth, dt, & numberOfFrames, & t1); |
| 38 | const integercxx . . $ integer# numberOfFormants = ( safetyMargin == 0.0 ? numberOfPoles : (numberOfPoles + 1) / 2 ); |
| 39 | autoFormantcxx . . $ autoFormant# formant = Formant_createcxx . . $ Formant_create(c4f62f8fc805b821). (sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmincxx . . $ structFunction#xmin., sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmaxcxx . . $ structFunction#xmax., numberOfFrames, dt, t1, numberOfFormants); |
| 40 | for (integercxx . . $ integer# iframe = 1; iframe <= numberOfFrames; iframe ++) { |
| 41 | Formant_Framecxx . . $ Formant_Frame# formantFrame = &formant ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). framescxx . . $ structFormant#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 42 | Formant_Frame_initcxx . . $ Formant_Frame_init(c15ad6279e61c40d). (formantFrame, numberOfFormants); |
| 43 | } |
| 44 | outputFormant =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). formant.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 45 | autoLPCcxx . . $ autoLPC# lpc = LPC_createCompletelyInitializedcxx . . $ LPC_createCompletelyInitialized(dee197ba90f07c69). (sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmincxx . . $ structFunction#xmin., sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmaxcxx . . $ structFunction#xmax., formant ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx., formant ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., |
| 46 | formant ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). x1cxx . . $ structSampled#x1., numberOfPoles, sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx.); |
| 47 | outputLPC =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). lpc.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 48 | sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). resampled.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 49 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 50 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot create Formant or LPC or Sound."); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | static autoFormantcxx . . $ autoFormant# createFormant_commoncxx . . $ createFormant_common(8e347dae5513eac9). (constSoundcxx . . $ constSound# me, double dt, integercxx . . $ integer# numberOfPoles, double effectiveAnalysisWidth, |
| 55 | double safetyMargin) |
| 56 | { |
| 57 | integercxx . . $ integer# numberOfFrames; |
| 58 | double t1; |
| 59 | const double physicalAnalysisWidth = getPhysicalAnalysisWidth2cxx . . $ getPhysicalAnalysisWidth2(746d57f737047cdc). (effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2.); |
| 60 | Sampled_shortTermAnalysiscxx . . $ Sampled_shortTermAnalysis(77f703705034c8a). (me, physicalAnalysisWidth, dt, & numberOfFrames, & t1); |
| 61 | const integercxx . . $ integer# numberOfFormants = numberOfFormantsFromNumberOfCoefficients2cxx . . $ numberOfFormantsFromNumberOfCoefficients2(d0157cb6947e575f). (numberOfPoles, safetyMargin); |
| 62 | autoFormantcxx . . $ autoFormant# formant = Formant_createcxx . . $ Formant_create(c4f62f8fc805b821). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., numberOfFrames, dt, t1, numberOfFormants); |
| 63 | return formantcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 64 | } |
| 65 | |
| 66 | void Sound_into_Formant_burgcxx . . $ Sound_into_Formant_burg(85296959bfb5a335). (constSoundcxx . . $ constSound# me, mutableLPCcxx . . $ mutableLPC# intermediateLPC, mutableFormantcxx . . $ mutableFormant# outputFormant, |
| 67 | double effectiveAnalysisWidth, double safetyMargin) |
| 68 | { |
| 69 | Sampleds_requireEqualDomainscxx . . $ Sampleds_requireEqualDomains(8783de53eef05e7). (me, intermediateLPC); |
| 70 | Sampleds_assertEqualDomainsAndSamplingcxx . . $ Sampleds_assertEqualDomainsAndSampling(8783de53eef05e7). (intermediateLPC, outputFormant); |
| 71 | const integercxx . . $ integer# order = intermediateLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 72 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 40; |
| 73 | const double samplingPeriod = intermediateLPC -> samplingPeriodcxx . . $ structLPC#samplingPeriod.; |
| 74 | |
| 75 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (outputFormant -> nx, thresholdNumberOfFramesPerThread) { |
| 76 | autoSoundFramescxx . . $ autoSoundFrames# soundFrames = SoundFrames_createForIntoSampledcxx . . $ SoundFrames_createForIntoSampled(bc9244df65bbc83e). (me, intermediateLPC, effectiveAnalysisWidth, |
| 77 | kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., true); |
| 78 | integercxx . . $ integer# info; |
| 79 | autoVECcxx . . $ autoVEC# aa = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order); |
| 80 | autoVECcxx . . $ autoVEC# b1 = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). soundFrameSizecxx . . $ structSoundFrames#soundFrameSize.); |
| 81 | autoVECcxx . . $ autoVEC# b2 = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). soundFrameSizecxx . . $ structSoundFrames#soundFrameSize.); |
| 82 | autoVECcxx . . $ autoVEC# polynomialIntoRootsWorkspace = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order * order + order + order + 11 * order); |
| 83 | autoPolynomialcxx . . $ autoPolynomial# p = Polynomial_createcxx . . $ Polynomial_create(7da2dc008a3770b9). (-1.0, 1.0, order); |
| 84 | autoRootscxx . . $ autoRoots# roots = Roots_createcxx . . $ Roots_create(27f7be40982d89fc). (order); |
| 85 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 86 | const LPC_Framecxx . . $ LPC_Frame# lpcFrame = & intermediateLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 87 | VECcxx . . $ VEC# soundFrame = soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getMonoFramecxx . . $ structSoundFrames#getMonoFrame(516a12db1224da40). (iframe); |
| 88 | soundFrameIntoLPCFrame_burgcxx . . $ soundFrameIntoLPCFrame_burg(bf16199e8e1e3d9b). (soundFrame, lpcFrame, b1.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), b2.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), aa.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), info); |
| 89 | Formant_Framecxx . . $ Formant_Frame# formantFrame = & outputFormant -> framescxx . . $ structFormant#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 90 | LPC_Frame_into_Formant_Framecxx . . $ LPC_Frame_into_Formant_Frame(924e0a11d6140f04). (lpcFrame, formantFrame, samplingPeriod, |
| 91 | safetyMargin, p.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), roots.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), polynomialIntoRootsWorkspace.getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 92 | } |
| 93 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 94 | } |
| 95 | |
| 96 | autoFormantcxx . . $ autoFormant# Sound_to_Formant_burg_mtcxx . . $ Sound_to_Formant_burg_mt(a339ef7a46c5fea9). (constSoundcxx . . $ constSound# me, double dt, double numberOfFormants, double maximumFrequency, |
| 97 | double effectiveAnalysisWidth, double preEmphasisFrequency, double safetyMargin) |
| 98 | { |
| 99 | try { |
| 100 | autoSoundcxx . . $ autoSound# soundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 101 | autoFormantcxx . . $ autoFormant# outputFormantcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 102 | autoLPCcxx . . $ autoLPC# intermediateLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 103 | Sound_to_Formant_commoncxx . . $ Sound_to_Formant_common(a052fee722c7f721). (me, dt, numberOfFormants, maximumFrequency, effectiveAnalysisWidth, |
| 104 | preEmphasisFrequency, safetyMargin, outputFormant, intermediateLPC, sound); |
| 105 | Sound_into_Formant_burgcxx . . $ Sound_into_Formant_burg(85296959bfb5a335). (me, intermediateLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputFormant.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth, safetyMargin); |
| 106 | return outputFormantcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 107 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 108 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Could not create Formant (burg)."); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | #if 0 |
| 113 | void Sound_and_LPC_into_Formant (constSound inputSound, constLPC inputLPC, mutableLPC intermediateLPC, |
| 114 | mutableFormant outputFormant, double effectiveAnalysisWidth, double safetyMargin, double k_stdev, |
| 115 | integer itermax, double tol, double location, bool wantlocation) |
| 116 | { |
| 117 | Sound_and_LPC_require_equalDomainsAndSamplingPeriods (inputSound, inputLPC); |
| 118 | SampledAndSampled_requireEqualDomainsAndSampling (inputLPC, intermediateLPC); |
| 119 | SampledAndSampled_requireEqualDomainsAndSampling (inputLPC, outputFormant); |
| 120 | const integer order = inputLPC -> maxnCoefficients; |
| 121 | const integer thresholdNumberOfFramesPerThread = 40; |
| 122 | const double samplingPeriod = inputLPC -> samplingPeriod; |
| 123 | MelderThread_PARALLEL (outputFormant -> nx, thresholdNumberOfFramesPerThread) { |
| 124 | autoSoundFrames soundFrames = SoundFrames_createForSampled (inputSound, intermediateLPC, effectiveAnalysisWidth, |
| 125 | kSound_windowShape::GAUSSIAN_2, true, false, 0_integer); |
| 126 | integer info; |
| 127 | autoRobustLPCWorkspace ws = RobustLPCWorkspace_create (inputLPC, inputSound, intermediateLPC, |
| 128 | effectiveAnalysisWidth, kSound_windowShape :: GAUSSIAN_2, k_stdev, itermax, tol, wantlocation); |
| 129 | autoVEC polynomialIntoRootsWorkspace = raw_VEC (order * order + order + order + 11 * order); |
| 130 | autoPolynomial p = Polynomial_create (-1.0, 1.0, order); |
| 131 | autoRoots roots = Roots_create (order); |
| 132 | MelderThread_FOR (iframe) { |
| 133 | const LPC_Frame inputLPCFrame = & inputLPC -> d_frames [iframe]; |
| 134 | const LPC_Frame intermediateLPCFrame = & intermediateLPC -> d_frames [iframe]; |
| 135 | const Formant_Frame formantFrame = & outputFormant -> frames [iframe]; |
| 136 | VEC soundFrame = soundFrames -> getFrame (iframe); |
| 137 | |
| 138 | soundFrameAndLPCFrameIntoLPCFrame (soundFrame, inputLPCFrame, intermediateLPCFrame, ws.get(), info); |
| 139 | LPC_Frame_into_Formant_Frame (intermediateLPCFrame, formantFrame, samplingPeriod, |
| 140 | safetyMargin, p.get(), roots.get(), polynomialIntoRootsWorkspace.get()); |
| 141 | } |
| 142 | } MelderThread_ENDPARALLEL |
| 143 | } |
| 144 | |
| 145 | autoFormant Sound_and_LPC_to_Formant (constSound inputSound, constLPC inputLPC, double effectiveAnalysisWidth, double preEmphasisFrequency, |
| 146 | double safetyMargin, double k_stdev, integer itermax, double tol, double location, bool wantlocation) |
| 147 | { |
| 148 | try { |
| 149 | const double maximumFrequency = 1.0 / inputLPC -> samplingPeriod; |
| 150 | autoSound sound = Sound_resampleAndOrPreemphasize (inputSound, maximumFrequency, 50, preEmphasisFrequency); |
| 151 | autoFormant outputFormant = createFormant_common (sound.get(), inputLPC -> dx, |
| 152 | inputLPC -> maxnCoefficients, effectiveAnalysisWidth, safetyMargin); |
| 153 | autoLPC intermediateLPC = Data_copy (inputLPC); |
| 154 | Sound_and_LPC_into_Formant (inputSound, inputLPC, intermediateLPC.get(), outputFormant.get(), |
| 155 | effectiveAnalysisWidth, safetyMargin, k_stdev, itermax, tol, location, wantlocation); |
| 156 | return outputFormant; |
| 157 | } catch (MelderError) { |
| 158 | Melder_throw (U"Could not create Formant from Sound and LPC."); |
| 159 | } |
| 160 | } |
| 161 | #endif |
| 162 | |
| 163 | autoFormantcxx . . $ autoFormant# Sound_to_Formant_robust_mtcxx . . $ Sound_to_Formant_robust_mt(8450e07614a0da56). (constSoundcxx . . $ constSound# inputSound, double dt, double numberOfFormants, double maximumFrequency, |
| 164 | double effectiveAnalysisWidth, double preEmphasisFrequency, double safetyMargin, double k_stdev, integercxx . . $ integer# itermax, double tol, |
| 165 | double location, bool wantlocation) |
| 166 | { |
| 167 | try { |
| 168 | autoSoundcxx . . $ autoSound# soundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 169 | autoFormantcxx . . $ autoFormant# outputFormantcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 170 | autoLPCcxx . . $ autoLPC# outputLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 171 | Sound_to_Formant_commoncxx . . $ Sound_to_Formant_common(a052fee722c7f721). (inputSound, dt, numberOfFormants, maximumFrequency, effectiveAnalysisWidth, preEmphasisFrequency, |
| 172 | safetyMargin, outputFormant, outputLPC, sound); |
| 173 | const kSound_windowShapecxx . . $ kSound_windowShape# windowShape = kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2.; |
| 174 | |
| 175 | Sound_into_LPC_robustcxx . . $ Sound_into_LPC_robust(889d8559deb2e9ad). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth, k_stdev, itermax, tol, wantlocation); |
| 176 | LPC_into_Formantcxx . . $ LPC_into_Formant(93cc955d6b6c1ef9). (outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputFormant.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), safetyMargin); |
| 177 | return outputFormantcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 178 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 179 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (inputSound, U": no robust Formant created."); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | autoFormantcxx . . $ autoFormant# Sound_to_Formant_robustcxx . . $ Sound_to_Formant_robust(ece26b81bee16a44). (Soundcxx . . $ Sound# me, double dt_in, double numberOfFormants, double maximumFrequency, |
| 184 | double effectiveAnalysisWidth, double preEmphasisFrequency, double safetyMargin, |
| 185 | double numberOfStandardDeviations, integercxx . . $ integer# maximumNumberOfIterations, double tolerance, |
| 186 | double location, bool wantlocation) |
| 187 | { |
| 188 | const double dt = ( dt_in > 0.0 ? dt_in : effectiveAnalysisWidth / 4.0 ); |
| 189 | const double nyquist = 0.5 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.; |
| 190 | const integercxx . . $ integer# predictionOrder = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (2 * numberOfFormants); |
| 191 | try { |
| 192 | autoSoundcxx . . $ autoSound# soundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 193 | if (maximumFrequency <= 0.0 || fabscxx . . $ fabs(fee4f1d22bc8e617). (maximumFrequency / nyquist - 1.0) < 1.0e-12) |
| 194 | sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (me); // will be modified |
| 195 | else |
| 196 | sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_resamplecxx . . $ Sound_resample(872961da5f5e69e5). (me, maximumFrequency * 2.0, 50); |
| 197 | |
| 198 | autoLPCcxx . . $ autoLPC# lpc = Sound_to_LPC_autocxx . . $ Sound_to_LPC_auto(ed41325f50f429a4). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), predictionOrder, effectiveAnalysisWidth, dt, preEmphasisFrequency); |
| 199 | autoLPCcxx . . $ autoLPC# lpcRobust = LPC_and_Sound_to_LPC_robustcxx . . $ LPC_and_Sound_to_LPC_robust(54d8670bb958c0e1). (lpc.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth, preEmphasisFrequency, |
| 200 | numberOfStandardDeviations, maximumNumberOfIterations, tolerance, wantlocation); |
| 201 | autoFormantcxx . . $ autoFormant# thee = LPC_to_Formantcxx . . $ LPC_to_Formant(6c989ebfc69f4efc). (lpcRobust.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), safetyMargin); |
| 202 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 203 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 204 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no robust Formant created."); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | |
| 209 | /* |
| 210 | void Sound_into_Formant_robust_mt (constSound me, mutableFormant thee, double effectiveAnalysisWidth, integer numberOfPoles, double safetyMargin, |
| 211 | double k_stdev, integer itermax, double tol, double location, bool wantlocation) |
| 212 | { |
| 213 | autoSoundFrameIntoFormantFrameRobust ws = SoundFrameIntoFormantFrameRobust_create (me, thee, |
| 214 | effectiveAnalysisWidth, kSound_windowShape :: GAUSSIAN_2, k_stdev, itermax, tol, location, wantlocation, numberOfPoles, safetyMargin); |
| 215 | |
| 216 | |
| 217 | SampledToSampled_analyseThreaded (ws.get()); |
| 218 | } |
| 219 | |
| 220 | autoFormant Sound_to_Formant_robust_mt (constSound me, double dt_in, double numberOfFormants, double maximumFrequency, |
| 221 | double effectiveAnalysisWidth, double preEmphasisFrequency, double safetyMargin, double k_stdev, integer itermax, double tol, |
| 222 | double location, bool wantlocation) |
| 223 | { |
| 224 | const double dt = dt_in > 0.0 ? dt_in : effectiveAnalysisWidth / 4.0; |
| 225 | try { |
| 226 | autoSound sound = Sound_resampleAndOrPreemphasize (me, maximumFrequency, 50, preEmphasisFrequency); |
| 227 | integer numberOfFrames; |
| 228 | double t1; |
| 229 | const double physicalAnalysisWidth = getPhysicalAnalysisWidth (effectiveAnalysisWidth, kSound_windowShape::GAUSSIAN_2); |
| 230 | Sampled_shortTermAnalysis (sound.get(), physicalAnalysisWidth, dt, & numberOfFrames, & t1); |
| 231 | const integer numberOfPoles = numberOfPolesFromNumberOfFormants (numberOfFormants); |
| 232 | const integer numberOfFormants = numberOfFormantsFromNumberOfCoefficients (numberOfPoles, safetyMargin); |
| 233 | autoFormant formant = Formant_create (my xmin, my xmax, numberOfFrames, dt, t1, numberOfFormants); |
| 234 | Sound_into_Formant_robust_mt (sound.get(), formant.get(), effectiveAnalysisWidth, numberOfPoles, safetyMargin, k_stdev, |
| 235 | itermax, tol, location, wantlocation); |
| 236 | return formant; |
| 237 | } catch (MelderError) { |
| 238 | Melder_throw (me, U": no robust Formant created."); |
| 239 | } |
| 240 | } |
| 241 | */ |
| 242 | /* End of file Sound_to_Formant_mt.cpp */ |