| 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"cxx . . $ `<file>/fon/Ltas_to_SpectrumTier.h`/ |
| 20 | |
| 21 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (SpectrumTier, RealTier, 0); |
| 22 | |
| 23 | void structSpectrumTiercxx . . $ structSpectrumTier# :: v1_infocxx . . $ structSpectrumTier#v1_info(49f6e7a06ebc5aa8). () { |
| 24 | ourcxx . . $ `melder/melder.h:42:9`! structDaatacxx . . $ structDaata# :: v1_infocxx . . $ structThing#v1_info(49f6e7a06ebc5aa8). (); |
| 25 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Frequency domain:"); |
| 26 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Lowest frequency: ", ourcxx . . $ `melder/melder.h:42:9`! xmincxx . . $ structFunction#xmin., U" Hz"); |
| 27 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Highest frequency: ", ourcxx . . $ `melder/melder.h:42:9`! xmaxcxx . . $ structFunction#xmax., U" Hz"); |
| 28 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Total bandwidth: ", ourcxx . . $ `melder/melder.h:42:9`! xmaxcxx . . $ structFunction#xmax. - ourcxx . . $ `melder/melder.h:42:9`! xmincxx . . $ structFunction#xmin., U" Hz"); |
| 29 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of points: ", ourcxx . . $ `melder/melder.h:42:9`! pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size.); |
| 30 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Minimum power value: ", RealTier_getMinimumValuecxx . . $ RealTier_getMinimumValue(77f29e426b60f650). (this), U" dB/Hz"); |
| 31 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Maximum power value: ", RealTier_getMaximumValuecxx . . $ RealTier_getMaximumValue(77f29e426b60f650). (this), U" dB/Hz"); |
| 32 | } |
| 33 | |
| 34 | autoSpectrumTiercxx . . $ autoSpectrumTier# SpectrumTier_createcxx . . $ SpectrumTier_create(f37a4ac803fe2850). (const double fmin, const double fmax) { |
| 35 | try { |
| 36 | autoSpectrumTiercxx . . $ autoSpectrumTier# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (SpectrumTier); |
| 37 | RealTier_initcxx . . $ RealTier_init(d84c0874d617a544). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), fmin, fmax); |
| 38 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 39 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 40 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"SpectrumTier not created."); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | void SpectrumTier_drawcxx . . $ SpectrumTier_draw(f3044d768d4ea5f5). ( |
| 45 | const SpectrumTiercxx . . $ SpectrumTier# me, |
| 46 | const Graphicscxx . . $ Graphics# g, |
| 47 | const double fmin, const double fmax, |
| 48 | const double pmin, const double pmax, |
| 49 | const bool garnish, |
| 50 | const conststring32cxx . . $ conststring32# method |
| 51 | ) { |
| 52 | RealTier_drawcxx . . $ RealTier_draw(91d4c8857589b937). (me, g, fmin, fmax, pmin, pmax, garnish, method, U"Power spectral density (dB)"); |
| 53 | } |
| 54 | |
| 55 | void SpectrumTier_listcxx . . $ SpectrumTier_list(10c18286bcc555d5). ( |
| 56 | const SpectrumTiercxx . . $ SpectrumTier# me, |
| 57 | const bool includeIndexes, |
| 58 | const bool includeFrequency, |
| 59 | const bool includePowerDensity |
| 60 | ) { |
| 61 | try { |
| 62 | autoTablecxx . . $ autoTable# table = SpectrumTier_downto_Tablecxx . . $ SpectrumTier_downto_Table(37cd45cfbe4b728f). (me, includeIndexes, includeFrequency, includePowerDensity); |
| 63 | Table_listcxx . . $ Table_list(8e854cd23ee58a8f). (table.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false); |
| 64 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 65 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not listed."); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | autoTablecxx . . $ autoTable# SpectrumTier_downto_Tablecxx . . $ SpectrumTier_downto_Table(37cd45cfbe4b728f). ( |
| 70 | const SpectrumTiercxx . . $ SpectrumTier# me, |
| 71 | const bool includeIndexes, |
| 72 | const bool includeFrequency, |
| 73 | const bool includePowerDensity |
| 74 | ) { |
| 75 | return RealTier_downto_Tablecxx . . $ RealTier_downto_Table(5289193065a545ac). (me, |
| 76 | includeIndexes ? U"index" : nullptr, |
| 77 | includeFrequency ? U"freq(Hz)" : nullptr, |
| 78 | includePowerDensity ? U"pow(dB/Hz)" : nullptr); |
| 79 | } |
| 80 | |
| 81 | autoSpectrumTiercxx . . $ autoSpectrumTier# Spectrum_to_SpectrumTier_peakscxx . . $ Spectrum_to_SpectrumTier_peaks(b46e03f03e7d3bf6). (const Spectrumcxx . . $ Spectrum# me) { |
| 82 | try { |
| 83 | autoLtascxx . . $ autoLtas# ltas = Spectrum_to_Ltas_1to1cxx . . $ Spectrum_to_Ltas_1to1(f1266e571d43bf18). (me); |
| 84 | autoSpectrumTiercxx . . $ autoSpectrumTier# thee = Ltas_to_SpectrumTier_peakscxx . . $ Ltas_to_SpectrumTier_peaks(313af16e3f8d873b). (ltas.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 85 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 86 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 87 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": peaks not converted to SpectrumTier."); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /* End of file SpectrumTier.cpp */ |