| 1 | /* Pitch_extensions.cpp |
| 2 | * |
| 3 | * Copyright (C) 1993-2019 David Weenink, 2017,2019 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. 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 1997 |
| 21 | djmw 20030217 Latest modification |
| 22 | djmw 20061201 Interface change: removed minimumPitch parameter from PitchTier_modifyRange. |
| 23 | djmw 20061207 Removed PitchTier_modifyRange. |
| 24 | */ |
| 25 | |
| 26 | #include "Pitch_extensions.h"cxx . . $ `<file>/dwtools/Pitch_extensions.h`/ |
| 27 | |
| 28 | void Pitch_Frame_addPitchcxx . . $ Pitch_Frame_addPitch(203fb7178073f670). (Pitch_Framecxx . . $ Pitch_Frame# me, double f, double strength, integercxx . . $ integer# maxnCandidates) { |
| 29 | integercxx . . $ integer# pos = 0; |
| 30 | double weakest = 1e308; |
| 31 | if (mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates. < maxnCandidates) { |
| 32 | mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates.. resizecxx . . $ autovector#resize(d91e89fbd57cd1). (++ mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates.); |
| 33 | pos = mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates.; |
| 34 | } else { |
| 35 | // Find weakest candidate so far (skip the unvoiced one) |
| 36 | for (integercxx . . $ integer# i = 1; i <= maxnCandidates; i ++) |
| 37 | if (mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. strengthcxx . . $ structPitch_Candidate#strength. < weakest && mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. frequencycxx . . $ structPitch_Candidate#frequency. > 0.0) |
| 38 | weakest = mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos = i]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 39 | if (strength < weakest) |
| 40 | pos = 0; |
| 41 | } |
| 42 | if (pos > 0) { |
| 43 | mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos]. frequencycxx . . $ structPitch_Candidate#frequency. = f; |
| 44 | mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos]. strengthcxx . . $ structPitch_Candidate#strength. = strength; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void Pitch_Frame_getPitchcxx . . $ Pitch_Frame_getPitch(804b7ce859a03a77). (Pitch_Framecxx . . $ Pitch_Frame# me, double *out_f, double *out_strength) { |
| 49 | integercxx . . $ integer# pos = 1; |
| 50 | double strength = -1.0; |
| 51 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates.; i ++) |
| 52 | if (mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. strengthcxx . . $ structPitch_Candidate#strength. > strength && mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. frequencycxx . . $ structPitch_Candidate#frequency. > 0.0) |
| 53 | strength = mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos = i]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 54 | if (out_f) |
| 55 | *out_f = mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos]. frequencycxx . . $ structPitch_Candidate#frequency.; |
| 56 | if (out_strength) |
| 57 | *out_strength = strength; |
| 58 | } |
| 59 | |
| 60 | void Pitch_Frame_resizeStrengthscxx . . $ Pitch_Frame_resizeStrengths(cb539ae45523e044). (Pitch_Framecxx . . $ Pitch_Frame# me, double maxStrength, double unvoicedCriterium) { |
| 61 | integercxx . . $ integer# pos = 1; |
| 62 | double strongest = mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 63 | for (integercxx . . $ integer# i = 2; i <= mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates.; i ++) |
| 64 | if (mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. strengthcxx . . $ structPitch_Candidate#strength. > strongest) |
| 65 | strongest = mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos = i]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 66 | if (strongest != 0) |
| 67 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates.; i ++) |
| 68 | mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. strengthcxx . . $ structPitch_Candidate#strength. *= maxStrength / strongest; |
| 69 | |
| 70 | if (maxStrength < unvoicedCriterium) |
| 71 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nCandidatescxx . . $ structPitch_Frame#nCandidates.; i ++) |
| 72 | if (mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. frequencycxx . . $ structPitch_Candidate#frequency. == 0) { |
| 73 | pos = i; |
| 74 | break; |
| 75 | } |
| 76 | if (pos != 1) { |
| 77 | stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06). (mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency., mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos]. frequencycxx . . $ structPitch_Candidate#frequency.); |
| 78 | stdcxx . . $ std/::swapcxx . . $ std/swap(c75b8fd57d7c2e06). (mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. strengthcxx . . $ structPitch_Candidate#strength., mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).pos]. strengthcxx . . $ structPitch_Candidate#strength.); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | autoPitchcxx . . $ autoPitch# Pitch_scaleTimecxx . . $ Pitch_scaleTime(8c3978e901f12399). (Pitchcxx . . $ Pitch# me, double scaleFactor) { |
| 83 | try { |
| 84 | double dx = mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., x1 = mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1., xmax = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.; |
| 85 | if (scaleFactor != 1.0) { |
| 86 | dx = mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx. * scaleFactor; |
| 87 | x1 = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin. + 0.5 * dx; |
| 88 | xmax = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin. + mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx. * dx; |
| 89 | } |
| 90 | autoPitchcxx . . $ autoPitch# thee = Pitch_createcxx . . $ Pitch_create(15f7ea67007465c5). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., xmax, mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., dx, x1, mycxx . . $ `melder/melder.h:44:9`! ceilingcxx . . $ structPitch#ceiling., 2); |
| 91 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; i ++) { |
| 92 | double f = mycxx . . $ `melder/melder.h:44:9`! framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency.; |
| 93 | thycxx . . $ `melder/melder.h:45:9`! framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. strengthcxx . . $ structPitch_Candidate#strength. = mycxx . . $ `melder/melder.h:44:9`! framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 94 | f /= scaleFactor; |
| 95 | if (f < mycxx . . $ `melder/melder.h:44:9`! ceilingcxx . . $ structPitch#ceiling.) |
| 96 | thycxx . . $ `melder/melder.h:45:9`! framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency. = f; |
| 97 | } |
| 98 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 99 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 100 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not scaled."); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | static double HertzToSpecialcxx . . $ HertzToSpecial(379ec9dd013821f5). (double value, kPitch_unitcxx . . $ kPitch_unit# pitchUnit) { |
| 105 | return ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::HERTZcxx . . $ kPitch_unit#HERTZ. ? value : |
| 106 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::HERTZ_LOGARITHMICcxx . . $ kPitch_unit#HERTZ_LOGARITHMIC. ? ( value <= 0.0 ? undefinedcxx . . $ undefined. : log10cxx . . $ log10(fee4f1d22bc8e617). (value)) : |
| 107 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::MELcxx . . $ kPitch_unit#MEL. ? NUMhertzToMelcxx . . $ NUMhertzToMel(447c67c6676f75c3). (value) : |
| 108 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::LOG_HERTZcxx . . $ kPitch_unit#LOG_HERTZ. ? ( value <= 0.0 ? undefinedcxx . . $ undefined. : log10cxx . . $ log10(fee4f1d22bc8e617). (value) ) : |
| 109 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_1cxx . . $ kPitch_unit#SEMITONES_1. ? ( value <= 0.0 ? undefinedcxx . . $ undefined. : 12.0 * logcxx . . $ log(fee4f1d22bc8e617). (value / 1.0) / NUMln2cxx . . $ NUMln2. ) : |
| 110 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_100cxx . . $ kPitch_unit#SEMITONES_100. ? ( value <= 0.0 ? undefinedcxx . . $ undefined. : 12.0 * logcxx . . $ log(fee4f1d22bc8e617). (value / 100.0) / NUMln2cxx . . $ NUMln2. ) : |
| 111 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_200cxx . . $ kPitch_unit#SEMITONES_200. ? (value <= 0.0 ? undefinedcxx . . $ undefined. : 12.0 * logcxx . . $ log(fee4f1d22bc8e617). (value / 200.0) / NUMln2cxx . . $ NUMln2. ) : |
| 112 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_440cxx . . $ kPitch_unit#SEMITONES_440. ? ( value <= 0.0 ? undefinedcxx . . $ undefined. : 12.0 * logcxx . . $ log(fee4f1d22bc8e617). (value / 440.0) / NUMln2cxx . . $ NUMln2. ) : |
| 113 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::ERBcxx . . $ kPitch_unit#ERB. ? NUMhertzToErbcxx . . $ NUMhertzToErb(447c67c6676f75c3). (value) : undefinedcxx . . $ undefined. ) ) ) ) ) ) ) ) ); |
| 114 | } |
| 115 | |
| 116 | static double SpecialToHertzcxx . . $ SpecialToHertz(379ec9dd013821f5). (double value, kPitch_unitcxx . . $ kPitch_unit# pitchUnit) { |
| 117 | return ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::HERTZcxx . . $ kPitch_unit#HERTZ. ? value : |
| 118 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::HERTZ_LOGARITHMICcxx . . $ kPitch_unit#HERTZ_LOGARITHMIC. ? powcxx . . $ pow(b71928d39fde4295). (10.0, value) : |
| 119 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::MELcxx . . $ kPitch_unit#MEL. ? NUMmelToHertzcxx . . $ NUMmelToHertz(447c67c6676f75c3). (value) : |
| 120 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::LOG_HERTZcxx . . $ kPitch_unit#LOG_HERTZ. ? powcxx . . $ pow(b71928d39fde4295). (10.0, value) : |
| 121 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_1cxx . . $ kPitch_unit#SEMITONES_1. ? 1.0 * expcxx . . $ exp(fee4f1d22bc8e617). (value * (NUMln2cxx . . $ NUMln2. / 12.0)) : |
| 122 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_100cxx . . $ kPitch_unit#SEMITONES_100. ? 100.0 * expcxx . . $ exp(fee4f1d22bc8e617). (value * (NUMln2cxx . . $ NUMln2. / 12.0)) : |
| 123 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_200cxx . . $ kPitch_unit#SEMITONES_200. ? 200.0 * expcxx . . $ exp(fee4f1d22bc8e617). (value * (NUMln2cxx . . $ NUMln2. / 12.0)) : |
| 124 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::SEMITONES_440cxx . . $ kPitch_unit#SEMITONES_440. ? 440.0 * expcxx . . $ exp(fee4f1d22bc8e617). (value * (NUMln2cxx . . $ NUMln2. / 12.0)) : |
| 125 | ( pitchUnit == kPitch_unitcxx . . $ kPitch_unit#::ERBcxx . . $ kPitch_unit#ERB. ? NUMerbToHertzcxx . . $ NUMerbToHertz(447c67c6676f75c3). (value) : undefinedcxx . . $ undefined. ) ) ) ) ) ) ) ) ); |
| 126 | } |
| 127 | |
| 128 | autoPitchTiercxx . . $ autoPitchTier# PitchTier_normalizePitchRangecxx . . $ PitchTier_normalizePitchRange(387ebe1bdc40e308). (PitchTiercxx . . $ PitchTier# me, double pitchMin_ref_Hz, double pitchMax_ref_Hz, double pitchMin_Hz, double pitchMax_Hz, kPitch_unitcxx . . $ kPitch_unit# pitchUnit); |
| 129 | autoPitchTiercxx . . $ autoPitchTier# PitchTier_normalizePitchRangecxx . . $ PitchTier_normalizePitchRange(387ebe1bdc40e308). (PitchTiercxx . . $ PitchTier# me, double pitchMin_ref_Hz, double pitchMax_ref_Hz, double pitchMin_Hz, double pitchMax_Hz, kPitch_unitcxx . . $ kPitch_unit# pitchUnit) { |
| 130 | try { |
| 131 | const double fminr = HertzToSpecialcxx . . $ HertzToSpecial(379ec9dd013821f5). (pitchMin_ref_Hz, pitchUnit); |
| 132 | const double fmaxr = HertzToSpecialcxx . . $ HertzToSpecial(379ec9dd013821f5). (pitchMax_ref_Hz, pitchUnit); |
| 133 | const double fmin = HertzToSpecialcxx . . $ HertzToSpecial(379ec9dd013821f5). (pitchMin_Hz, pitchUnit); |
| 134 | const double fmax = HertzToSpecialcxx . . $ HertzToSpecial(379ec9dd013821f5). (pitchMax_Hz, pitchUnit); |
| 135 | |
| 136 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (! (isundef (fminr) || isundef (fmaxr) || isundef (fmin) || isundef (fmax)), |
| 137 | U"The conversion of a pitch value is not defined."); |
| 138 | const double ranger = fmaxr - fminr, range = fmax - fmin; |
| 139 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (ranger >= 0.01 && range >= 0.01, |
| 140 | U"Pitch range too small."); |
| 141 | |
| 142 | const double fmidr = fminr + ranger / 2.0; |
| 143 | const double factor = ranger / range; |
| 144 | autoPitchTiercxx . . $ autoPitchTier# thee = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me); |
| 145 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size.; i ++) { |
| 146 | const RealPointcxx . . $ RealPoint# point = thycxx . . $ `melder/melder.h:45:9`! pointscxx . . $ structRealTier#points..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 147 | double f = HertzToSpecialcxx . . $ HertzToSpecial(379ec9dd013821f5). (point -> valuecxx . . $ structRealPoint#value., pitchUnit); |
| 148 | f = factor * (f - fmidr); |
| 149 | f = SpecialToHertzcxx . . $ SpecialToHertz(379ec9dd013821f5). (f, pitchUnit); |
| 150 | point -> valuecxx . . $ structRealPoint#value. = f; |
| 151 | } |
| 152 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 153 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 154 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no PitchTier created."); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | autoPitchcxx . . $ autoPitch# PitchTier_to_Pitchcxx . . $ PitchTier_to_Pitch(20008ffd6ba3dd0). (PitchTiercxx . . $ PitchTier# me, double dt, double pitchFloor, double pitchCeiling) { |
| 159 | try { |
| 160 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! points.size > 0, |
| 161 | U"The PitchTier is empty."); |
| 162 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (dt > 0.0, |
| 163 | U"The time step should be a positive number."); |
| 164 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (pitchFloor < pitchCeiling, |
| 165 | U"The pitch floor should be lower than the pitch ceiling."); |
| 166 | |
| 167 | const double tmin = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., tmax = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., t1 = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin. + dt / 2.0; |
| 168 | integercxx . . $ integer# nt = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! ((tmax - tmin - t1) / dt); |
| 169 | if (t1 + nt * dt < tmax) |
| 170 | nt ++; |
| 171 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (nt > 0, |
| 172 | U"Duration is too short."); |
| 173 | |
| 174 | autoPitchcxx . . $ autoPitch# thee = Pitch_createcxx . . $ Pitch_create(15f7ea67007465c5). (tmin, tmax, nt, dt, t1, pitchCeiling, 1); |
| 175 | for (integercxx . . $ integer# i = 1; i <= nt; i ++) { |
| 176 | const Pitch_Framecxx . . $ Pitch_Frame# frame = & thycxx . . $ `melder/melder.h:45:9`! framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 177 | const Pitch_Candidatecxx . . $ Pitch_Candidate# candidate = & frame -> candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]; |
| 178 | const double t = t1 + (i - 1) * dt; |
| 179 | double f = RealTier_getValueAtTimecxx . . $ RealTier_getValueAtTime(22f4103126fb5be4). (me, t); |
| 180 | if (f < pitchFloor || f > pitchCeiling) |
| 181 | f = 0.0; |
| 182 | candidate -> frequencycxx . . $ structPitch_Candidate#frequency. = f; |
| 183 | } |
| 184 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 185 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 186 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Pitch created."); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /* End of file Pitch_extensions.cpp */ |