| 1 | /* PowerCepstrogram.cpp |
| 2 | * |
| 3 | * Copyright (C) 2013-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 "PowerCepstrogram.h"cxx . . $ `<file>/LPC/PowerCepstrogram.h`/ |
| 20 | #include "Cepstrum_and_Spectrum.h"cxx . . $ `<file>/LPC/Cepstrum_and_Spectrum.h`/ |
| 21 | #include "Matrix_extensions.h"cxx . . $ `<file>/dwtools/Matrix_extensions.h`/ |
| 22 | #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/ |
| 23 | #include "Sound_and_Spectrum.h"cxx . . $ `<file>/fon/Sound_and_Spectrum.h`/ |
| 24 | #include "Sound_extensions.h"cxx . . $ `<file>/dwtools/Sound_extensions.h`/ |
| 25 | |
| 26 | |
| 27 | #define TO10LOGcxx . . $ `LPC/PowerCepstrogram.cpp:27:9`!(x) ((10 / NUMln10) * log ((x) + 1e-30)) |
| 28 | |
| 29 | integercxx . . $ integer# acxx . . $ a. = sizeof(struct structMatrixcxx . . $ structMatrix#); |
| 30 | |
| 31 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (PowerCepstrogram, Matrix, 2); // derives from Matrix -> also version 2 |
| 32 | |
| 33 | double structPowerCepstrogramcxx . . $ structPowerCepstrogram# :: v_getValueAtSamplecxx . . $ structPowerCepstrogram#v_getValueAtSample(8bbfc6ce471470c9). (integercxx . . $ integer# sampleNumber, integercxx . . $ integer# row, int unit) const { |
| 34 | double result = undefinedcxx . . $ undefined.; |
| 35 | if (row >= 1 && row <= nycxx . . $ structSampledXY#ny.) { |
| 36 | if (unit == 0) |
| 37 | result = zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).sampleNumber]; |
| 38 | else |
| 39 | result = 10.0 * log10cxx . . $ log10(fee4f1d22bc8e617). (zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).sampleNumber] + 1e-30); // always positive |
| 40 | } |
| 41 | return result; |
| 42 | } |
| 43 | |
| 44 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# PowerCepstrogram_createcxx . . $ PowerCepstrogram_create(bde97b71e31956b6). (double tmin, double tmax, integercxx . . $ integer# nt, double dt, double t1, |
| 45 | double qmin, double qmax, integercxx . . $ integer# nq, double dq, double q1) { |
| 46 | try { |
| 47 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (PowerCepstrogram); |
| 48 | Matrix_initcxx . . $ Matrix_init(9dd6c49f9830a091). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, nt, dt, t1, qmin, qmax, nq, dq, q1); |
| 49 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 50 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 51 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"PowerCepstrogram not created."); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void PowerCepstrogram_paintcxx . . $ PowerCepstrogram_paint(e228a6e630a2d0e1). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, Graphicscxx . . $ Graphics# g, double tmin, double tmax, double qmin, double qmax, double dBmaximum, int autoscaling, double dynamicRangedB, double dynamicCompression, bool garnish) { |
| 56 | Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax); |
| 57 | SampledXY_unidirectionalAutowindowYcxx . . $ SampledXY_unidirectionalAutowindowY(b6a531eed30bf40e). (me, & qmin, & qmax); |
| 58 | integercxx . . $ integer# itmin, itmax, ifmin, ifmax; |
| 59 | if (Matrix_getWindowSamplesXcxx . . $ Matrix_getWindowSamplesX(c738979be11bd51a). (me, tmin - 0.49999 * mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., tmax + 0.49999 * mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., & itmin, & itmax) == 0 || |
| 60 | Matrix_getWindowSamplesYcxx . . $ Matrix_getWindowSamplesY(c738979be11bd51a). (me, qmin - 0.49999 * mycxx . . $ `melder/melder.h:44:9`! dycxx . . $ structSampledXY#dy., qmax + 0.49999 * mycxx . . $ `melder/melder.h:44:9`! dycxx . . $ structSampledXY#dy., & ifmin, & ifmax) == 0) |
| 61 | return; |
| 62 | autoMatrixcxx . . $ autoMatrix# thee = Data_copycxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21). (me); |
| 63 | MelderExtremaWithInitcxx . . $ MelderExtremaWithInit# extrema; |
| 64 | for (integercxx . . $ integer# irow = 1; irow <= mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.; irow ++) { |
| 65 | for (integercxx . . $ integer# icol = 1; icol <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; icol ++) { |
| 66 | const double val = TO10LOGcxx . . $ `LPC/PowerCepstrogram.cpp:27:9`! (mycxx . . $ `melder/melder.h:44:9`! z [irow] [icol]); |
| 67 | extrema.updatecxx . . $ MelderExtremaWithInit#update(ba8836b59fb42830). (val); |
| 68 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = val; |
| 69 | } |
| 70 | } |
| 71 | double dBminimum = dBmaximum - dynamicRangedB; |
| 72 | if (autoscaling) { |
| 73 | dBminimum = extrema.mincxx . . $ MelderExtremaWithInit#min.; |
| 74 | dBmaximum = extrema.maxcxx . . $ MelderExtremaWithInit#max.; |
| 75 | } |
| 76 | |
| 77 | for (integercxx . . $ integer# icol = 1; icol <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; icol ++) { |
| 78 | const double lmax = NUMmax_ucxx . . $ NUMmax_u(4bb9c3e3a8dd5442). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (icol)); |
| 79 | if (isundefcxx . . $ isundef(f8197d536af80c96). (lmax)) |
| 80 | return; |
| 81 | const double factor = dynamicCompression * (extrema.maxcxx . . $ MelderExtremaWithInit#max. - lmax); |
| 82 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (icol) +=cxx . . $ `operator+=`(c555d170d72ff256). factor; |
| 83 | } |
| 84 | |
| 85 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g); |
| 86 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, tmin, tmax, qmin, qmax); |
| 87 | Graphics_imagecxx . . $ Graphics_image(a5d48eb8683d0521). (g, thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..partcxx . . $ automatrix#part(5c23e73480cfacfb). (ifmin, ifmax, itmin, itmax), |
| 88 | Matrix_columnToXcxx . . $ Matrix_columnToX(89d6d8659270b8b7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), itmin - 0.5), |
| 89 | Matrix_columnToXcxx . . $ Matrix_columnToX(89d6d8659270b8b7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), itmax + 0.5), |
| 90 | Matrix_rowToYcxx . . $ Matrix_rowToY(89d6d8659270b8b7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ifmin - 0.5), |
| 91 | Matrix_rowToYcxx . . $ Matrix_rowToY(89d6d8659270b8b7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ifmax + 0.5), |
| 92 | dBminimum, dBmaximum); |
| 93 | |
| 94 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g); |
| 95 | if (garnish) { |
| 96 | Graphics_drawInnerBoxcxx . . $ Graphics_drawInnerBox(2d838ed765120c5d). (g); |
| 97 | Graphics_textBottomcxx . . $ Graphics_textBottom(48cf1f690ec61203). (g, true, U"Time (s)"); |
| 98 | Graphics_marksBottomcxx . . $ Graphics_marksBottom(c3a11a8a55b243ff). (g, 2, true, true, false); |
| 99 | Graphics_marksLeftcxx . . $ Graphics_marksLeft(c3a11a8a55b243ff). (g, 2, true, true, false); |
| 100 | Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, true, U"Quefrency (s)"); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | void PowerCepstrogram_subtractTrend_inplacecxx . . $ PowerCepstrogram_subtractTrend_inplace(83c1ee410c32d421). (mutablePowerCepstrogramcxx . . $ mutablePowerCepstrogram# me, double qminFit, double qmaxFit, |
| 105 | kCepstrum_trendTypecxx . . $ kCepstrum_trendType# lineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) |
| 106 | { |
| 107 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# thee = PowerCepstrogram_subtractTrendcxx . . $ PowerCepstrogram_subtractTrend(a230c63ce2610488). (me, qminFit, qmaxFit, lineType, fitMethod); |
| 108 | mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). copy_MATcxx . . $ copy_MAT(a392b09ce3fc3972). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 109 | } |
| 110 | |
| 111 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# PowerCepstrogram_subtractTrendcxx . . $ PowerCepstrogram_subtractTrend(a230c63ce2610488). (constPowerCepstrogramcxx . . $ constPowerCepstrogram# me, double qminFit, double qmaxFit, kCepstrum_trendTypecxx . . $ kCepstrum_trendType# trendLineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) { |
| 112 | try { |
| 113 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# thee = PowerCepstrogram_createcxx . . $ PowerCepstrogram_create(bde97b71e31956b6). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1., |
| 114 | mycxx . . $ `melder/melder.h:44:9`! ymincxx . . $ structSampledXY#ymin., mycxx . . $ `melder/melder.h:44:9`! ymaxcxx . . $ structSampledXY#ymax., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny., mycxx . . $ `melder/melder.h:44:9`! dycxx . . $ structSampledXY#dy., mycxx . . $ `melder/melder.h:44:9`! y1cxx . . $ structSampledXY#y1.); |
| 115 | const integercxx . . $ integer# thresholdNumberOfFramesPerThread = 10; |
| 116 | |
| 117 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (mycxx . . $ `melder/melder.h:44:9`! nx, thresholdNumberOfFramesPerThread) { |
| 118 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# powerCepstrum = PowerCepstrum_createcxx . . $ PowerCepstrum_create(65f6cc037cbc1c8a). (mycxx . . $ `melder/melder.h:44:9`! ymaxcxx . . $ structSampledXY#ymax., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.); |
| 119 | autoPowerCepstrumWorkspacecxx . . $ autoPowerCepstrumWorkspace# ws = PowerCepstrumWorkspace_createcxx . . $ PowerCepstrumWorkspace_create(fb1b3573b07a0390). (powerCepstrum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), qminFit, qmaxFit, trendLineType, fitMethod); |
| 120 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 121 | powerCepstrumcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe); |
| 122 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). newDatacxx . . $ structPowerCepstrumWorkspace#newData(97428d87df076bf). (powerCepstrum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 123 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getSlopeAndInterceptcxx . . $ structPowerCepstrumWorkspace#getSlopeAndIntercept(49f6e7a06ebc5aa8). (); |
| 124 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). subtractTrendcxx . . $ structPowerCepstrumWorkspace#subtractTrend(49f6e7a06ebc5aa8). (); |
| 125 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe) <<=cxx . . $ `operator<<=`(adea042513329390). powerCepstrumcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 126 | } |
| 127 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 128 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 129 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 130 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no trend subtracted."); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | autoTablecxx . . $ autoTable# PowerCepstrogram_to_Table_hillenbrandcxx . . $ PowerCepstrogram_to_Table_hillenbrand(d04d1cc2c1a2ca3a). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double pitchFloor, double pitchCeiling) { |
| 135 | try { |
| 136 | const conststring32cxx . . $ conststring32# columnNames [] = { U"time(s)", U"quefrency(s)", U"CPP(dB)", U"f0(Hz)" }; |
| 137 | autoTablecxx . . $ autoTable# thee = Table_createWithColumnNamescxx . . $ Table_createWithColumnNames(41b41b537590f3f4). (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., ARRAY_TO_STRVECcxx . . $ `melder/melder_strvec.h:262:9`! (columnNames)); |
| 138 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# him = PowerCepstrum_createcxx . . $ PowerCepstrum_create(65f6cc037cbc1c8a). (mycxx . . $ `melder/melder.h:44:9`! ymaxcxx . . $ structSampledXY#ymax., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.); |
| 139 | for (integercxx . . $ integer# icol = 1; icol <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; icol ++) { |
| 140 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (icol); |
| 141 | double qpeak; |
| 142 | const double cpp = PowerCepstrum_getPeakProminence_hillenbrandcxx . . $ PowerCepstrum_getPeakProminence_hillenbrand(e2f5b9137cc1c6d6). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pitchFloor, pitchCeiling, qpeak); |
| 143 | const double time = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (me, icol); |
| 144 | Table_setNumericValuecxx . . $ Table_setNumericValue(adcc5027476b94a0). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), icol, 1, time); |
| 145 | Table_setNumericValuecxx . . $ Table_setNumericValue(adcc5027476b94a0). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), icol, 2, qpeak); |
| 146 | Table_setNumericValuecxx . . $ Table_setNumericValue(adcc5027476b94a0). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), icol, 3, cpp); // Cepstrogram_getCPPS depends on this index 3!! |
| 147 | Table_setNumericValuecxx . . $ Table_setNumericValue(adcc5027476b94a0). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), icol, 4, 1.0 / qpeak); |
| 148 | } |
| 149 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 150 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 151 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Table with cepstral peak prominence values created."); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | static void PowerCepstrogram_into_Matrix_CPPcxx . . $ PowerCepstrogram_into_Matrix_CPP(9b47cf0a70c9e055). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, mutableMatrixcxx . . $ mutableMatrix# thee, bool trendSubtracted, double pitchFloor, |
| 156 | double pitchCeiling, double deltaF0, kVector_peakInterpolationcxx . . $ kVector_peakInterpolation# peakInterpolationType, double qminFit, double qmaxFit, |
| 157 | kCepstrum_trendTypecxx . . $ kCepstrum_trendType# trendLineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) |
| 158 | { |
| 159 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thycxx . . $ `melder/melder.h:45:9`! ny == 6); |
| 160 | const integercxx . . $ integer# numberOfFrames = thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx., thresholdNumberOfFramesPerThread = 10; |
| 161 | const double qminPeakSearch = 1.0 / pitchCeiling, qmaxPeakSearch = 1.0 / pitchFloor; |
| 162 | MelderThread_PARALLELcxx . . $ `melder/MelderThread.h:173:9`! (numberOfFrames, thresholdNumberOfFramesPerThread) { |
| 163 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# powerCepstrum = PowerCepstrum_createcxx . . $ PowerCepstrum_create(65f6cc037cbc1c8a). (mycxx . . $ `melder/melder.h:44:9`! ymaxcxx . . $ structSampledXY#ymax., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.); |
| 164 | autoPowerCepstrumWorkspacecxx . . $ autoPowerCepstrumWorkspace# ws = PowerCepstrumWorkspace_createcxx . . $ PowerCepstrumWorkspace_create(fb1b3573b07a0390). (powerCepstrum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), qminFit, qmaxFit, trendLineType, fitMethod); |
| 165 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). initPeakSearchPartcxx . . $ structPowerCepstrumWorkspace#initPeakSearchPart(f64aff899444c20a). (qminPeakSearch, qmaxPeakSearch, peakInterpolationType); |
| 166 | MelderThread_FORcxx . . $ `melder/MelderThread.h:183:9`! (iframe) { |
| 167 | powerCepstrumcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe); |
| 168 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). newDatacxx . . $ structPowerCepstrumWorkspace#newData(97428d87df076bf). (powerCepstrum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 169 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). trendSubtractedcxx . . $ structPowerCepstrumWorkspace#trendSubtracted. = trendSubtracted; |
| 170 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getSlopeAndInterceptcxx . . $ structPowerCepstrumWorkspace#getSlopeAndIntercept(49f6e7a06ebc5aa8). (); |
| 171 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). slopeKnowncxx . . $ structPowerCepstrumWorkspace#slopeKnown. = true; |
| 172 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getPeakAndPositioncxx . . $ structPowerCepstrumWorkspace#getPeakAndPosition(49f6e7a06ebc5aa8). (); |
| 173 | ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). getCPPcxx . . $ structPowerCepstrumWorkspace#getCPP(49f6e7a06ebc5aa8). (); |
| 174 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (thee, iframe); |
| 175 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).2] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). slopecxx . . $ structPowerCepstrumWorkspace#slope.; |
| 176 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).3] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interceptcxx . . $ structPowerCepstrumWorkspace#intercept.; |
| 177 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).4] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). peakdBcxx . . $ structPowerCepstrumWorkspace#peakdB.; |
| 178 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).5] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). peakQuefrencycxx . . $ structPowerCepstrumWorkspace#peakQuefrency.; |
| 179 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).6] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = ws ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). cppcxx . . $ structPowerCepstrumWorkspace#cpp.; |
| 180 | } |
| 181 | } MelderThread_ENDPARALLELcxx . . $ `melder/MelderThread.h:189:9`! |
| 182 | } |
| 183 | |
| 184 | static autoMatrixcxx . . $ autoMatrix# PowerCepstrogram_to_Matrix_CPPcxx . . $ PowerCepstrogram_to_Matrix_CPP(aafea8f0324cb9fa). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, bool trendSubtracted, double pitchFloor, double pitchCeiling, |
| 185 | double deltaF0, kVector_peakInterpolationcxx . . $ kVector_peakInterpolation# peakInterpolationType, double qminFit, double qmaxFit, |
| 186 | kCepstrum_trendTypecxx . . $ kCepstrum_trendType# lineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) |
| 187 | { |
| 188 | try { |
| 189 | /* Matrix rows: time, cppRaw, slope, intercept, cppCorrected, peakQuefrency */ |
| 190 | autoMatrixcxx . . $ autoMatrix# thee = Matrix_createcxx . . $ Matrix_create(494a3ae9ff7e3b60). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1., 0.5, 6.5, 6, 1.0, 1.0); |
| 191 | PowerCepstrogram_into_Matrix_CPPcxx . . $ PowerCepstrogram_into_Matrix_CPP(9b47cf0a70c9e055). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), trendSubtracted, pitchFloor, pitchCeiling, deltaF0, peakInterpolationType, |
| 192 | qminFit, qmaxFit, lineType, fitMethod); |
| 193 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 194 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 195 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": could mot create Matrix with CPP values. "); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | autoTablecxx . . $ autoTable# PowerCepstrogram_to_Table_CPPcxx . . $ PowerCepstrogram_to_Table_CPP(3c2647b8f0ab4b03). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, bool includeFrameNumber, bool includeTime, |
| 200 | integercxx . . $ integer# numberOfTimeDecimals, integercxx . . $ integer# numberOfCPPdecimals, bool includePeakQuefrency, integercxx . . $ integer# numberOfQuefrencyDecimals, |
| 201 | double pitchFloor, double pitchCeiling, double deltaF0, kVector_peakInterpolationcxx . . $ kVector_peakInterpolation# peakInterpolationType, double qminFit, double qmaxFit, kCepstrum_trendTypecxx . . $ kCepstrum_trendType# lineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) { |
| 202 | try { |
| 203 | autoTablecxx . . $ autoTable# thee = Table_createWithoutColumnNamescxx . . $ Table_createWithoutColumnNames(9861d2482f105183). (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., includeFrameNumber + includeTime + includePeakQuefrency + 1); |
| 204 | integercxx . . $ integer# icol = 0; |
| 205 | if (includeFrameNumber) |
| 206 | Table_renameColumn_ecxx . . $ Table_renameColumn_e(f3de302d64cc2e6c). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ++ icol, U"frame"); |
| 207 | if (includeTime) |
| 208 | Table_renameColumn_ecxx . . $ Table_renameColumn_e(f3de302d64cc2e6c). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ++ icol, U"time(s)"); |
| 209 | if (includePeakQuefrency) |
| 210 | Table_renameColumn_ecxx . . $ Table_renameColumn_e(f3de302d64cc2e6c). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ++ icol, U"quefrency(s)"); |
| 211 | Table_renameColumn_ecxx . . $ Table_renameColumn_e(f3de302d64cc2e6c). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ++ icol, U"CPP(dB)"); |
| 212 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# him = PowerCepstrum_createcxx . . $ PowerCepstrum_create(65f6cc037cbc1c8a). (mycxx . . $ `melder/melder.h:44:9`! ymaxcxx . . $ structSampledXY#ymax., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.); |
| 213 | for (integercxx . . $ integer# iframe = 1; iframe <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; iframe ++) { |
| 214 | icol = 0; |
| 215 | if (includeFrameNumber) |
| 216 | Table_setNumericValuecxx . . $ Table_setNumericValue(adcc5027476b94a0). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), iframe, ++ icol, iframe); |
| 217 | if (includeTime) |
| 218 | Table_setStringValuecxx . . $ Table_setStringValue(309228d4a4a76ab1). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), iframe, ++ icol, Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (me, iframe), numberOfTimeDecimals)); |
| 219 | hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe); |
| 220 | double peakQuefrency; |
| 221 | const double cpp = PowerCepstrum_getPeakProminencecxx . . $ PowerCepstrum_getPeakProminence(4004aa546187d74). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pitchFloor, pitchCeiling, peakInterpolationType, |
| 222 | qminFit, qmaxFit, lineType, fitMethod, peakQuefrency); |
| 223 | if (includePeakQuefrency) |
| 224 | Table_setStringValuecxx . . $ Table_setStringValue(309228d4a4a76ab1). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), iframe, ++ icol, Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (peakQuefrency, numberOfQuefrencyDecimals)); |
| 225 | Table_setStringValuecxx . . $ Table_setStringValue(309228d4a4a76ab1). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), iframe, ++ icol, Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (cpp, numberOfCPPdecimals)); |
| 226 | } |
| 227 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 228 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 229 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Table with cepstral peak prominence values created."); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | autoTablecxx . . $ autoTable# PowerCepstrogram_to_Table_CPPvaluescxx . . $ PowerCepstrogram_to_Table_CPPvalues(63c4d242c3c4a41b). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double pitchFloor, double pitchCeiling, |
| 234 | double deltaF0, kVector_peakInterpolationcxx . . $ kVector_peakInterpolation# peakInterpolationType, double qminFit, double qmaxFit, |
| 235 | kCepstrum_trendTypecxx . . $ kCepstrum_trendType# lineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) |
| 236 | { |
| 237 | try { |
| 238 | static const conststring32cxx . . $ conststring32# colNames [] = { U"time(s)", U"dB/s", U"intercept(dB)", U"peak(dB)", U"quefrency(s)", U"cpp(dB)" }; |
| 239 | autoTablecxx . . $ autoTable# thee = Table_createWithColumnNamescxx . . $ Table_createWithColumnNames(41b41b537590f3f4). (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., ARRAY_TO_STRVECcxx . . $ `melder/melder_strvec.h:262:9`! (colNames)); |
| 240 | if (lineType == kCepstrum_trendTypecxx . . $ kCepstrum_trendType#::EXPONENTIAL_DECAYcxx . . $ kCepstrum_trendType#EXPONENTIAL_DECAY.) |
| 241 | Table_renameColumn_ecxx . . $ Table_renameColumn_e(f3de302d64cc2e6c). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 2, U"dB/ln(s)"); |
| 242 | autoMatrixcxx . . $ autoMatrix# m = PowerCepstrogram_to_Matrix_CPPcxx . . $ PowerCepstrogram_to_Matrix_CPP(aafea8f0324cb9fa). (me, false, pitchFloor, pitchCeiling, |
| 243 | deltaF0, peakInterpolationType, qminFit, qmaxFit, lineType, fitMethod); |
| 244 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (m -> nx == mycxx . . $ `melder/melder.h:44:9`! nx && m -> ny == 6); |
| 245 | for (integercxx . . $ integer# irow = 1; irow <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; irow ++) { |
| 246 | for (integercxx . . $ integer# icol = 1; icol <= m ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nycxx . . $ structSampledXY#ny.; icol ++) |
| 247 | Table_setNumericValuecxx . . $ Table_setNumericValue(adcc5027476b94a0). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), irow, icol, m ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).icol] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).irow]); |
| 248 | } |
| 249 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 250 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 251 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Could not create Table from PowerCepstrogram."); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | void PowerCepstrogram_listCPPcxx . . $ PowerCepstrogram_listCPP(3a0656b26706ebd2). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, bool includeFrameNumber, bool includeTime, |
| 256 | integercxx . . $ integer# numberOfTimeDecimals, integercxx . . $ integer# numberOfCPPdecimals, bool includePeakQuefrency, integercxx . . $ integer# numberOfQuefrencyDecimals, |
| 257 | double pitchFloor, double pitchCeiling, double deltaF0, kVector_peakInterpolationcxx . . $ kVector_peakInterpolation# peakInterpolationType, |
| 258 | double qminFit, double qmaxFit, kCepstrum_trendTypecxx . . $ kCepstrum_trendType# lineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) |
| 259 | { |
| 260 | try { |
| 261 | autoTablecxx . . $ autoTable# table = PowerCepstrogram_to_Table_CPPcxx . . $ PowerCepstrogram_to_Table_CPP(3c2647b8f0ab4b03). (me, includeFrameNumber, includeTime, |
| 262 | numberOfTimeDecimals, numberOfCPPdecimals, includePeakQuefrency, numberOfQuefrencyDecimals, |
| 263 | pitchFloor, pitchCeiling, deltaF0, peakInterpolationType, qminFit, qmaxFit, lineType, fitMethod); |
| 264 | Table_listcxx . . $ Table_list(8e854cd23ee58a8f). (table.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false); |
| 265 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 266 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": CPP not listed."); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | static autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# PowerCepstrogram_smoothRectangularcxx . . $ PowerCepstrogram_smoothRectangular(784f2760925e5127). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double timeAveragingWindow, double quefrencyAveragingWindow) { |
| 271 | try { |
| 272 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# thee = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me); |
| 273 | /* |
| 274 | 1. average across time |
| 275 | */ |
| 276 | const integercxx . . $ integer# numberOfFrames = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (timeAveragingWindow / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.); |
| 277 | if (numberOfFrames > 1) { |
| 278 | const double halfWindow = 0.5 * timeAveragingWindow; |
| 279 | autoVECcxx . . $ autoVEC# qout = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.); |
| 280 | for (integercxx . . $ integer# iq = 1; iq <= mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.; iq ++) { |
| 281 | for (integercxx . . $ integer# iframe = 1; iframe <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; iframe ++) { |
| 282 | const double xmid = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (me, iframe); |
| 283 | qout [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe] = Sampled_getMeancxx . . $ Sampled_getMean(2a8b0d40a92e6734). (me, xmid - halfWindow, xmid + halfWindow, iq, 0, true); |
| 284 | } |
| 285 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iq) <<=cxx . . $ `operator<<=`(adea042513329390). qoutcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(); |
| 286 | } |
| 287 | } |
| 288 | /* |
| 289 | 2. average across quefrencies |
| 290 | */ |
| 291 | const integercxx . . $ integer# numberOfQuefrencyBins = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (quefrencyAveragingWindow / mycxx . . $ `melder/melder.h:44:9`! dycxx . . $ structSampledXY#dy.); |
| 292 | if (numberOfQuefrencyBins > 1) { |
| 293 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# smooth = PowerCepstrum_createcxx . . $ PowerCepstrum_create(65f6cc037cbc1c8a). (thycxx . . $ `melder/melder.h:45:9`! ymaxcxx . . $ structSampledXY#ymax., thycxx . . $ `melder/melder.h:45:9`! nycxx . . $ structSampledXY#ny.); |
| 294 | for (integercxx . . $ integer# iframe = 1; iframe <= thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.; iframe ++) { |
| 295 | smoothcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe); |
| 296 | PowerCepstrum_smooth_inplacecxx . . $ PowerCepstrum_smooth_inplace(7a6e9b94d2abb698). (smooth.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), quefrencyAveragingWindow, 1); |
| 297 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe) <<=cxx . . $ `operator<<=`(adea042513329390). smoothcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1); |
| 298 | } |
| 299 | } |
| 300 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 301 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 302 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not smoothed."); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | static autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# PowerCepstrogram_smoothRectangular_oldcxx . . $ PowerCepstrogram_smoothRectangular_old(784f2760925e5127). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double timeAveragingWindow, double quefrencyAveragingWindow) { |
| 307 | try { |
| 308 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# thee = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me); |
| 309 | /* |
| 310 | 1. average across time |
| 311 | */ |
| 312 | const integercxx . . $ integer# numberOfFrames = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (timeAveragingWindow / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.); |
| 313 | if (numberOfFrames > 1) |
| 314 | for (integercxx . . $ integer# iq = 1; iq <= mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.; iq ++) |
| 315 | VECsmoothByMovingAverage_preallocatedcxx . . $ VECsmoothByMovingAverage_preallocated(5e8ce1ad74af04af). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iq), mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iq), numberOfFrames); |
| 316 | /* |
| 317 | 2. average across quefrencies |
| 318 | */ |
| 319 | const integercxx . . $ integer# numberOfQuefrencyBins = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (quefrencyAveragingWindow / mycxx . . $ `melder/melder.h:44:9`! dycxx . . $ structSampledXY#dy.); |
| 320 | if (numberOfQuefrencyBins > 1) { |
| 321 | autoVECcxx . . $ autoVEC# qin = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (thycxx . . $ `melder/melder.h:45:9`! nycxx . . $ structSampledXY#ny.); |
| 322 | for (integercxx . . $ integer# iframe = 1; iframe <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; iframe ++) { |
| 323 | qin.allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe); |
| 324 | VECsmoothByMovingAverage_preallocatedcxx . . $ VECsmoothByMovingAverage_preallocated(5e8ce1ad74af04af). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe), qincxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(), numberOfQuefrencyBins); |
| 325 | } |
| 326 | } |
| 327 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 328 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 329 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not smoothed."); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | static autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# PowerCepstrogram_smoothGaussiancxx . . $ PowerCepstrogram_smoothGaussian(784f2760925e5127). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double timeAveragingWindow, double quefrencyAveragingWindow) { |
| 334 | try { |
| 335 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# thee = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me); |
| 336 | /* |
| 337 | 1. average across time |
| 338 | */ |
| 339 | const double numberOfSigmasInWindow = 4.0; |
| 340 | const double numberOfFrames = timeAveragingWindow / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.; |
| 341 | if (numberOfFrames > 1.0) { |
| 342 | const double sigma = numberOfFrames / numberOfSigmasInWindow; // 2sigma -> 95.4%, 3sigma -> 99.7 % of the data |
| 343 | const integercxx . . $ integer# nfft = Melder_clippedLeftcxx . . $ Melder_clippedLeft(f80f7d6260b3ee3a). (2_integercxx . . $ `operator""_integer`(85240eb457c3721a)., Melder_iroundUpToPowerOfTwocxx . . $ Melder_iroundUpToPowerOfTwo(8ce0d1b217db7fd1). (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.)); // TODO: explain edge case |
| 344 | autoNUMFourierTablecxx . . $ autoNUMFourierTable# fourierTable = NUMFourierTable_createcxx . . $ NUMFourierTable_create(10012c71e147318e). (nfft); |
| 345 | for (integercxx . . $ integer# iq = 1; iq <= mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.; iq ++) { |
| 346 | VECsmooth_gaussiancxx . . $ VECsmooth_gaussian(f66dda4be53d10a1). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iq), mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iq), sigma, fourierTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 347 | abs_VEC_inoutcxx . . $ abs_VEC_inout(41aeeb373bdabfed). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iq)); |
| 348 | } |
| 349 | } |
| 350 | /* |
| 351 | 2. average across quefrencies |
| 352 | */ |
| 353 | const double numberOfQuefrencyBins = quefrencyAveragingWindow / mycxx . . $ `melder/melder.h:44:9`! dycxx . . $ structSampledXY#dy.; |
| 354 | if (numberOfQuefrencyBins > 1.0) { |
| 355 | const integercxx . . $ integer# nfft = Melder_clippedLeftcxx . . $ Melder_clippedLeft(f80f7d6260b3ee3a). (2_integercxx . . $ `operator""_integer`(85240eb457c3721a)., Melder_iroundUpToPowerOfTwocxx . . $ Melder_iroundUpToPowerOfTwo(8ce0d1b217db7fd1). (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.)); // TODO: explain edge case |
| 356 | autoNUMFourierTablecxx . . $ autoNUMFourierTable# fourierTable = NUMFourierTable_createcxx . . $ NUMFourierTable_create(10012c71e147318e). (nfft); |
| 357 | const double sigma = numberOfQuefrencyBins / numberOfSigmasInWindow; // 2sigma -> 95.4%, 3sigma -> 99.7 % of the data |
| 358 | for (integercxx . . $ integer# iframe = 1; iframe <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; iframe ++) { |
| 359 | VECsmooth_gaussian_inplacecxx . . $ VECsmooth_gaussian_inplace(2a239a383ab729f). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe), sigma, fourierTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 360 | abs_VEC_inoutcxx . . $ abs_VEC_inout(41aeeb373bdabfed). (thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe)); |
| 361 | } |
| 362 | } |
| 363 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 364 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 365 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not smoothed."); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# PowerCepstrogram_smoothcxx . . $ PowerCepstrogram_smooth(784f2760925e5127). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double timeAveragingWindow, double quefrencyAveragingWindow) { |
| 370 | if (Melder_debugcxx . . $ Melder_debug. == -4) |
| 371 | return PowerCepstrogram_smoothRectangular_oldcxx . . $ PowerCepstrogram_smoothRectangular_old(784f2760925e5127). (me, timeAveragingWindow, quefrencyAveragingWindow); |
| 372 | else if (Melder_debugcxx . . $ Melder_debug. == -5) |
| 373 | return PowerCepstrogram_smoothGaussiancxx . . $ PowerCepstrogram_smoothGaussian(784f2760925e5127). (me, timeAveragingWindow, quefrencyAveragingWindow); |
| 374 | else |
| 375 | return PowerCepstrogram_smoothRectangularcxx . . $ PowerCepstrogram_smoothRectangular(784f2760925e5127). (me, timeAveragingWindow, quefrencyAveragingWindow); |
| 376 | } |
| 377 | |
| 378 | autoMatrixcxx . . $ autoMatrix# PowerCepstrogram_to_Matrixcxx . . $ PowerCepstrogram_to_Matrix(f63da8dca4ae29d5). (PowerCepstrogramcxx . . $ PowerCepstrogram# me) { |
| 379 | try { |
| 380 | autoMatrixcxx . . $ autoMatrix# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Matrix); |
| 381 | mycxx . . $ `melder/melder.h:44:9`! structMatrixcxx . . $ structMatrix# :: v1_copycxx . . $ structMatrix#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 382 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 383 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 384 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Matrix."); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# PowerCepstrogram_to_PowerCepstrum_slicecxx . . $ PowerCepstrogram_to_PowerCepstrum_slice(cffbf2e4edc2074). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, double time) { |
| 389 | try { |
| 390 | integercxx . . $ integer# iframe = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (me, time); |
| 391 | iframe = iframe < 1 ? 1 : iframe > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx. ? mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx. : iframe; |
| 392 | autoPowerCepstrumcxx . . $ autoPowerCepstrum# thee = PowerCepstrum_createcxx . . $ PowerCepstrum_create(65f6cc037cbc1c8a). (mycxx . . $ `melder/melder.h:44:9`! ymaxcxx . . $ structSampledXY#ymax., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.); |
| 393 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (iframe); |
| 394 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 395 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 396 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": Cepstrum not extracted."); |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# Matrix_to_PowerCepstrogramcxx . . $ Matrix_to_PowerCepstrogram(66931413c5178fa4). (Matrixcxx . . $ Matrix# me) { |
| 401 | try { |
| 402 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (PowerCepstrogram); |
| 403 | mycxx . . $ `melder/melder.h:44:9`! structMatrixcxx . . $ structMatrix# :: v1_copycxx . . $ structMatrix#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 404 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 405 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 406 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to PowerCepstrogram."); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | double PowerCepstrogram_getCPPScxx . . $ PowerCepstrogram_getCPPS(cc85b1fb6b62d83c). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, bool subtractTrendBeforeSmoothing, double timeAveragingWindow, double quefrencyAveragingWindow, double pitchFloor, double pitchCeiling, double deltaF0, kVector_peakInterpolationcxx . . $ kVector_peakInterpolation# peakInterpolationType, double qminFit, double qmaxFit, kCepstrum_trendTypecxx . . $ kCepstrum_trendType# lineType, kCepstrum_trendFitcxx . . $ kCepstrum_trendFit# fitMethod) { |
| 414 | try { |
| 415 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# flattenedcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 416 | bool trendSubtracted = subtractTrendBeforeSmoothing; |
| 417 | if (subtractTrendBeforeSmoothing) |
| 418 | flattened =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). PowerCepstrogram_subtractTrendcxx . . $ PowerCepstrogram_subtractTrend(a230c63ce2610488). (me, qminFit, qmaxFit, lineType, fitMethod); |
| 419 | |
| 420 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# smooth = PowerCepstrogram_smoothcxx . . $ PowerCepstrogram_smooth(784f2760925e5127). (subtractTrendBeforeSmoothing ? flattened.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).() : me, timeAveragingWindow, quefrencyAveragingWindow); |
| 421 | if (Melder_debugcxx . . $ Melder_debug. == -6) { // old algorithm |
| 422 | autoTablecxx . . $ autoTable# table = PowerCepstrogram_to_Table_CPPcxx . . $ PowerCepstrogram_to_Table_CPP(3c2647b8f0ab4b03). (smooth.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false, false, 6, 16, false, 6, pitchFloor, pitchCeiling, |
| 423 | deltaF0, peakInterpolationType, qminFit, qmaxFit, lineType, fitMethod); |
| 424 | const double cpps = Table_getMeancxx . . $ Table_getMean(676f3c91a8818756). (table.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1); // no frame number, no time, quefrency |
| 425 | return cpps; |
| 426 | } else { |
| 427 | autoMatrixcxx . . $ autoMatrix# cpp = PowerCepstrogram_to_Matrix_CPPcxx . . $ PowerCepstrogram_to_Matrix_CPP(aafea8f0324cb9fa). (smooth.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), trendSubtracted, pitchFloor, pitchCeiling, deltaF0, |
| 428 | peakInterpolationType, qminFit, qmaxFit, lineType, fitMethod); |
| 429 | const double cpps = Matrix_getMeancxx . . $ Matrix_getMean(ebf5718d71cfe4d5). (cpp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cpp ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmincxx . . $ structFunction#xmin., cpp ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). xmaxcxx . . $ structFunction#xmax., 5.5, 6.5); // TODO Sampled_getMean?? |
| 430 | return cpps; |
| 431 | } |
| 432 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 433 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no CPPS value calculated."); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | double PowerCepstrogram_getCPPS_hillenbrandcxx . . $ PowerCepstrogram_getCPPS_hillenbrand(d729da23b6b7ca26). (PowerCepstrogramcxx . . $ PowerCepstrogram# me, bool subtractTrendBeforeSmoothing, double timeAveragingWindow, double quefrencyAveragingWindow, double pitchFloor, double pitchCeiling) { |
| 438 | try { |
| 439 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# himcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 440 | if (subtractTrendBeforeSmoothing) |
| 441 | him =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). PowerCepstrogram_subtractTrendcxx . . $ PowerCepstrogram_subtractTrend(a230c63ce2610488). (me, 0.001, 0, kCepstrum_trendTypecxx . . $ kCepstrum_trendType#::LINEARcxx . . $ kCepstrum_trendType#LINEAR., kCepstrum_trendFitcxx . . $ kCepstrum_trendFit#::LEAST_SQUAREScxx . . $ kCepstrum_trendFit#LEAST_SQUARES.); |
| 442 | |
| 443 | autoPowerCepstrogramcxx . . $ autoPowerCepstrogram# smooth = PowerCepstrogram_smoothcxx . . $ PowerCepstrogram_smooth(784f2760925e5127). (subtractTrendBeforeSmoothing ? him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).() : me, timeAveragingWindow, quefrencyAveragingWindow); |
| 444 | autoTablecxx . . $ autoTable# table = PowerCepstrogram_to_Table_hillenbrandcxx . . $ PowerCepstrogram_to_Table_hillenbrand(d04d1cc2c1a2ca3a). (smooth.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pitchFloor, pitchCeiling); |
| 445 | const double cpps = Table_getMeancxx . . $ Table_getMean(676f3c91a8818756). (table.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 3); |
| 446 | return cpps; |
| 447 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 448 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no CPPS value calculated."); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | /* End of file PowerCepstrogram.cpp */ |