| 1 | /* Sound_to_Harmonicity.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2011,2015,2016,2017,2019,2023 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 "Sound_to_Pitch.h"cxx . . $ `<file>/fon/Sound_to_Pitch.h`/ |
| 20 | #include "Sound_to_Harmonicity.h"cxx . . $ `<file>/fon/Sound_to_Harmonicity.h`/ |
| 21 | |
| 22 | autoHarmonicitycxx . . $ autoHarmonicity# Sound_to_Harmonicity_accxx . . $ Sound_to_Harmonicity_ac(e2f9e5fff2451113). (Soundcxx . . $ Sound# me, double dt, double pitchFloor, |
| 23 | double silenceThreshold, double periodsPerWindow) |
| 24 | { |
| 25 | try { |
| 26 | autoPitchcxx . . $ autoPitch# pitch = Sound_to_Pitch_anycxx . . $ Sound_to_Pitch_any(29e703e14008e8fa). (me, 1, periodsPerWindow, dt, pitchFloor, 0.5 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., 15, |
| 27 | silenceThreshold, 0.0, 0.0, 0.0, 0.0); |
| 28 | autoHarmonicitycxx . . $ autoHarmonicity# thee = Harmonicity_createcxx . . $ Harmonicity_create(ad7a3d614a026a90). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx., |
| 29 | pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). x1cxx . . $ structSampled#x1.); |
| 30 | for (integercxx . . $ integer# i = 1; i <= thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.; i ++) { |
| 31 | if (pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency. == 0.0) { |
| 32 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = -200.0; |
| 33 | } else { |
| 34 | const double r = pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 35 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = ( r <= 1e-15 ? -150.0 : r > 1.0 - 1e-15 ? 150.0 : 10.0 * log10cxx . . $ log10(fee4f1d22bc8e617). (r / (1.0 - r)) ); |
| 36 | } |
| 37 | } |
| 38 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 39 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 40 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": harmonicity analysis (ac) not performed."); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | autoHarmonicitycxx . . $ autoHarmonicity# Sound_to_Harmonicity_cccxx . . $ Sound_to_Harmonicity_cc(e2f9e5fff2451113). (Soundcxx . . $ Sound# me, double dt, double pitchFloor, |
| 45 | double silenceThreshold, double periodsPerWindow) |
| 46 | { |
| 47 | try { |
| 48 | autoPitchcxx . . $ autoPitch# pitch = Sound_to_Pitch_anycxx . . $ Sound_to_Pitch_any(29e703e14008e8fa). (me, 3, periodsPerWindow, dt, pitchFloor, 0.5 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., 15, |
| 49 | silenceThreshold, 0.0, 0.0, 0.0, 0.0); |
| 50 | autoHarmonicitycxx . . $ autoHarmonicity# thee = Harmonicity_createcxx . . $ Harmonicity_create(ad7a3d614a026a90). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx., |
| 51 | pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). x1cxx . . $ structSampled#x1.); |
| 52 | for (integercxx . . $ integer# i = 1; i <= thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.; i ++) { |
| 53 | if (pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. frequencycxx . . $ structPitch_Candidate#frequency. == 0.0) { |
| 54 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = -200.0; |
| 55 | } else { |
| 56 | const double r = pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). framescxx . . $ structPitch#frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. candidatescxx . . $ structPitch_Frame#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]. strengthcxx . . $ structPitch_Candidate#strength.; |
| 57 | thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = ( r <= 1e-15 ? -150.0 : r > 1.0 - 1e-15 ? 150.0 : 10.0 * log10cxx . . $ log10(fee4f1d22bc8e617). (r / (1.0 - r)) ); |
| 58 | } |
| 59 | } |
| 60 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 61 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 62 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": harmonicity analysis (cc) not performed."); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /* End of file Sound_to_Harmonicity.cpp */ |