Debian Codegraph @

fon/Spectrum_to_Excitation.cpp

raw symbols SCIP
1 /* Spectrum_to_Excitation.cpp
2 *
3 * Copyright (C) 1992-2005,2011,2014-2020,2023 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Spectrum_to_Excitation.h"cxx . . $ `<file>/fon/Spectrum_to_Excitation.h`/
20
21 autoExcitationcxx . . $ autoExcitation# Spectrum_to_Excitationcxx . . $ Spectrum_to_Excitation(921ae313082a41f3). (Spectrumcxx . . $ Spectrum# me, double dbark) {
22 try {
23 const integercxx . . $ integer# nbark = Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (25.6 / dbark);
24 const constVECcxx . . $ constVEC# re = mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1), im = mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (2);
25 const autoVECcxx . . $ autoVEC# auditoryFilter = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (nbark);
26 for (integercxx . . $ integer# i = 1; i <= nbark; i ++) {
27 const double bark = dbark * (i - nbark/2) + 0.474;
28 auditoryFilter [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = powcxx . . $ pow(9454dda30a4b8335). (10, (1.581 + 0.75 * bark - 1.75 * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (1 + bark * bark)));
29 }
30 /*const double filterArea = NUMsum (auditoryFilter.get());
31 auditoryFilter.all() /= filterArea;*/
32 const autoVECcxx . . $ autoVEC# rFreqs = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (nbark + 1);
33 const autoINTVECcxx . . $ autoINTVEC# iFreqs = raw_INTVECcxx . . $ raw_INTVEC(dab5d3ef28d6a25). (nbark + 1);
34 for (integercxx . . $ integer# i = 1; i <= nbark + 1; i ++) {
35 rFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = NUMbarkToHertzcxx . . $ NUMbarkToHertz(447c67c6676f75c3). (dbark * (i - 1));
36 iFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = Sampled_xToNearestIndexcxx . . $ Sampled_xToNearestIndex(405c2491bc3636e9). (me, rFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]);
37 }
38 const autoVECcxx . . $ autoVEC# inSig = zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (nbark);
39 for (integercxx . . $ integer# i = 1; i <= nbark; i ++) {
40 const integercxx . . $ integer# low = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., iFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]);
41 const integercxx . . $ integer# high = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (iFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + 1] - 1, mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.);
42 for (integercxx . . $ integer# j = low; j <= high; j ++)
43 inSig [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] += re [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * re [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] + im [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * im [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; // Pa2 s2
44
45 /* An anti-undersampling correction. */
46 if (high >= low)
47 inSig [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] *= 2.0 * (rFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + 1] - rFreqs [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]) / (high - low + 1) * mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.; // Pa2: power density in this band
48 }
49
50 /* Convolution with auditory (masking) filter. */
51
52 const autoVECcxx . . $ autoVEC# outSig = zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (2 * nbark);
53 for (integercxx . . $ integer# i = 1; i <= nbark; i ++)
54 for (integercxx . . $ integer# j = 1; j <= nbark; j ++)
55 outSig [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + j] += inSig [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] * auditoryFilter [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j];
56
57 autoExcitationcxx . . $ autoExcitation# thee = Excitation_createcxx . . $ Excitation_create(f4e2e4701e37a6f3). (dbark, nbark);
58 for (integercxx . . $ integer# i = 1; i <= nbark; i ++)
59 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = NUMsoundPressureToPhoncxx . . $ NUMsoundPressureToPhon(d8e7e0733fa41c87). (sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (outSig [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + nbark/2]), Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), i));
60
61 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
62 } catch (MelderErrorcxx . . $ MelderError#) {
63 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Excitation.");
64 }
65 }
66
67 /* End of file Spectrum_to_Excitation.cpp */