Debian Codegraph @

fon/Pitch_AnyTier_to_PitchTier.cpp

raw symbols SCIP
1 /* Pitch_AnyTier_to_PitchTier.cpp
2 *
3 * Copyright (C) 1992-2011,2015,2016,2017 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 "Pitch_AnyTier_to_PitchTier.h"cxx . . $ `<file>/fon/Pitch_AnyTier_to_PitchTier.h`/
20 #include "Pitch_to_PitchTier.h"cxx . . $ `<file>/fon/Pitch_to_PitchTier.h`/
21
22 autoPitchTiercxx . . $ autoPitchTier# PitchTier_AnyTier_to_PitchTiercxx . . $ PitchTier_AnyTier_to_PitchTier(fb6231c3ba676981). (PitchTiercxx . . $ PitchTier# pitch, AnyTiercxx . . $ AnyTier# tier) {
23 try {
24 if (pitch -> pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size. == 0) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No pitch points.");
25
26 /*
27 * Result's domain is a union of both domains.
28 */
29 autoPitchTiercxx . . $ autoPitchTier# thee = PitchTier_createcxx . . $ PitchTier_create(6e304f2c8cc67c9c). (
30 pitch -> xmincxx . . $ structFunction#xmin. < tier -> xmincxx . . $ structFunction#xmin. ? pitch -> xmincxx . . $ structFunction#xmin. : tier -> xmincxx . . $ structFunction#xmin.,
31 pitch -> xmaxcxx . . $ structFunction#xmax. > tier -> xmaxcxx . . $ structFunction#xmax. ? pitch -> xmaxcxx . . $ structFunction#xmax. : tier -> xmaxcxx . . $ structFunction#xmax.);
32
33 /*
34 * Copy pitch's frequencies at tier's points to the resulting PitchTier.
35 */
36 for (integercxx . . $ integer# ipoint = 1; ipoint <= tier -> pointscxx . . $ structAnyTier#points..sizecxx . . $ CollectionOf#size.; ipoint ++) {
37 AnyPointcxx . . $ AnyPoint# point = tier -> pointscxx . . $ structAnyTier#points..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).ipoint];
38 double time = point -> numbercxx . . $ structSimpleDouble#number.;
39 double frequency = RealTier_getValueAtTimecxx . . $ RealTier_getValueAtTime(22f4103126fb5be4). (pitch, time);
40 RealTier_addPointcxx . . $ RealTier_addPoint(d84c0874d617a544). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), time, frequency);
41 }
42
43 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
44 } catch (MelderErrorcxx . . $ MelderError#) {
45 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (pitch, U" & ", tier, U": not converted to PitchTier.");
46 }
47 }
48
49 autoPitchTiercxx . . $ autoPitchTier# Pitch_AnyTier_to_PitchTiercxx . . $ Pitch_AnyTier_to_PitchTier(cce1086f8d721c67). (Pitchcxx . . $ Pitch# pitch, AnyTiercxx . . $ AnyTier# tier, int checkMethod) {
50 try {
51 if (checkMethod == 2) {
52 autoPitchTiercxx . . $ autoPitchTier# temp = Pitch_to_PitchTiercxx . . $ Pitch_to_PitchTier(511873a878854c23). (pitch);
53 return PitchTier_AnyTier_to_PitchTiercxx . . $ PitchTier_AnyTier_to_PitchTier(fb6231c3ba676981). (temp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tier);
54 }
55
56 /*
57 * Result's domain is a union of both domains.
58 */
59 autoPitchTiercxx . . $ autoPitchTier# thee = PitchTier_createcxx . . $ PitchTier_create(6e304f2c8cc67c9c). (
60 pitch -> xmincxx . . $ structFunction#xmin. < tier -> xmincxx . . $ structFunction#xmin. ? pitch -> xmincxx . . $ structFunction#xmin. : tier -> xmincxx . . $ structFunction#xmin.,
61 pitch -> xmaxcxx . . $ structFunction#xmax. > tier -> xmaxcxx . . $ structFunction#xmax. ? pitch -> xmaxcxx . . $ structFunction#xmax. : tier -> xmaxcxx . . $ structFunction#xmax.);
62
63 /*
64 * Copy pitch's frequencies at tier's points to the resulting PitchTier.
65 */
66 for (integercxx . . $ integer# ipoint = 1; ipoint <= tier -> pointscxx . . $ structAnyTier#points..sizecxx . . $ CollectionOf#size.; ipoint ++) {
67 AnyPointcxx . . $ AnyPoint# point = tier -> pointscxx . . $ structAnyTier#points..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).ipoint];
68 double time = point -> numbercxx . . $ structSimpleDouble#number.;
69 double frequency = Pitch_getValueAtTimecxx . . $ Pitch_getValueAtTime(b0f5a36024d7459c). (pitch, time, kPitch_unitcxx . . $ kPitch_unit#::HERTZcxx . . $ kPitch_unit#HERTZ., Pitch_LINEARcxx . . $ `fon/Pitch.h:95:9`!);
70 if (isundefcxx . . $ isundef(f8197d536af80c96). (frequency) && checkMethod != 0)
71 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No periodicity at time ", time, U" seconds.");
72 RealTier_addPointcxx . . $ RealTier_addPoint(d84c0874d617a544). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), time, frequency);
73 }
74
75 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
76 } catch (MelderErrorcxx . . $ MelderError#) {
77 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (pitch, U" & ", tier, U": not converted to PitchTier.");
78 }
79 }
80
81 /* End of file Pitch_AnyTier_to_PitchTier.cpp */