Debian Codegraph @

fon/SpectrumTier.cpp

raw
1 /* SpectrumTier.cpp
2 *
3 * Copyright (C) 20072008,2010-2012,2015,2016,2018,2020,2022-2024 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 "Ltas_to_SpectrumTier.h"
20
21 Thing_implement (SpectrumTier, RealTier, 0);
22
23 void structSpectrumTier :: v1_info () {
24 our structDaata :: v1_info ();
25 MelderInfo_writeLine (U"Frequency domain:");
26 MelderInfo_writeLine (U" Lowest frequency: ", our xmin, U" Hz");
27 MelderInfo_writeLine (U" Highest frequency: ", our xmax, U" Hz");
28 MelderInfo_writeLine (U" Total bandwidth: ", our xmax - our xmin, U" Hz");
29 MelderInfo_writeLine (U"Number of points: ", our points.size);
30 MelderInfo_writeLine (U"Minimum power value: ", RealTier_getMinimumValue (this), U" dB/Hz");
31 MelderInfo_writeLine (U"Maximum power value: ", RealTier_getMaximumValue (this), U" dB/Hz");
32 }
33
34 autoSpectrumTier SpectrumTier_create (const double fmin, const double fmax) {
35 try {
36 autoSpectrumTier me = Thing_new (SpectrumTier);
37 RealTier_init (me.get(), fmin, fmax);
38 return me;
39 } catch (MelderError) {
40 Melder_throw (U"SpectrumTier not created.");
41 }
42 }
43
44 void SpectrumTier_draw (
45 const SpectrumTier me,
46 const Graphics g,
47 const double fmin, const double fmax,
48 const double pmin, const double pmax,
49 const bool garnish,
50 const conststring32 method
51 ) {
52 RealTier_draw (me, g, fmin, fmax, pmin, pmax, garnish, method, U"Power spectral density (dB)");
53 }
54
55 void SpectrumTier_list (
56 const SpectrumTier me,
57 const bool includeIndexes,
58 const bool includeFrequency,
59 const bool includePowerDensity
60 ) {
61 try {
62 autoTable table = SpectrumTier_downto_Table (me, includeIndexes, includeFrequency, includePowerDensity);
63 Table_list (table.get(), false);
64 } catch (MelderError) {
65 Melder_throw (me, U": not listed.");
66 }
67 }
68
69 autoTable SpectrumTier_downto_Table (
70 const SpectrumTier me,
71 const bool includeIndexes,
72 const bool includeFrequency,
73 const bool includePowerDensity
74 ) {
75 return RealTier_downto_Table (me,
76 includeIndexes ? U"index" : nullptr,
77 includeFrequency ? U"freq(Hz)" : nullptr,
78 includePowerDensity ? U"pow(dB/Hz)" : nullptr);
79 }
80
81 autoSpectrumTier Spectrum_to_SpectrumTier_peaks (const Spectrum me) {
82 try {
83 autoLtas ltas = Spectrum_to_Ltas_1to1 (me);
84 autoSpectrumTier thee = Ltas_to_SpectrumTier_peaks (ltas.get());
85 return thee;
86 } catch (MelderError) {
87 Melder_throw (me, U": peaks not converted to SpectrumTier.");
88 }
89 }
90
91 /* End of file SpectrumTier.cpp */