| 1 | /* LPC_to_Spectrogram.cpp |
| 2 | * |
| 3 | * Copyright (C) 1994-2019 David Weenink |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 | /* |
| 20 | djmw 20020812 GPL header |
| 21 | djmw 20080122 float -> double |
| 22 | */ |
| 23 | |
| 24 | #include "LPC_to_Spectrogram.h"cxx . . $ `<file>/LPC/LPC_to_Spectrogram.h`/ |
| 25 | |
| 26 | autoSpectrogramcxx . . $ autoSpectrogram# LPC_to_Spectrogramcxx . . $ LPC_to_Spectrogram(d487aad41c6543a2). (LPCcxx . . $ LPC# me, double dfMin, double bandwidthReduction, double deEmphasisFrequency) { |
| 27 | try { |
| 28 | const double samplingFrequency = 1.0 / mycxx . . $ `melder/melder.h:44:9`! samplingPeriodcxx . . $ structLPC#samplingPeriod.; |
| 29 | integercxx . . $ integer# nfft = 2; |
| 30 | if (dfMin <= 0.0) { |
| 31 | nfft = 512; |
| 32 | dfMin = samplingFrequency / nfft; |
| 33 | } |
| 34 | while (samplingFrequency / nfft > dfMin || nfft <= mycxx . . $ `melder/melder.h:44:9`! maxnCoefficientscxx . . $ structLPC#maxnCoefficients.) |
| 35 | nfft *= 2; |
| 36 | const double freqStep = samplingFrequency / nfft; |
| 37 | |
| 38 | autoSpectrogramcxx . . $ autoSpectrogram# thee = Spectrogram_createcxx . . $ Spectrogram_create(afddb115247e4bb0). (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.0, samplingFrequency / 2.0, nfft / 2 + 1, freqStep, 0.0); |
| 39 | |
| 40 | for (integercxx . . $ integer# iframe = 1; iframe <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; iframe ++) { |
| 41 | const double t = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (me, iframe); |
| 42 | autoSpectrumcxx . . $ autoSpectrum# spec = LPC_to_Spectrumcxx . . $ LPC_to_Spectrum(48d866ab98aaf9e7). (me, t, dfMin, bandwidthReduction, deEmphasisFrequency); |
| 43 | for (integercxx . . $ integer# j = 1; j <= spec ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx.; j ++) { |
| 44 | const double re = spec ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j], im = spec ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).2] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 45 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iframe] = re * re + im * im; |
| 46 | } |
| 47 | } |
| 48 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 49 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 50 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Spectrogram created."); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /* End of file LPC_to_Spectrogram.cpp */ |