| 1 | /* Sound_and_LPC.cpp |
| 2 | * |
| 3 | * Copyright (C) 1994-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 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. See the GNU |
| 13 | * 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 "SoundFrames.h"cxx . . $ `<file>/dwtools/SoundFrames.h`/ |
| 20 | #include "Sound_and_LPC.h"cxx . . $ `<file>/LPC/Sound_and_LPC.h`/ |
| 21 | #include "Sound_extensions.h"cxx . . $ `<file>/dwtools/Sound_extensions.h`/ |
| 22 | #include "Spectrum.h"cxx . . $ `<file>/fon/Spectrum.h`/ |
| 23 | #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/ |
| 24 | |
| 25 | // TODO Remove the Sound_into_LPC variants. Only preemplasis here |
| 26 | |
| 27 | void checkLPCAnalysisParameters_ecxx . . $ checkLPCAnalysisParameters_e(f2b963dca309bb3b). (double sound_dx, integercxx . . $ integer# sound_nx, double physicalAnalysisWidth, integercxx . . $ integer# predictionOrder) { |
| 28 | volatile const double physicalDuration = sound_dx * sound_nx; |
| 29 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (physicalAnalysisWidth <= physicalDuration, |
| 30 | U"Your sound is shorter than two window lengths. " |
| 31 | "Either your sound is too short or your window is too long." |
| 32 | ); |
| 33 | // we round the minimum duration to be able to use asserterror in testing scripts. |
| 34 | conststring32cxx . . $ conststring32# minimumDurationRounded = Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (predictionOrder * sound_dx , 5); |
| 35 | const integercxx . . $ integer# approximateNumberOfSamplesPerWindow = Melder_iroundDowncxx . . $ Melder_iroundDown(a6e4a4c8b00c35a3). (physicalAnalysisWidth / sound_dx); |
| 36 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (approximateNumberOfSamplesPerWindow > predictionOrder, |
| 37 | U"Analysis window duration too short. For a prediction order of ", predictionOrder, |
| 38 | U", the analysis window duration should be greater than ", minimumDurationRounded, |
| 39 | U" s. Please increase the analysis window duration or lower the prediction order." |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | static void Sound_to_LPC_common_ecxx . . $ Sound_to_LPC_common_e(fcf3d59d0cb103c2). (constSoundcxx . . $ constSound# inputSound, int predictionOrder, double effectiveAnalysisWidth, double dt, |
| 44 | double preEmphasisFrequency, autoSoundcxx . . $ autoSound#& outputSound, autoLPCcxx . . $ autoLPC#& outputLPC) |
| 45 | { |
| 46 | try { |
| 47 | const double physicalAnalysisWidth = getPhysicalAnalysisWidth2cxx . . $ getPhysicalAnalysisWidth2(746d57f737047cdc). (effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2.); |
| 48 | checkLPCAnalysisParameters_ecxx . . $ checkLPCAnalysisParameters_e(f2b963dca309bb3b). (inputSound -> dxcxx . . $ structSampled#dx., inputSound -> nxcxx . . $ structSampled#nx., physicalAnalysisWidth, predictionOrder); |
| 49 | integercxx . . $ integer# numberOfFrames; |
| 50 | double t1; |
| 51 | autoSoundcxx . . $ autoSound# sound = Data_copycxx . . $ Data_copy(97a542a26794c80e). (inputSound); |
| 52 | if (preEmphasisFrequency > 0) // TODO check |
| 53 | Sound_preEmphasize_inplacecxx . . $ Sound_preEmphasize_inplace(e59d264236af2337). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), preEmphasisFrequency); |
| 54 | outputSound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). sound.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 55 | Sampled_shortTermAnalysiscxx . . $ Sampled_shortTermAnalysis(77f703705034c8a). (outputSound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), physicalAnalysisWidth, dt, & numberOfFrames, & t1); |
| 56 | autoLPCcxx . . $ autoLPC# lpc = LPC_createCompletelyInitializedcxx . . $ LPC_createCompletelyInitialized(dee197ba90f07c69). (outputSound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmincxx . . $ structFunction#xmin., outputSound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmaxcxx . . $ structFunction#xmax., numberOfFrames, dt, t1, predictionOrder, outputSound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx.); |
| 57 | outputLPC =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). lpc.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 58 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 59 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (inputSound, U": Sound and/or LPC not created from specification."); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /*********************** Autocorrelation method *************************************************************/ |
| 64 | |
| 65 | void soundFrameIntoLPCFrame_autocxx . . $ soundFrameIntoLPCFrame_auto(bf16199e8e1e3d9b). (VECcxx . . $ VEC# soundFrame, LPC_Framecxx . . $ LPC_Frame# lpcFrame, VECcxx . . $ VEC# a, VECcxx . . $ VEC# r, VECcxx . . $ VEC# rc, integercxx . . $ integer#& info) { |
| 66 | integercxx . . $ integer# order = lpcFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients., orderp1 = order + 1; |
| 67 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (a.size >= orderp1); |
| 68 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (r.size >= orderp1); |
| 69 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (rc.size >= orderp1); |
| 70 | info = 0; |
| 71 | /* |
| 72 | Compute the autocorrelations |
| 73 | */ |
| 74 | VECcxx . . $ VEC# x = soundFrame; |
| 75 | for (integercxx . . $ integer# i = 1; i <= orderp1; i ++) |
| 76 | r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..partcxx . . $ vector#part(ae267db9e2c04be7). (1, x.sizecxx . . $ vector#size. - i + 1), xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..partcxx . . $ vector#part(ae267db9e2c04be7). (i, x.sizecxx . . $ vector#size.)); |
| 77 | if (r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] == 0.0) { |
| 78 | /* |
| 79 | The sound frame contains only zero's |
| 80 | */ |
| 81 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = 0.0; |
| 82 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a).); // maintain invariant |
| 83 | info = 1; |
| 84 | return; |
| 85 | } |
| 86 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 1.0; |
| 87 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = - r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] / r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 88 | double gain = r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] + r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] * rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 89 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain; |
| 90 | integercxx . . $ integer# i = 1; |
| 91 | for (i = 2; i <= order; i ++) { |
| 92 | longdoublecxx . . $ longdouble# s = 0.0; |
| 93 | for (integercxx . . $ integer# j = 1; j <= i; j ++) |
| 94 | s += r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j + 2] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 95 | rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = - s / gain; |
| 96 | for (integercxx . . $ integer# j = 2; j <= i / 2 + 1; j ++) { |
| 97 | const double at = a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] + rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j + 2]; |
| 98 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j + 2] += rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 99 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = at; |
| 100 | } |
| 101 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i + 1] = rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]; |
| 102 | gain += rc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * s; |
| 103 | if (gain <= 0.0) { |
| 104 | info = 2; |
| 105 | break; |
| 106 | } |
| 107 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain; |
| 108 | } |
| 109 | const integercxx . . $ integer# numberOfCoefficients = i - 1; |
| 110 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (numberOfCoefficients); |
| 111 | lpcFramecxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). -> acxx . . $ structLPC_Frame#a..partcxx . . $ autovector#part(2d8d48654ca64e70). (1, numberOfCoefficients) <<=cxx . . $ `operator<<=`(adea042513329390). acxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..partcxx . . $ vector#part(ae267db9e2c04be7). (2, numberOfCoefficients + 1); |
| 112 | } |
| 113 | |
| 114 | void Sound_into_LPC_autocxx . . $ Sound_into_LPC_auto(5892df8d1f4abf78). (constSoundcxx . . $ constSound# me, mutableLPCcxx . . $ mutableLPC# outputLPC, double effectiveAnalysisWidth) { |
| 115 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (me, outputLPC); |
| 116 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 40, order = outputLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 117 | |
| 118 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (outputLPC -> nx, thresholdNumberOfFramesPerThread) { |
| 119 | integercxx . . $ integer# info; |
| 120 | autoVECcxx . . $ autoVEC# a = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1), r = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1), rc = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1); |
| 121 | autoSoundFramescxx . . $ autoSoundFrames# soundFrames = SoundFrames_createForIntoSampledcxx . . $ SoundFrames_createForIntoSampled(bc9244df65bbc83e). (me, outputLPC, effectiveAnalysisWidth, |
| 122 | kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., true); |
| 123 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 124 | const LPC_Framecxx . . $ LPC_Frame# lpcFrame = & outputLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 125 | VECcxx . . $ VEC# soundFrame = soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getMonoFramecxx . . $ structSoundFrames#getMonoFrame(516a12db1224da40). (iframe); |
| 126 | soundFrameIntoLPCFrame_autocxx . . $ soundFrameIntoLPCFrame_auto(bf16199e8e1e3d9b). (soundFrame, lpcFrame, a.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), r.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), rc.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), info); |
| 127 | } |
| 128 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 129 | } |
| 130 | |
| 131 | autoLPCcxx . . $ autoLPC# Sound_to_LPC_autocxx . . $ Sound_to_LPC_auto(ed41325f50f429a4). (constSoundcxx . . $ constSound# me, int predictionOrder, double effectiveAnalysisWidth, double dt, double preEmphasisFrequency) { |
| 132 | try { |
| 133 | autoSoundcxx . . $ autoSound# inputSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 134 | autoLPCcxx . . $ autoLPC# outputLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 135 | Sound_to_LPC_common_ecxx . . $ Sound_to_LPC_common_e(fcf3d59d0cb103c2). (me, predictionOrder, effectiveAnalysisWidth, dt, preEmphasisFrequency, inputSound, outputLPC); |
| 136 | Sound_into_LPC_autocxx . . $ Sound_into_LPC_auto(5892df8d1f4abf78). (inputSound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth); |
| 137 | return outputLPCcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 138 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 139 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no LPC (auto) created."); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | /*********************** Covariance method *************************************************************/ |
| 144 | |
| 145 | void soundFrameIntoLPCFrame_covarcxx . . $ soundFrameIntoLPCFrame_covar(328c036c4c37c586). (VECcxx . . $ VEC# soundFrame, LPC_Framecxx . . $ LPC_Frame# lpcFrame, VECcxx . . $ VEC# a, VECcxx . . $ VEC# b, VECcxx . . $ VEC# grc, VECcxx . . $ VEC# beta, VECcxx . . $ VEC# cc, integercxx . . $ integer# & info) { |
| 146 | const integercxx . . $ integer# n = soundFrame.sizecxx . . $ vector#size., order = lpcFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; |
| 147 | |
| 148 | if (lpcFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients. == 0) { |
| 149 | info = 6; |
| 150 | return; |
| 151 | } |
| 152 | constVECcxx . . $ constVEC# x = soundFramecxx . . $ constvector#constvector(eac9d6ec4c4bfecd).; |
| 153 | /* |
| 154 | Compute the covariances |
| 155 | */ |
| 156 | constVECVUcxx . . $ constVECVU# xi = xcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf)..partcxx . . $ constvector#part(e8ca93054b46a634). (order + 1, n), xim1 = xcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf)..partcxx . . $ constvector#part(e8ca93054b46a634). (order, n - 1); |
| 157 | double gain = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xi, xi); |
| 158 | cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xi, xim1); |
| 159 | cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xim1, xim1); |
| 160 | |
| 161 | if (gain == 0.0) { |
| 162 | info = 1; |
| 163 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain; |
| 164 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a).); //maintain invariant |
| 165 | return; |
| 166 | } |
| 167 | bcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). <<=cxx . . $ `operator<<=`(c555d170d72ff256). 0.0; |
| 168 | b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 1.0; |
| 169 | beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2]; |
| 170 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 1.0; |
| 171 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = -cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] / cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2]; |
| 172 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain += grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] * cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 173 | integercxx . . $ integer# i = 2; |
| 174 | for (i = 2; i <= order; i ++) { // 130 |
| 175 | for (integercxx . . $ integer# j = 1; j <= i; j ++) |
| 176 | cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j + 2] = cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j + 1] + x [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).order - i + 1] * x [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).order - i + j] - x [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).n - i + 1] * x [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).n - i + j]; |
| 177 | |
| 178 | // cc[1]=0.0; for (integer j = m + 1; j <= n; j ++) cc [1] += x [j - i] * x [j]; |
| 179 | cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf)..partcxx . . $ constvector#part(e8ca93054b46a634). (order + 1 - i, n - i), xcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf)..partcxx . . $ constvector#part(e8ca93054b46a634). (order + 1, n)); //30 |
| 180 | |
| 181 | b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i * (i + 1) / 2] = 1.0; |
| 182 | for (integercxx . . $ integer# j = 1; j <= i - 1; j ++) { // 70 |
| 183 | if (beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] < 0.0) { |
| 184 | info = 2; |
| 185 | goto end; |
| 186 | } else if (beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] == 0.0) |
| 187 | continue; |
| 188 | |
| 189 | double gam = 0.0; |
| 190 | for (integercxx . . $ integer# k = 1; k <= j; k ++) |
| 191 | gam += cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] * b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j * (j - 1) / 2 + k]; // 50 |
| 192 | gam /= beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 193 | for (integercxx . . $ integer# k = 1; k <= j; k ++) |
| 194 | b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i * (i - 1) / 2 + k] -= gam * b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j * (j - 1) / 2 + k]; // 60 |
| 195 | } |
| 196 | |
| 197 | beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = 0.0; |
| 198 | for (integercxx . . $ integer# j = 1; j <= i; j ++) |
| 199 | beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] += cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j + 1] * b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i * (i - 1) / 2 + j]; // 80 |
| 200 | if (beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] <= 0.0) { |
| 201 | info = 3; |
| 202 | break; |
| 203 | } |
| 204 | double s = 0.0; |
| 205 | for (integercxx . . $ integer# j = 1; j <= i; j ++) |
| 206 | s += cc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; // 100 |
| 207 | grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = -s / beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]; |
| 208 | |
| 209 | for (integercxx . . $ integer# j = 2; j <= i; j ++) |
| 210 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] += grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * b [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i * (i - 1) / 2 + j - 1]; // 110 |
| 211 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i + 1] = grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]; |
| 212 | s = grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * grc [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * beta [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]; |
| 213 | gain -= s; |
| 214 | if (gain <= 0.0) { |
| 215 | info = 4; |
| 216 | break; |
| 217 | } |
| 218 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain; |
| 219 | } |
| 220 | end: |
| 221 | const integercxx . . $ integer# numberOfCoefficients = i - 1; |
| 222 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (numberOfCoefficients); |
| 223 | lpcFramecxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). -> acxx . . $ structLPC_Frame#a..partcxx . . $ autovector#part(2d8d48654ca64e70). (1, numberOfCoefficients) <<=cxx . . $ `operator<<=`(adea042513329390). acxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..partcxx . . $ vector#part(ae267db9e2c04be7). (2, numberOfCoefficients + 1); |
| 224 | |
| 225 | } |
| 226 | |
| 227 | void Sound_into_LPC_covarcxx . . $ Sound_into_LPC_covar(5892df8d1f4abf78). (constSoundcxx . . $ constSound# me, mutableLPCcxx . . $ mutableLPC# outputLPC, double effectiveAnalysisWidth) { |
| 228 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (me, outputLPC); |
| 229 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 40, order = outputLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 230 | |
| 231 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (outputLPC -> nx, thresholdNumberOfFramesPerThread) { |
| 232 | autoSoundFramescxx . . $ autoSoundFrames# soundFrames = Thing_newcxx . . $ `sys/Thing.h:514:9`! (SoundFrames); |
| 233 | soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). initForIntoSampledcxx . . $ structSoundFrames#initForIntoSampled(ecb22456c6d7c3c). (me, outputLPC, effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., true); |
| 234 | integercxx . . $ integer# info; |
| 235 | autoVECcxx . . $ autoVEC# a = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1); |
| 236 | autoVECcxx . . $ autoVEC# b = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order * (order + 1) / 2); |
| 237 | autoVECcxx . . $ autoVEC# grc = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order); |
| 238 | autoVECcxx . . $ autoVEC# beta = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order); |
| 239 | autoVECcxx . . $ autoVEC# cc = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1); |
| 240 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 241 | const LPC_Framecxx . . $ LPC_Frame# lpcFrame = & outputLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 242 | VECcxx . . $ VEC# soundFrame = soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getMonoFramecxx . . $ structSoundFrames#getMonoFrame(516a12db1224da40). (iframe); |
| 243 | soundFrameIntoLPCFrame_covarcxx . . $ soundFrameIntoLPCFrame_covar(328c036c4c37c586). (soundFrame, lpcFrame, a.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), b.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), grc.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), |
| 244 | beta.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), cc.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), info); |
| 245 | } |
| 246 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 247 | } |
| 248 | |
| 249 | autoLPCcxx . . $ autoLPC# Sound_to_LPC_covarcxx . . $ Sound_to_LPC_covar(ed41325f50f429a4). (constSoundcxx . . $ constSound# me, int predictionOrder, double effectiveAnalysisWidth, double dt, double preEmphasisFrequency) { |
| 250 | try { |
| 251 | autoSoundcxx . . $ autoSound# inputSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 252 | autoLPCcxx . . $ autoLPC# outputLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 253 | Sound_to_LPC_common_ecxx . . $ Sound_to_LPC_common_e(fcf3d59d0cb103c2). (me, predictionOrder, effectiveAnalysisWidth, dt, preEmphasisFrequency, inputSound, outputLPC); |
| 254 | Sound_into_LPC_covarcxx . . $ Sound_into_LPC_covar(5892df8d1f4abf78). (inputSound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth); |
| 255 | return outputLPCcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 256 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 257 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no LPC (covar) created."); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | /*********************** Burg method *************************************************************/ |
| 262 | |
| 263 | void soundFrameIntoLPCFrame_burgcxx . . $ soundFrameIntoLPCFrame_burg(bf16199e8e1e3d9b). (VECcxx . . $ VEC# soundFrame, LPC_Framecxx . . $ LPC_Frame# lpcFrame, VECcxx . . $ VEC# b1, VECcxx . . $ VEC# b2, |
| 264 | VECcxx . . $ VEC# aa, integercxx . . $ integer# &info) |
| 265 | { |
| 266 | const integercxx . . $ integer# n = soundFrame.sizecxx . . $ vector#size., order = lpcFrame ->nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; |
| 267 | VECcxx . . $ VEC# x = soundFrame; |
| 268 | VECcxx . . $ VEC# a = lpcFrame -> acxx . . $ structLPC_Frame#a..getcxx . . $ autovector#get(e8d1da7fe68a6585).(); // always safe |
| 269 | aacxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). <<=cxx . . $ `operator<<=`(c555d170d72ff256). 0.0; |
| 270 | if (n <= 2) { |
| 271 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = -1.0; |
| 272 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = ( n == 2 ? 0.5 * (x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] + x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2]) : x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] ); |
| 273 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 274 | } |
| 275 | |
| 276 | // (3) |
| 277 | |
| 278 | double gain = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)., xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).); |
| 279 | |
| 280 | if (gain == 0.0) { |
| 281 | info = 1; |
| 282 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = 0.0; |
| 283 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 284 | return; |
| 285 | } |
| 286 | // (9) |
| 287 | |
| 288 | b1 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 289 | for (integercxx . . $ integer# j = 2; j <= n - 1; j ++) |
| 290 | b1 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = b2 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j - 1] = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 291 | b2 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n - 1] = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n]; |
| 292 | |
| 293 | for (integercxx . . $ integer# i = 1; i <= order; i ++) { |
| 294 | // (7) |
| 295 | |
| 296 | /* |
| 297 | longdouble num = 0.0, denum = 0.0; |
| 298 | for (integer j = 1; j <= n - i; j ++) { |
| 299 | num += b1 [j] * b2 [j]; |
| 300 | denum += b1 [j] * b1 [j] + b2 [j] * b2 [j]; |
| 301 | } |
| 302 | */ |
| 303 | VECcxx . . $ VEC# b1part = b1.partcxx . . $ vector#part(ae267db9e2c04be7). (1, n - i), b2part = b2.partcxx . . $ vector#part(ae267db9e2c04be7). (1, n - i); |
| 304 | const double num = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (b1partcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)., b2partcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).); |
| 305 | const double denum = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (b1partcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)., b1partcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).) + NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (b2partcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)., b2partcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).); |
| 306 | |
| 307 | if (denum <= 0.0) { // part of sound has zero amplitude |
| 308 | info = 1; |
| 309 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = 0.0; |
| 310 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 311 | return; // warning ill-conditioned |
| 312 | } |
| 313 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = 2.0 * num / denum; |
| 314 | |
| 315 | // (10) |
| 316 | |
| 317 | gain *= 1.0 - a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]; |
| 318 | |
| 319 | // (5) |
| 320 | |
| 321 | for (integercxx . . $ integer# j = 1; j <= i - 1; j ++) |
| 322 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = aa [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] - a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * aa [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j]; |
| 323 | |
| 324 | if (i < order) { |
| 325 | |
| 326 | // (8) Watch out: i -> i+1 |
| 327 | |
| 328 | for (integercxx . . $ integer# j = 1; j <= i; j ++) |
| 329 | aa [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 330 | for (integercxx . . $ integer# j = 1; j <= n - i - 1; j ++) { |
| 331 | b1 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] -= aa [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * b2 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 332 | b2 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = b2 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j + 1] - aa [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * b1 [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j + 1]; |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain; // djmw 20251021 no need to multiply by n! |
| 337 | for (integercxx . . $ integer# i = 1; i <= lpcFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; i ++) |
| 338 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = - a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]; |
| 339 | } |
| 340 | |
| 341 | void Sound_into_LPC_burgcxx . . $ Sound_into_LPC_burg(5892df8d1f4abf78). (constSoundcxx . . $ constSound# me, mutableLPCcxx . . $ mutableLPC# outputLPC, double effectiveAnalysisWidth) { |
| 342 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (me, outputLPC); |
| 343 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 40, order = outputLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 344 | |
| 345 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (outputLPC -> nx, thresholdNumberOfFramesPerThread) { |
| 346 | autoSoundFramescxx . . $ autoSoundFrames# soundFrames = SoundFrames_createForIntoSampledcxx . . $ SoundFrames_createForIntoSampled(bc9244df65bbc83e). (me, outputLPC, effectiveAnalysisWidth, |
| 347 | kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., true); |
| 348 | integercxx . . $ integer# info; |
| 349 | autoVECcxx . . $ autoVEC# aa = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order); |
| 350 | autoVECcxx . . $ autoVEC# b1 = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). soundFrameSizecxx . . $ structSoundFrames#soundFrameSize.); |
| 351 | autoVECcxx . . $ autoVEC# b2 = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). soundFrameSizecxx . . $ structSoundFrames#soundFrameSize.); |
| 352 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 353 | const LPC_Framecxx . . $ LPC_Frame# lpcFrame = & outputLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 354 | VECcxx . . $ VEC# soundFrame = soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getMonoFramecxx . . $ structSoundFrames#getMonoFrame(516a12db1224da40). (iframe); |
| 355 | soundFrameIntoLPCFrame_burgcxx . . $ soundFrameIntoLPCFrame_burg(bf16199e8e1e3d9b). (soundFrame, lpcFrame, b1.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), b2.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), aa.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), info); |
| 356 | } |
| 357 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 358 | } |
| 359 | |
| 360 | autoLPCcxx . . $ autoLPC# Sound_to_LPC_burgcxx . . $ Sound_to_LPC_burg(ed41325f50f429a4). (constSoundcxx . . $ constSound# me, int predictionOrder, double effectiveAnalysisWidth, double dt, double preEmphasisFrequency) { |
| 361 | try { |
| 362 | autoSoundcxx . . $ autoSound# inputSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 363 | autoLPCcxx . . $ autoLPC# outputLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 364 | Sound_to_LPC_common_ecxx . . $ Sound_to_LPC_common_e(fcf3d59d0cb103c2). (me, predictionOrder, effectiveAnalysisWidth, dt, preEmphasisFrequency, inputSound, outputLPC); |
| 365 | Sound_into_LPC_burgcxx . . $ Sound_into_LPC_burg(5892df8d1f4abf78). (inputSound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth); |
| 366 | return outputLPCcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 367 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 368 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no LPC (burg) created."); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | /*********************** Marple method *************************************************************/ |
| 373 | |
| 374 | void soundFrameIntoLPCFrame_marplecxx . . $ soundFrameIntoLPCFrame_marple(ef1ab10d3bebd73b). (VECcxx . . $ VEC# soundFrame, LPC_Framecxx . . $ LPC_Frame# lpcFrame, VECcxx . . $ VEC# c, VECcxx . . $ VEC# d, VECcxx . . $ VEC# r, |
| 375 | double tol1, double tol2, integercxx . . $ integer#& info) |
| 376 | { |
| 377 | const integercxx . . $ integer# mmax = lpcFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients., n = soundFrame.sizecxx . . $ vector#size.; |
| 378 | VECcxx . . $ VEC# x = soundFrame; |
| 379 | |
| 380 | info = 0; |
| 381 | VECcxx . . $ VEC# a = lpcFrame -> acxx . . $ structLPC_Frame#a..getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 382 | |
| 383 | double e0 = 2.0 * NUMsum2cxx . . $ NUMsum2(fa513f1eb826a064). (xcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).); |
| 384 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = 0.0; |
| 385 | integercxx . . $ integer# m = 1; |
| 386 | if (e0 == 0.0) { |
| 387 | info = 1; |
| 388 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 389 | return; |
| 390 | } |
| 391 | double q1 = 1.0 / e0; |
| 392 | double q2 = q1 * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1], q = q1 * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1], w = q1 * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n]; |
| 393 | double v = q, u = w; |
| 394 | double den = 1.0 - q - w; |
| 395 | double q4 = 1.0 / den, q5 = 1.0 - q, q6 = 1.0 - w; |
| 396 | double h = q2 * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n], s = h; |
| 397 | double gain = e0 * den; |
| 398 | q1 = 1.0 / gain; |
| 399 | c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = q1 * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 400 | d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = q1 * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n]; |
| 401 | double s1 = 0.0; |
| 402 | for (integercxx . . $ integer# k = 1; k <= n - 1; k ++) |
| 403 | s1 += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 404 | r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 2.0 * s1; |
| 405 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = - q1 * r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 406 | gain *= (1.0 - a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]); |
| 407 | while (m < mmax) { |
| 408 | const double eOld = gain; |
| 409 | double f = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m + 1], b = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n - m]; // n-1 ->n-m |
| 410 | for (integercxx . . $ integer# k = 1; k <= m; k ++) { |
| 411 | // n-1 -> n-m |
| 412 | f += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m + 1 - k] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 413 | b += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n - m + k] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 414 | } |
| 415 | q1 = 1.0 / gain; |
| 416 | q2 = q1 * f; |
| 417 | const double q3 = q1 * b; |
| 418 | for (integercxx . . $ integer# k = m; k >= 1; k--) { |
| 419 | c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] = c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] + q2 * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 420 | d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] = d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] * q3 * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 421 | } |
| 422 | c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = q2; |
| 423 | d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = q3; |
| 424 | const double q7 = s * s; |
| 425 | double y1 = f * f; |
| 426 | const double y2 = v * v; |
| 427 | const double y3 = b * b; |
| 428 | const double y4 = u * u; |
| 429 | double y5 = 2.0 * h * s; |
| 430 | q += y1 * q1 + q4 * (y2 * q6 + q7 * q5 + v * y5); |
| 431 | w += y3 * q1 + q4 * (y4 * q5 + q7 * q6 + u * y5); |
| 432 | h = s = u = v = 0.0; |
| 433 | for (integercxx . . $ integer# k = 0; k <= m; k ++) { |
| 434 | h += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n - m + k] * c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1]; |
| 435 | s += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n - k] * c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1]; |
| 436 | u += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n - k] * d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1]; |
| 437 | v += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] * c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1]; |
| 438 | } |
| 439 | q5 = 1.0 - q; |
| 440 | q6 = 1.0 - w; |
| 441 | den = q5 * q6 - h * h; |
| 442 | if (den <= 0.0) { |
| 443 | info = 2; |
| 444 | goto end; // 2: ill-conditioning |
| 445 | } |
| 446 | q4 = 1.0 / den; |
| 447 | q1 *= q4; |
| 448 | const double alf = 1.0 / (1.0 + q1 * (y1 * q6 + y3 * q5 + 2.0 * h * f * b)); |
| 449 | gain *= alf; |
| 450 | y5 = h * s; |
| 451 | double c1 = q4 * (f * q6 + b * h); |
| 452 | double c2 = q4 * (b * q5 + h * f); |
| 453 | const double c3 = q4 * (v * q6 + y5); |
| 454 | const double c4 = q4 * (s * q5 + v * h); |
| 455 | const double c5 = q4 * (s * q6 + h * u); |
| 456 | const double c6 = q4 * (u * q5 + y5); |
| 457 | for (integercxx . . $ integer# k = 1; k <= m; k ++) |
| 458 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] = alf * (a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] + c1 * c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] + c2 * d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1]); |
| 459 | for (integercxx . . $ integer# k = 1; k <= m / 2 + 1; k ++) { |
| 460 | s1 = c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 461 | const double s2 = d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k], s3 = c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m + 2 - k], s4 = d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m + 2 - k]; |
| 462 | |
| 463 | c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] += c3 * s3 + c4 * s4; |
| 464 | d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] += c5 * s3 + c6 * s4; |
| 465 | if (m + 2 - k == k) |
| 466 | continue; |
| 467 | c [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m + 2 - k] += c3 * s1 + c4 * s2; |
| 468 | d [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m + 2 - k] += c5 * s1 + c6 * s2; |
| 469 | } |
| 470 | m ++; |
| 471 | c1 = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n + 1 - m]; |
| 472 | c2 = x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m]; |
| 473 | double delta = 0.0; |
| 474 | for (integercxx . . $ integer# k = m - 1; k >= 1; k--) { |
| 475 | r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] = r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] - x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).n + 1 - k] * c1 - x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] * c2; |
| 476 | delta += r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + 1] * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 477 | } |
| 478 | s1 = 0.0; |
| 479 | for (integercxx . . $ integer# k = 1; k <= n - m; k ++) |
| 480 | s1 += x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k + m] * x [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 481 | r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 2.0 * s1; |
| 482 | delta += r [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 483 | q2 = - delta / gain; |
| 484 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m] = q2; |
| 485 | for (integercxx . . $ integer# k = 1; k <= m / 2; k ++) { |
| 486 | s1 = a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 487 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] += q2 * a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m - k]; |
| 488 | if (k == m - k) |
| 489 | continue; |
| 490 | a [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).m - k] += q2 * s1; |
| 491 | } |
| 492 | y1 = q2 * q2; |
| 493 | gain *= 1.0 - y1; |
| 494 | if (y1 >= 1.0) { |
| 495 | info = 3; |
| 496 | break; // |a [m]| > 1 |
| 497 | } |
| 498 | if (gain < e0 * tol1) { |
| 499 | info = 4; |
| 500 | break; |
| 501 | } |
| 502 | if (eOld - gain < eOld * tol2) { |
| 503 | info = 5; |
| 504 | break; |
| 505 | } |
| 506 | } |
| 507 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (m); |
| 508 | end: |
| 509 | lpcFrame -> gaincxx . . $ structLPC_Frame#gain. = gain * 0.5; // because e0 is twice the energy |
| 510 | if (!(info == 0 || info == 4 || info == 5)) |
| 511 | lpcFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (m - 1); |
| 512 | } |
| 513 | |
| 514 | void Sound_into_LPC_marplecxx . . $ Sound_into_LPC_marple(ca81e047e6329e35). (constSoundcxx . . $ constSound# me, mutableLPCcxx . . $ mutableLPC# outputLPC, double effectiveAnalysisWidth, |
| 515 | double tol1, double tol2) |
| 516 | { |
| 517 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (me, outputLPC); |
| 518 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 40, order = outputLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 519 | |
| 520 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (outputLPC -> nx, thresholdNumberOfFramesPerThread) { |
| 521 | integercxx . . $ integer# info; |
| 522 | autoSoundFramescxx . . $ autoSoundFrames# soundFrames = SoundFrames_createForIntoSampledcxx . . $ SoundFrames_createForIntoSampled(bc9244df65bbc83e). (me, outputLPC, effectiveAnalysisWidth, |
| 523 | kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., true); |
| 524 | autoVECcxx . . $ autoVEC# c = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1); |
| 525 | autoVECcxx . . $ autoVEC# d = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1); |
| 526 | autoVECcxx . . $ autoVEC# r = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (order + 1); |
| 527 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 528 | const LPC_Framecxx . . $ LPC_Frame# lpcFrame = & outputLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 529 | VECcxx . . $ VEC# soundFrame = soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getMonoFramecxx . . $ structSoundFrames#getMonoFrame(516a12db1224da40). (iframe); |
| 530 | soundFrameIntoLPCFrame_marplecxx . . $ soundFrameIntoLPCFrame_marple(ef1ab10d3bebd73b). (soundFrame, lpcFrame, c.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), d.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), r.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), tol1, tol2, info); |
| 531 | } |
| 532 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 533 | } |
| 534 | |
| 535 | autoLPCcxx . . $ autoLPC# Sound_to_LPC_marplecxx . . $ Sound_to_LPC_marple(869b7bf396bbc43a). (constSoundcxx . . $ constSound# me, int predictionOrder, double effectiveAnalysisWidth, double dt, |
| 536 | double preEmphasisFrequency, double tol1, double tol2) |
| 537 | { |
| 538 | try { |
| 539 | autoSoundcxx . . $ autoSound# inputSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 540 | autoLPCcxx . . $ autoLPC# outputLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 541 | Sound_to_LPC_common_ecxx . . $ Sound_to_LPC_common_e(fcf3d59d0cb103c2). (me, predictionOrder, effectiveAnalysisWidth, dt, preEmphasisFrequency, inputSound, outputLPC); |
| 542 | Sound_into_LPC_marplecxx . . $ Sound_into_LPC_marple(ca81e047e6329e35). (inputSound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth, tol1, tol2); |
| 543 | return outputLPCcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 544 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 545 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no LPC (marple) created."); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | /*********************** PLP (Hermansky) method *************************************************************/ |
| 550 | |
| 551 | /* |
| 552 | void structSoundFrameIntoLPCFramePLP :: getFilterCharacteristics () { |
| 553 | struct structCriticalBandFilter { |
| 554 | double fb, fm, fe; |
| 555 | integer i1, i2; |
| 556 | integer iv1, iv2; |
| 557 | }; |
| 558 | const double nyquistFrequency = 0.5 / frameAsSound -> dx; |
| 559 | const double df = 1.0 / (frameAsSound -> dx * numberOfFourierSamples); |
| 560 | const double fmax_bark = hertzToBark (nyquistFrequency); |
| 561 | numberOfCriticalBandFilters = Melder_ifloor (fmax_bark) + 2; |
| 562 | const double df_bark = fmax_bark / (numberOfCriticalBandFilters - 1); |
| 563 | autovector<struct structCriticalBandFilter> filters = newvectorzero<struct structCriticalBandFilter> (numberOfCriticalBandFilters); |
| 564 | for (integer ifilter = 1; ifilter <= numberOfCriticalBandFilters; ifilter ++) { |
| 565 | struct structCriticalBandFilter *fstruct = & filters [ifilter]; |
| 566 | const double fm_bark = ifilter * df_bark; |
| 567 | const double fb_bark = Melder_clippedLeft (0.0, fm_bark - 2.5); |
| 568 | const double fe_bark = Melder_clippedRight (fm_bark + 1.3, fmax_bark); |
| 569 | fstruct -> fb = barkToHertz (fb_bark); |
| 570 | fstruct -> fe = barkToHertz (fe_bark); |
| 571 | fstruct -> fm = barkToHertz (fm_bark); |
| 572 | |
| 573 | } |
| 574 | |
| 575 | }*/ |
| 576 | |
| 577 | /*********************** Robust method (LPC & Sound) **********************************************/ |
| 578 | |
| 579 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (RobustLPCWorkspace, Thing, 0); |
| 580 | |
| 581 | void structRobustLPCWorkspacecxx . . $ structRobustLPCWorkspace# :: initcxx . . $ structRobustLPCWorkspace#init(9a303f6b9c9b3e7b). (constLPCcxx . . $ constLPC# inputLPC, constSoundcxx . . $ constSound# inputSound, mutableLPCcxx . . $ mutableLPC# outputLPC, |
| 582 | double effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape# windowShape, |
| 583 | double k_stdev, integercxx . . $ integer# itermax, double tol, bool wantLocation) |
| 584 | { |
| 585 | const double physicalAnalysisWidth = getPhysicalAnalysisWidthcxx . . $ getPhysicalAnalysisWidth(746d57f737047cdc). (effectiveAnalysisWidth, windowShape); |
| 586 | const integercxx . . $ integer# soundFrameSize = getSoundFrameSizecxx . . $ getSoundFrameSize(e4170d96af58b73c). (physicalAnalysisWidth, inputSound -> dxcxx . . $ structSampled#dx.); |
| 587 | ourcxx . . $ `melder/melder.h:42:9`! ordercxx . . $ structRobustLPCWorkspace#order. = inputLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 588 | ourcxx . . $ `melder/melder.h:42:9`! inputLPCcxx . . $ structRobustLPCWorkspace#inputLPC. = inputLPC; |
| 589 | ourcxx . . $ `melder/melder.h:42:9`! outputLPCcxx . . $ structRobustLPCWorkspace#outputLPC. = outputLPC; |
| 590 | ourcxx . . $ `melder/melder.h:42:9`! k_stdevcxx . . $ structRobustLPCWorkspace#k_stdev. = k_stdev; |
| 591 | ourcxx . . $ `melder/melder.h:42:9`! itermaxcxx . . $ structRobustLPCWorkspace#itermax. = itermax; |
| 592 | ourcxx . . $ `melder/melder.h:42:9`! tol1cxx . . $ structRobustLPCWorkspace#tol1. = tol; |
| 593 | ourcxx . . $ `melder/melder.h:42:9`! wantLocationcxx . . $ structRobustLPCWorkspace#wantLocation. = wantLocation; |
| 594 | ourcxx . . $ `melder/melder.h:42:9`! wantScalecxx . . $ structRobustLPCWorkspace#wantScale. = true; |
| 595 | ourcxx . . $ `melder/melder.h:42:9`! locationcxx . . $ structRobustLPCWorkspace#location. = 0.0; |
| 596 | ourcxx . . $ `melder/melder.h:42:9`! huber_iterationscxx . . $ structRobustLPCWorkspace#huber_iterations. = 5; |
| 597 | ourcxx . . $ `melder/melder.h:42:9`! errorcxx . . $ structRobustLPCWorkspace#error. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrameSize); |
| 598 | ourcxx . . $ `melder/melder.h:42:9`! sampleWeightscxx . . $ structRobustLPCWorkspace#sampleWeights. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrameSize); |
| 599 | coefficientscxx . . $ structRobustLPCWorkspace#coefficients. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (ordercxx . . $ structRobustLPCWorkspace#order.); |
| 600 | covarianceswcxx . . $ structRobustLPCWorkspace#covariancesw. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (ordercxx . . $ structRobustLPCWorkspace#order.); |
| 601 | covarmatrixwcxx . . $ structRobustLPCWorkspace#covarmatrixw. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (ordercxx . . $ structRobustLPCWorkspace#order., ordercxx . . $ structRobustLPCWorkspace#order.); |
| 602 | svdcxx . . $ structRobustLPCWorkspace#svd. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). SVD_createcxx . . $ SVD_create(1ec6f5698ce1ada6). (ordercxx . . $ structRobustLPCWorkspace#order., ordercxx . . $ structRobustLPCWorkspace#order.); |
| 603 | SVD_setTolerancecxx . . $ SVD_setTolerance(e291c81952ef8ef2). (svdcxx . . $ structRobustLPCWorkspace#svd..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tolSVDcxx . . $ structRobustLPCWorkspace#tolSVD.); |
| 604 | computedSVDworksizecxx . . $ structRobustLPCWorkspace#computedSVDworksize. = SVD_getWorkspaceSizecxx . . $ SVD_getWorkspaceSize(c9b8894ea6dfb8fa). (svdcxx . . $ structRobustLPCWorkspace#svd..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 605 | svdwork1cxx . . $ structRobustLPCWorkspace#svdwork1. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (computedSVDworksizecxx . . $ structRobustLPCWorkspace#computedSVDworksize.); |
| 606 | svdwork2cxx . . $ structRobustLPCWorkspace#svdwork2. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (ordercxx . . $ structRobustLPCWorkspace#order.); |
| 607 | filterMemorycxx . . $ structRobustLPCWorkspace#filterMemory. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (ordercxx . . $ structRobustLPCWorkspace#order.); |
| 608 | huberworkcxx . . $ structRobustLPCWorkspace#huberwork. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (soundFrameSize); |
| 609 | } |
| 610 | |
| 611 | void structRobustLPCWorkspacecxx . . $ structRobustLPCWorkspace# :: resizecxx . . $ structRobustLPCWorkspace#resize(49f6e7a06ebc5aa8). () { |
| 612 | if (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder. == svdcxx . . $ structRobustLPCWorkspace#svd. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numberOfColumnscxx . . $ structSVD#numberOfColumns.) |
| 613 | return; |
| 614 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (currentPredictionOrder <= order); |
| 615 | coefficientscxx . . $ structRobustLPCWorkspace#coefficients..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 616 | covarianceswcxx . . $ structRobustLPCWorkspace#covariancesw..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 617 | covarmatrixwcxx . . $ structRobustLPCWorkspace#covarmatrixw..resizecxx . . $ automatrix#resize(a64d57580b9dfd76). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder., currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 618 | SVD_resizeWithinOldBoundscxx . . $ SVD_resizeWithinOldBounds(fd3486631380876d). (svdcxx . . $ structRobustLPCWorkspace#svd..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ordercxx . . $ structRobustLPCWorkspace#order., ordercxx . . $ structRobustLPCWorkspace#order., currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder., currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 619 | } |
| 620 | |
| 621 | void structRobustLPCWorkspacecxx . . $ structRobustLPCWorkspace# :: setSampleWeightscxx . . $ structRobustLPCWorkspace#setSampleWeights(49f6e7a06ebc5aa8). () { |
| 622 | for (integercxx . . $ integer# isamp = 1 ; isamp <= errorcxx . . $ structRobustLPCWorkspace#error..sizecxx . . $ autovector#size.; isamp ++) { |
| 623 | const double absDiff = fabscxx . . $ fabs(fee4f1d22bc8e617). (errorcxx . . $ structRobustLPCWorkspace#error. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isamp] - locationcxx . . $ structRobustLPCWorkspace#location.); |
| 624 | sampleWeightscxx . . $ structRobustLPCWorkspace#sampleWeights. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isamp] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (1.0, k_stdevcxx . . $ structRobustLPCWorkspace#k_stdev. * scalecxx . . $ structRobustLPCWorkspace#scale. / absDiff); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | void structRobustLPCWorkspacecxx . . $ structRobustLPCWorkspace# :: setCovariancescxx . . $ structRobustLPCWorkspace#setCovariances(49f6e7a06ebc5aa8). () { |
| 629 | MATVUcxx . . $ MATVU# covar = MATVUcxx . . $ MATVU# (covarmatrixwcxx . . $ structRobustLPCWorkspace#covarmatrixw..partcxx . . $ automatrix#part(5c23e73480cfacfb). (1, currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder., 1, currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.)); |
| 630 | for (integercxx . . $ integer# i = 1; i <= currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.; i ++) { |
| 631 | for (integercxx . . $ integer# j = i; j <= currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.; j ++) { |
| 632 | /* |
| 633 | The following inner loop will take the most CPU time of all the robust calculations |
| 634 | */ |
| 635 | longdoublecxx . . $ longdouble# cv1 = 0.0; |
| 636 | for (integercxx . . $ integer# k = currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder. + 1; k <= soundFramecxx . . $ structRobustLPCWorkspace#soundFrame..sizecxx . . $ vector#size.; k ++) |
| 637 | cv1 += soundFramecxx . . $ structRobustLPCWorkspace#soundFrame. [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k - j] * soundFramecxx . . $ structRobustLPCWorkspace#soundFrame. [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k - i] * sampleWeightscxx . . $ structRobustLPCWorkspace#sampleWeights. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).k]; |
| 638 | covar [cxx . . $ matrixview#`operator[]`(a8b9553e85c2b1fc).i] [cxx . . $ vectorview#`operator[]`(8a4599b8835d1ce1).j] = covar [cxx . . $ matrixview#`operator[]`(a8b9553e85c2b1fc).j] [cxx . . $ vectorview#`operator[]`(8a4599b8835d1ce1).i] = cv1; |
| 639 | } |
| 640 | longdoublecxx . . $ longdouble# cv2 = 0.0; |
| 641 | for (integercxx . . $ integer# k = currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder. + 1; k <= soundFramecxx . . $ structRobustLPCWorkspace#soundFrame..sizecxx . . $ vector#size.; k ++) |
| 642 | cv2 += soundFramecxx . . $ structRobustLPCWorkspace#soundFrame. [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k - i] * soundFramecxx . . $ structRobustLPCWorkspace#soundFrame. [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] * sampleWeightscxx . . $ structRobustLPCWorkspace#sampleWeights. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).k]; |
| 643 | covarianceswcxx . . $ structRobustLPCWorkspace#covariancesw. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = - cv2; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | void structRobustLPCWorkspacecxx . . $ structRobustLPCWorkspace# :: solvelpccxx . . $ structRobustLPCWorkspace#solvelpc(49f6e7a06ebc5aa8). () { |
| 648 | svdcxx . . $ structRobustLPCWorkspace#svd. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). ucxx . . $ structSVD#u..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). covarmatrixwcxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58)..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 649 | svdwork2cxx . . $ structRobustLPCWorkspace#svdwork2..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 650 | SVD_computecxx . . $ SVD_compute(ddb1bcafe9937c37). (svdcxx . . $ structRobustLPCWorkspace#svd..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), svdwork1cxx . . $ structRobustLPCWorkspace#svdwork1..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 651 | SVD_solve_preallocatedcxx . . $ SVD_solve_preallocated(a7076b13da87f7b9). (svdcxx . . $ structRobustLPCWorkspace#svd..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), covarianceswcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), coefficientscxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), svdwork2cxx . . $ structRobustLPCWorkspace#svdwork2..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 652 | coefficientscxx . . $ structRobustLPCWorkspace#coefficients..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); // maintain invariant |
| 653 | } |
| 654 | |
| 655 | void structRobustLPCWorkspacecxx . . $ structRobustLPCWorkspace# :: inputFrameIntoOutputFramecxx . . $ structRobustLPCWorkspace#inputFrameIntoOutputFrame(760f3c96cfe6a5b5). (LPC_Framecxx . . $ LPC_Frame# inputLPCFrame, LPC_Framecxx . . $ LPC_Frame# outputLPCFrame, VECcxx . . $ VEC# soundFrame, integercxx . . $ integer#& info) { |
| 656 | ourcxx . . $ `melder/melder.h:42:9`! soundFramecxx . . $ structRobustLPCWorkspace#soundFrame. =cxx . . $ vector#`operator=`(958c14910af86093). soundFrame; |
| 657 | currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder. = inputLPCFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; |
| 658 | outputLPCFrame -> resizecxx . . $ structLPC_Frame#resize(1624ee8275b10bda). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 659 | outputLPCFrame -> gaincxx . . $ structLPC_Frame#gain. = inputLPCFrame -> gaincxx . . $ structLPC_Frame#gain.; |
| 660 | info = 0; |
| 661 | if (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder. == 0) // is empty frame ? |
| 662 | return; |
| 663 | for (integercxx . . $ integer# i = 1; i <= currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.; i ++) |
| 664 | outputLPCFrame -> acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = inputLPCFrame -> acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 665 | |
| 666 | VECcxx . . $ VEC# inout_a = outputLPCFrame -> acxx . . $ structLPC_Frame#a..getcxx . . $ autovector#get(e8d1da7fe68a6585).(); |
| 667 | itercxx . . $ structRobustLPCWorkspace#iter. = 0; |
| 668 | scalecxx . . $ structRobustLPCWorkspace#scale. = 1e308; |
| 669 | bool farFromScale = true; |
| 670 | resizecxx . . $ structRobustLPCWorkspace#resize(49f6e7a06ebc5aa8). (); |
| 671 | filterMemorycxx . . $ structRobustLPCWorkspace#filterMemory..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder.); |
| 672 | do { |
| 673 | const double previousScale = scalecxx . . $ structRobustLPCWorkspace#scale.; |
| 674 | errorcxx . . $ structRobustLPCWorkspace#error..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). soundFramecxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).; |
| 675 | VECfilterInverse_inplacecxx . . $ VECfilterInverse_inplace(90fde51006936352). (errorcxx . . $ structRobustLPCWorkspace#error..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), inout_acxx . . $ constvector#constvector(eac9d6ec4c4bfecd)., filterMemorycxx . . $ structRobustLPCWorkspace#filterMemory..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 676 | NUMstatistics_hubercxx . . $ NUMstatistics_huber(f9ec060e31928512). (errorcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), & locationcxx . . $ structRobustLPCWorkspace#location., wantLocationcxx . . $ structRobustLPCWorkspace#wantLocation., & scalecxx . . $ structRobustLPCWorkspace#scale., wantScalecxx . . $ structRobustLPCWorkspace#wantScale., k_stdevcxx . . $ structRobustLPCWorkspace#k_stdev., |
| 677 | tol1cxx . . $ structRobustLPCWorkspace#tol1., huber_iterationscxx . . $ structRobustLPCWorkspace#huber_iterations., huberworkcxx . . $ structRobustLPCWorkspace#huberwork..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 678 | setSampleWeightscxx . . $ structRobustLPCWorkspace#setSampleWeights(49f6e7a06ebc5aa8). (); |
| 679 | |
| 680 | setCovariancescxx . . $ structRobustLPCWorkspace#setCovariances(49f6e7a06ebc5aa8). (); |
| 681 | /* |
| 682 | Solve C a = [-] c |
| 683 | */ |
| 684 | try { |
| 685 | solvelpccxx . . $ structRobustLPCWorkspace#solvelpc(49f6e7a06ebc5aa8). (); |
| 686 | inout_acxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). <<=cxx . . $ `operator<<=`(adea042513329390). coefficientscxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(); |
| 687 | farFromScale = ( fabscxx . . $ fabs(fee4f1d22bc8e617). (scalecxx . . $ structRobustLPCWorkspace#scale. - previousScale) > stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (tol1cxx . . $ structRobustLPCWorkspace#tol1. * fabscxx . . $ fabs(fee4f1d22bc8e617). (scalecxx . . $ structRobustLPCWorkspace#scale.), NUMepscxx . . $ `dwsys/NUM2.h:36:9`!) ); |
| 688 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 689 | Melder_clearErrorcxx . . $ Melder_clearError(49f6e7a06ebc5aa8). (); // No change could be made |
| 690 | info = 2; // solvelpc in error |
| 691 | inputLPCFrame -> copycxx . . $ structLPC_Frame#copy(93f372e9cde0d046). (outputLPCFrame); |
| 692 | return; |
| 693 | } |
| 694 | } while (++ itercxx . . $ structRobustLPCWorkspace#iter. < itermaxcxx . . $ structRobustLPCWorkspace#itermax. && farFromScale); |
| 695 | info = 3; // maximum number of iterations |
| 696 | } |
| 697 | |
| 698 | autoRobustLPCWorkspacecxx . . $ autoRobustLPCWorkspace# RobustLPCWorkspace_createcxx . . $ RobustLPCWorkspace_create(7f8ccc0cd9332402). (constLPCcxx . . $ constLPC# inputLPC, constSoundcxx . . $ constSound# inputSound, |
| 699 | mutableLPCcxx . . $ mutableLPC# outputLPC, double effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape# windowShape, |
| 700 | double k_stdev, integercxx . . $ integer# itermax, double tol, bool wantlocation) |
| 701 | { |
| 702 | try { |
| 703 | autoRobustLPCWorkspacecxx . . $ autoRobustLPCWorkspace# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (RobustLPCWorkspace); |
| 704 | mycxx . . $ `melder/melder.h:44:9`! initcxx . . $ structRobustLPCWorkspace#init(9a303f6b9c9b3e7b). (inputLPC, inputSound, outputLPC, effectiveAnalysisWidth, windowShape, k_stdev, itermax, tol, wantlocation); |
| 705 | mycxx . . $ `melder/melder.h:44:9`! wantScalecxx . . $ structRobustLPCWorkspace#wantScale. = true; // explicit |
| 706 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 707 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 708 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot create RobustLPCWorkspace."); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | void soundFrameAndLPCFrameIntoLPCFramecxx . . $ soundFrameAndLPCFrameIntoLPCFrame(376f3aa0aacb1ab6). (VECcxx . . $ VEC# soundFrame, LPC_Framecxx . . $ LPC_Frame# inputLPCFrame, LPC_Framecxx . . $ LPC_Frame# outputLPCFrame, |
| 713 | RobustLPCWorkspacecxx . . $ RobustLPCWorkspace# ws, integercxx . . $ integer#& info) |
| 714 | { |
| 715 | const integercxx . . $ integer# currentPredictionOrder = inputLPCFrame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; |
| 716 | ws -> currentPredictionOrdercxx . . $ structRobustLPCWorkspace#currentPredictionOrder. = currentPredictionOrder; |
| 717 | ws -> inputFrameIntoOutputFramecxx . . $ structRobustLPCWorkspace#inputFrameIntoOutputFrame(760f3c96cfe6a5b5). (inputLPCFrame, outputLPCFrame, soundFrame, info); |
| 718 | } |
| 719 | |
| 720 | void LPC_and_Sound_into_LPC_robustcxx . . $ LPC_and_Sound_into_LPC_robust(cf7985e5989e948d). (constLPCcxx . . $ constLPC# inputLPC, constSoundcxx . . $ constSound# inputSound, mutableLPCcxx . . $ mutableLPC# outputLPC, |
| 721 | double effectiveAnalysisWidth, double k_stdev, integercxx . . $ integer# itermax, double tol, bool wantlocation) |
| 722 | { |
| 723 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (inputSound, outputLPC); |
| 724 | Sampleds_requireEqualDomainsAndSamplingcxx . . $ Sampleds_requireEqualDomainsAndSampling(8783de53eef05e7). (inputLPC, outputLPC); |
| 725 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 40, order = outputLPC -> maxnCoefficientscxx . . $ structLPC#maxnCoefficients.; |
| 726 | |
| 727 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (outputLPC -> nx, thresholdNumberOfFramesPerThread) { |
| 728 | autoSoundFramescxx . . $ autoSoundFrames# soundFrames = SoundFrames_createForIntoSampledcxx . . $ SoundFrames_createForIntoSampled(bc9244df65bbc83e). (inputSound, outputLPC, effectiveAnalysisWidth, |
| 729 | kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., true); |
| 730 | integercxx . . $ integer# info; |
| 731 | autoRobustLPCWorkspacecxx . . $ autoRobustLPCWorkspace# ws = RobustLPCWorkspace_createcxx . . $ RobustLPCWorkspace_create(7f8ccc0cd9332402). (inputLPC, inputSound, outputLPC, |
| 732 | effectiveAnalysisWidth, kSound_windowShapecxx . . $ kSound_windowShape#::GAUSSIAN_2cxx . . $ kSound_windowShape#GAUSSIAN_2., k_stdev, itermax, tol, wantlocation); |
| 733 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 734 | const LPC_Framecxx . . $ LPC_Frame# outputLPCFrame = & outputLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 735 | const LPC_Framecxx . . $ LPC_Frame# inputLPCFrame = & inputLPC -> d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]; |
| 736 | VECcxx . . $ VEC# soundFrame = soundFrames ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getMonoFramecxx . . $ structSoundFrames#getMonoFrame(516a12db1224da40). (iframe); |
| 737 | soundFrameAndLPCFrameIntoLPCFramecxx . . $ soundFrameAndLPCFrameIntoLPCFrame(376f3aa0aacb1ab6). (soundFrame, inputLPCFrame, outputLPCFrame, ws.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), info); |
| 738 | } |
| 739 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 740 | } |
| 741 | |
| 742 | autoLPCcxx . . $ autoLPC# LPC_and_Sound_to_LPC_robustcxx . . $ LPC_and_Sound_to_LPC_robust(54d8670bb958c0e1). (constLPCcxx . . $ constLPC# inputLPC, constSoundcxx . . $ constSound# inputSound, double effectiveAnalysisWidth, |
| 743 | double preEmphasisFrequency, double k_stdev, integercxx . . $ integer# itermax, double tol, bool wantlocation) |
| 744 | { |
| 745 | try { |
| 746 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (inputSound, inputLPC); |
| 747 | autoSoundcxx . . $ autoSound# sound = Data_copycxx . . $ Data_copy(97a542a26794c80e). (inputSound); |
| 748 | if (preEmphasisFrequency >= 0.0) |
| 749 | Sound_preEmphasize_inplacecxx . . $ Sound_preEmphasize_inplace(e59d264236af2337). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), preEmphasisFrequency); |
| 750 | autoLPCcxx . . $ autoLPC# outputLPC = Data_copycxx . . $ Data_copy(97a542a26794c80e). (inputLPC); |
| 751 | LPC_and_Sound_into_LPC_robustcxx . . $ LPC_and_Sound_into_LPC_robust(cf7985e5989e948d). (inputLPC, sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth, |
| 752 | k_stdev, itermax, tol, wantlocation); |
| 753 | return outputLPCcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 754 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 755 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (inputLPC, U" and ", inputSound, U": no LPC (robust) created."); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | /*********************** Robust method (Sound) ******************************************************/ |
| 760 | |
| 761 | |
| 762 | void Sound_into_LPC_robustcxx . . $ Sound_into_LPC_robust(889d8559deb2e9ad). (constSoundcxx . . $ constSound# inputSound, mutableLPCcxx . . $ mutableLPC# outputLPC, double effectiveAnalysisWidth, double k_stdev, integercxx . . $ integer# itermax, double tol, bool wantlocation) |
| 763 | { |
| 764 | Sound_and_LPC_require_equalDomainsAndSamplingPeriodscxx . . $ Sound_and_LPC_require_equalDomainsAndSamplingPeriods(504d62ec9a7fd786). (inputSound, outputLPC); |
| 765 | autoLPCcxx . . $ autoLPC# intermediateLPC = Data_copycxx . . $ Data_copy(97a542a26794c80e). (outputLPC); |
| 766 | Sound_into_LPC_autocxx . . $ Sound_into_LPC_auto(5892df8d1f4abf78). (inputSound, intermediateLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth); |
| 767 | LPC_and_Sound_into_LPC_robustcxx . . $ LPC_and_Sound_into_LPC_robust(cf7985e5989e948d). (intermediateLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), inputSound, outputLPC, effectiveAnalysisWidth, |
| 768 | k_stdev, itermax, tol, wantlocation); |
| 769 | } |
| 770 | |
| 771 | autoLPCcxx . . $ autoLPC# Sound_to_LPC_robustcxx . . $ Sound_to_LPC_robust(c01bc10650f3b13c). (constSoundcxx . . $ constSound# me, int predictionOrder, double effectiveAnalysisWidth, double dt, |
| 772 | double preEmphasisFrequency, double k_stdev, integercxx . . $ integer# itermax, double tol, bool wantlocation) |
| 773 | { |
| 774 | try { |
| 775 | autoSoundcxx . . $ autoSound# emphasizedSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 776 | autoLPCcxx . . $ autoLPC# outputLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 777 | Sound_to_LPC_common_ecxx . . $ Sound_to_LPC_common_e(fcf3d59d0cb103c2). (me, predictionOrder, effectiveAnalysisWidth, dt, preEmphasisFrequency, emphasizedSound, outputLPC); |
| 778 | Sound_into_LPC_robustcxx . . $ Sound_into_LPC_robust(889d8559deb2e9ad). (emphasizedSound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), outputLPC.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), effectiveAnalysisWidth, k_stdev, |
| 779 | itermax, tol, wantlocation); |
| 780 | return outputLPCcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 781 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 782 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no LPC (robust) created."); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | /*********************** (inverse) filtering ******************************/ |
| 787 | |
| 788 | static void LPC_Frame_Sound_filtercxx . . $ LPC_Frame_Sound_filter(47c0128855b12415). (constLPC_Framecxx . . $ constLPC_Frame# me, mutableSoundcxx . . $ mutableSound# thee, integercxx . . $ integer# channel) { |
| 789 | const VECcxx . . $ VEC# y = thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (channel); |
| 790 | for (integercxx . . $ integer# i = 1; i <= thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.; i ++) { |
| 791 | const integercxx . . $ integer# m = ( i > mycxx . . $ `melder/melder.h:44:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients. ? mycxx . . $ `melder/melder.h:44:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients. : i - 1 ); // ppgb: what is m? |
| 792 | for (integercxx . . $ integer# j = 1; j <= m; j ++) |
| 793 | y [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] -= mycxx . . $ `melder/melder.h:44:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j] * y [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i - j]; |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | autoSoundcxx . . $ autoSound# LPC_Sound_filterInversecxx . . $ LPC_Sound_filterInverse(f4bce7e21db85b5). (constLPCcxx . . $ constLPC# me, constSoundcxx . . $ constSound# thee) { |
| 798 | try { |
| 799 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! samplingPeriod == thycxx . . $ `melder/melder.h:45:9`! dx, |
| 800 | U"The sampling frequencies should be equal."); |
| 801 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! xmin == thycxx . . $ `melder/melder.h:45:9`! xmin && thycxx . . $ `melder/melder.h:45:9`! xmax == mycxx . . $ `melder/melder.h:44:9`! xmax, |
| 802 | U"The domains of LPC and Sound should be equal."); |
| 803 | |
| 804 | autoSoundcxx . . $ autoSound# him = Data_copycxx . . $ Data_copy(97a542a26794c80e). (thee); |
| 805 | VECcxx . . $ VEC# source = hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 806 | VECcxx . . $ VEC# sound = thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 807 | for (integercxx . . $ integer# isamp = 1; isamp <= hiscxx . . $ `melder/melder.h:47:9`! nxcxx . . $ structSampled#nx.; isamp ++) { |
| 808 | const double sampleTime = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), isamp); |
| 809 | const integercxx . . $ integer# frameNumber = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (me, sampleTime); |
| 810 | if (frameNumber < 1 || frameNumber > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) { |
| 811 | source [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = 0.0; |
| 812 | continue; |
| 813 | } |
| 814 | const LPC_Framecxx . . $ LPC_Frame# frame = & mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).frameNumber]; |
| 815 | const integercxx . . $ integer# maximumFilterDepth = frame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; |
| 816 | const integercxx . . $ integer# maximumSoundDepth = isamp - 1; |
| 817 | const integercxx . . $ integer# usableDepth = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (maximumFilterDepth, maximumSoundDepth); |
| 818 | for (integercxx . . $ integer# icoef = 1; icoef <= usableDepth; icoef ++) |
| 819 | source [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] += frame -> acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icoef] * sound [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp - icoef]; |
| 820 | } |
| 821 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 822 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 823 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (thee, U": not inverse filtered."); |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | /* |
| 828 | Gain used as a constant amplitude multiplier within a frame of duration my dx. |
| 829 | future alternative: convolve gain with a smoother. |
| 830 | */ |
| 831 | autoSoundcxx . . $ autoSound# LPC_Sound_filtercxx . . $ LPC_Sound_filter(94682ef9887ad8d9). (constLPCcxx . . $ constLPC# me, constSoundcxx . . $ constSound# thee, bool useGain) { |
| 832 | try { |
| 833 | const double xmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., thycxx . . $ `melder/melder.h:45:9`! xmincxx . . $ structFunction#xmin.); |
| 834 | const double xmax = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., thycxx . . $ `melder/melder.h:45:9`! xmaxcxx . . $ structFunction#xmax.); |
| 835 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (xmin < xmax, |
| 836 | U"Domains of Sound [", thycxx . . $ `melder/melder.h:45:9`! xmin, U",", thycxx . . $ `melder/melder.h:45:9`! xmax, U"] and LPC [", |
| 837 | mycxx . . $ `melder/melder.h:44:9`! xmin, U",", mycxx . . $ `melder/melder.h:44:9`! xmax, U"] should overlap." |
| 838 | ); |
| 839 | /* |
| 840 | Resample the sound if the sampling frequencies do not match. |
| 841 | */ |
| 842 | autoSoundcxx . . $ autoSound# sourcecxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 843 | if (mycxx . . $ `melder/melder.h:44:9`! samplingPeriodcxx . . $ structLPC#samplingPeriod. != thycxx . . $ `melder/melder.h:45:9`! dxcxx . . $ structSampled#dx.) { |
| 844 | source =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_resamplecxx . . $ Sound_resample(872961da5f5e69e5). (thee, 1.0 / mycxx . . $ `melder/melder.h:44:9`! samplingPeriodcxx . . $ structLPC#samplingPeriod., 50); |
| 845 | thee = source.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); // reference copy; remove at end |
| 846 | } |
| 847 | |
| 848 | autoSoundcxx . . $ autoSound# him = Data_copycxx . . $ Data_copy(97a542a26794c80e). (thee); |
| 849 | |
| 850 | const integercxx . . $ integer# ifirst = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (thee, xmin)); |
| 851 | const integercxx . . $ integer# ilast = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (Sampled_xToLowIndexcxx . . $ Sampled_xToLowIndex(405c2491bc3636e9). (thee, xmax), thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.); |
| 852 | for (integercxx . . $ integer# isamp = ifirst; isamp <= ilast; isamp ++) { |
| 853 | const double sampleTime = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), isamp); |
| 854 | const integercxx . . $ integer# frameNumber = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (me, sampleTime); |
| 855 | if (frameNumber < 1 || frameNumber > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) { |
| 856 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = 0.0; |
| 857 | continue; |
| 858 | } |
| 859 | const LPC_Framecxx . . $ LPC_Frame# frame = & mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).frameNumber]; |
| 860 | const integercxx . . $ integer# maximumFilterDepth = frame -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; |
| 861 | const integercxx . . $ integer# maximumSourceDepth = isamp - 1; |
| 862 | const integercxx . . $ integer# usableDepth = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (maximumFilterDepth, maximumSourceDepth); |
| 863 | for (integercxx . . $ integer# icoef = 1; icoef <= usableDepth; icoef ++) |
| 864 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] -= frame -> acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icoef] * hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp - icoef]; |
| 865 | } |
| 866 | /* |
| 867 | Make samples before first frame and after last frame zero. |
| 868 | */ |
| 869 | for (integercxx . . $ integer# isamp = 1; isamp < ifirst; isamp ++) |
| 870 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = 0.0; |
| 871 | for (integercxx . . $ integer# isamp = ilast + 1; isamp <= hiscxx . . $ `melder/melder.h:47:9`! nxcxx . . $ structSampled#nx.; isamp ++) |
| 872 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = 0.0; |
| 873 | |
| 874 | if (useGain) { |
| 875 | for (integercxx . . $ integer# isamp = ifirst; isamp <= ilast; isamp ++) { |
| 876 | const double sampleTime = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), isamp); |
| 877 | const double realFrameNumber = Sampled_xToIndexcxx . . $ Sampled_xToIndex(b395a896ba2eff9a). (me, sampleTime); |
| 878 | const integercxx . . $ integer# leftFrameNumber = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (realFrameNumber); |
| 879 | const integercxx . . $ integer# rightFrameNumber = leftFrameNumber + 1; |
| 880 | const double phase = realFrameNumber - leftFrameNumber; |
| 881 | if (rightFrameNumber < 1 || leftFrameNumber > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) |
| 882 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = 0.0; |
| 883 | else if (rightFrameNumber == 1) |
| 884 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] *= sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. gaincxx . . $ structLPC_Frame#gain.) * phase; |
| 885 | else if (leftFrameNumber == mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) |
| 886 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] *= sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.]. gaincxx . . $ structLPC_Frame#gain.) * (1.0 - phase); |
| 887 | else |
| 888 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] *= |
| 889 | phase * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).rightFrameNumber]. gaincxx . . $ structLPC_Frame#gain.) + |
| 890 | (1.0 - phase) * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).leftFrameNumber]. gaincxx . . $ structLPC_Frame#gain.); |
| 891 | } |
| 892 | } |
| 893 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 894 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 895 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (thee, U": not filtered."); |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | void LPC_Sound_filterWithFilterAtTime_inplacecxx . . $ LPC_Sound_filterWithFilterAtTime_inplace(1a66f7bef222c354). (constLPCcxx . . $ constLPC# me, mutableSoundcxx . . $ mutableSound# thee, integercxx . . $ integer# channel, double time) { |
| 900 | integercxx . . $ integer# frameIndex = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (me, time); |
| 901 | Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & frameIndex, mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.); // constant extrapolation |
| 902 | if (channel > thycxx . . $ `melder/melder.h:45:9`! nycxx . . $ structSampledXY#ny.) |
| 903 | channel = 1; |
| 904 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (frameIndex > 0 && frameIndex <= mycxx . . $ `melder/melder.h:44:9`! nx, |
| 905 | U"Frame should be in the range [1, ", mycxx . . $ `melder/melder.h:44:9`! nx, U"]."); |
| 906 | |
| 907 | if (channel > 0) |
| 908 | LPC_Frame_Sound_filtercxx . . $ LPC_Frame_Sound_filter(47c0128855b12415). (& mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).frameIndex], thee, channel); |
| 909 | else |
| 910 | for (integercxx . . $ integer# ichan = 1; ichan <= thycxx . . $ `melder/melder.h:45:9`! nycxx . . $ structSampledXY#ny.; ichan ++) |
| 911 | LPC_Frame_Sound_filtercxx . . $ LPC_Frame_Sound_filter(47c0128855b12415). (& mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).frameIndex], thee, ichan); |
| 912 | } |
| 913 | |
| 914 | autoSoundcxx . . $ autoSound# LPC_Sound_filterWithFilterAtTimecxx . . $ LPC_Sound_filterWithFilterAtTime(bf907e3a385d3c6). (constLPCcxx . . $ constLPC# me, constSoundcxx . . $ constSound# thee, integercxx . . $ integer# channel, double time) { |
| 915 | try { |
| 916 | autoSoundcxx . . $ autoSound# him = Data_copycxx . . $ Data_copy(97a542a26794c80e). (thee); |
| 917 | LPC_Sound_filterWithFilterAtTime_inplacecxx . . $ LPC_Sound_filterWithFilterAtTime_inplace(1a66f7bef222c354). (me, him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), channel, time); |
| 918 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 919 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 920 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (thee, U": not filtered."); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | void LPC_Sound_filterInverseWithFilterAtTime_inplacecxx . . $ LPC_Sound_filterInverseWithFilterAtTime_inplace(1a66f7bef222c354). (constLPCcxx . . $ constLPC# me, mutableSoundcxx . . $ mutableSound# thee, integercxx . . $ integer# channel, double time) { |
| 925 | try { |
| 926 | integercxx . . $ integer# frameIndex = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (me, time); |
| 927 | Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & frameIndex, mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.); // constant extrapolation |
| 928 | if (channel > thycxx . . $ `melder/melder.h:45:9`! nycxx . . $ structSampledXY#ny.) |
| 929 | channel = 1; |
| 930 | LPC_Framecxx . . $ LPC_Frame# lpc = & mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).frameIndex]; |
| 931 | autoVECcxx . . $ autoVEC# workspace = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (lpc -> nCoefficientscxx . . $ structLPC_Frame#nCoefficients.); |
| 932 | if (channel > 0) |
| 933 | VECfilterInverse_inplacecxx . . $ VECfilterInverse_inplace(90fde51006936352). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (channel), lpccxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> acxx . . $ structLPC_Frame#a..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), workspace.getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 934 | else |
| 935 | for (integercxx . . $ integer# ichan = 1; ichan <= thycxx . . $ `melder/melder.h:45:9`! nycxx . . $ structSampledXY#ny.; ichan ++) |
| 936 | VECfilterInverse_inplacecxx . . $ VECfilterInverse_inplace(90fde51006936352). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (ichan), lpccxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> acxx . . $ structLPC_Frame#a..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), workspace.getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 937 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 938 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (thee, U": not inverse filtered."); |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | autoSoundcxx . . $ autoSound# LPC_Sound_filterInverseWithFilterAtTimecxx . . $ LPC_Sound_filterInverseWithFilterAtTime(bf907e3a385d3c6). (constLPCcxx . . $ constLPC# me, constSoundcxx . . $ constSound# thee, integercxx . . $ integer# channel, double time) { |
| 943 | try { |
| 944 | autoSoundcxx . . $ autoSound# him = Data_copycxx . . $ Data_copy(97a542a26794c80e). (thee); |
| 945 | LPC_Sound_filterInverseWithFilterAtTime_inplacecxx . . $ LPC_Sound_filterInverseWithFilterAtTime_inplace(1a66f7bef222c354). (me, him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), channel, time); |
| 946 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 947 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 948 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (thee, U": not inverse filtered."); |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | /* End of file Sound_and_LPC.cpp */ |