Debian Codegraph @

dwtools/Spectrum_and_AnalyticSound.cpp

raw symbols SCIP
1 /* Spectrum_and_AnalyticSound.cpp
2 *
3 * Copyright (C) 2021-2022 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 #include "Spectrum_and_AnalyticSound.h"cxx . . $ `<file>/dwtools/Spectrum_and_AnalyticSound.h`/
20 #include "Sound_and_Spectrum.h"cxx . . $ `<file>/fon/Sound_and_Spectrum.h`/
21 #include "Spectrum_extensions.h"cxx . . $ `<file>/dwtools/Spectrum_extensions.h`/
22
23 autoAnalyticSoundcxx . . $ autoAnalyticSound# Spectrum_to_AnalyticSoundcxx . . $ Spectrum_to_AnalyticSound(a6cdc77beb7a4796). (Spectrumcxx . . $ Spectrum# me) {
24 try {
25 autoSoundcxx . . $ autoSound# him = Spectrum_to_Soundcxx . . $ Spectrum_to_Sound(b9577246d0f6b8d7). (me);
26 autoAnalyticSoundcxx . . $ autoAnalyticSound# thee = AnalyticSound_createcxx . . $ AnalyticSound_create(3663e8d9e13c92b4). (hiscxx . . $ `melder/melder.h:47:9`! xmincxx . . $ structFunction#xmin., hiscxx . . $ `melder/melder.h:47:9`! xmaxcxx . . $ structFunction#xmax., hiscxx . . $ `melder/melder.h:47:9`! nxcxx . . $ structSampled#nx., hiscxx . . $ `melder/melder.h:47:9`! dxcxx . . $ structSampled#dx., hiscxx . . $ `melder/melder.h:47:9`! x1cxx . . $ structSampled#x1.);
27 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1) <<=cxx . . $ `operator<<=`(adea042513329390). hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1);
28 Spectrum_shiftPhaseBy90Degreescxx . . $ Spectrum_shiftPhaseBy90Degrees(9136b6455db7f37). (me);
29 him =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Spectrum_to_Soundcxx . . $ Spectrum_to_Sound(b9577246d0f6b8d7). (me);
30 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (2) <<=cxx . . $ `operator<<=`(adea042513329390). hiscxx . . $ `melder/melder.h:47:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1);
31 Spectrum_unshiftPhaseBy90Degreescxx . . $ Spectrum_unshiftPhaseBy90Degrees(9136b6455db7f37). (me); // restore phase
32 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
33 } catch (MelderErrorcxx . . $ MelderError#) {
34 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": could not create AnalyticSound.");
35 }
36 }
37
38 /*
39
40
41 */
42 autoAnalyticSoundcxx . . $ autoAnalyticSound# Spectrum_to_AnalyticSound_demodulateBandcxx . . $ Spectrum_to_AnalyticSound_demodulateBand(6317b4211f4fdb47). (Spectrumcxx . . $ Spectrum# me, integercxx . . $ integer# startSample, integercxx . . $ integer# endSample, double approximateOverSampling, const VECcxx . . $ VEC# & window) {
43 try {
44 Melder_clipLeftcxx . . $ Melder_clipLeft(6245cd023a7d1552). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & startSample);
45 Melder_clipRightcxx . . $ Melder_clipRight(5b63ce711df1ade7). (& endSample, mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.);
46 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (startSample < endSample,
47 U"The start spectral sample should lie before the end spectral sample.");
48 const integercxx . . $ integer# extraSpectralSample = ( startSample > 1 ? 1 : 0 ); // first spectral value cannot be imaginary
49 const integercxx . . $ integer# numberOfSamplesFromSpectrum = endSample - startSample + 1;
50 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (window.size <= numberOfSamplesFromSpectrum,
51 U"The window size should not exceed the number of selected spectral values.");
52 const integercxx . . $ integer# numberOfValuesInBand = extraSpectralSample + ( approximateOverSampling <= 1.0 ? numberOfSamplesFromSpectrum :
53 Melder_iroundUpcxx . . $ Melder_iroundUp(a6e4a4c8b00c35a3). (approximateOverSampling * numberOfSamplesFromSpectrum) );
54 const integercxx . . $ integer# numberOfSamplesFFT = Melder_iroundUpToPowerOfTwocxx . . $ Melder_iroundUpToPowerOfTwo(8ce0d1b217db7fd1). (numberOfValuesInBand);
55 const integercxx . . $ integer# numberOfFrequencies = numberOfSamplesFFT + 1;
56 const double demod_fmax = mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx. * numberOfSamplesFFT;
57 autoSpectrumcxx . . $ autoSpectrum# demodSpectrum = Spectrum_createcxx . . $ Spectrum_create(a338b9c326abb5ed). (demod_fmax, numberOfFrequencies);
58 demodSpectrum ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..partcxx . . $ automatrix#part(5c23e73480cfacfb). (1, 2, 1 + extraSpectralSample, numberOfSamplesFromSpectrum + extraSpectralSample)
59 <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..partcxx . . $ automatrix#part(5c23e73480cfacfb). (1, 2, startSample, endSample);
60 if (window.sizecxx . . $ vector#size. > 0) {
61 const integercxx . . $ integer# startWindowing = ( startSample == 1 ? numberOfSamplesFromSpectrum - window.sizecxx . . $ vector#size. + 1 : 2 );
62 const integercxx . . $ integer# endWindowing = startWindowing + window.sizecxx . . $ vector#size. - 1;
63 demodSpectrum ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..partcxx . . $ automatrix#part(5c23e73480cfacfb). (1, 2, startWindowing, endWindowing) *=cxx . . $ `operator*=`(88779db6ac139909). windowcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).;
64 }
65 return Spectrum_to_AnalyticSoundcxx . . $ Spectrum_to_AnalyticSound(a6cdc77beb7a4796). (demodSpectrum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
66 } catch (MelderErrorcxx . . $ MelderError#) {
67 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": could not create AnalyticSound.");
68 }
69
70 }
71 /* End of file Spectrum_and_AnalyticSound.h */