Debian Codegraph @

fon/Pitch_to_Sound.cpp

raw symbols SCIP
1 /* Pitch_to_Sound.cpp
2 *
3 * Copyright (C) 1992-2011,2015,2016,2017,2022 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_to_PointProcess.h"cxx . . $ `<file>/fon/Pitch_to_PointProcess.h`/
20 #include "PointProcess_and_Sound.h"cxx . . $ `<file>/fon/PointProcess_and_Sound.h`/
21 #include "Pitch_to_Sound.h"cxx . . $ `<file>/fon/Pitch_to_Sound.h`/
22 #include "PitchTier_to_Sound.h"cxx . . $ `<file>/fon/PitchTier_to_Sound.h`/
23 #include "Pitch_to_PitchTier.h"cxx . . $ `<file>/fon/Pitch_to_PitchTier.h`/
24
25 autoSoundcxx . . $ autoSound# Pitch_to_Soundcxx . . $ Pitch_to_Sound(84b4a253447cdfec). (Pitchcxx . . $ Pitch# me, double tmin, double tmax, bool hum) {
26 static double formant [1 + 6] { 0.0, 600.0, 1400.0, 2400.0, 3400.0, 4500.0, 5500.0 };
27 static double bandwidth [1 + 6] { 0.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0 };
28 try {
29 autoPointProcesscxx . . $ autoPointProcess# point = Pitch_to_PointProcesscxx . . $ Pitch_to_PointProcess(9d4c69dc4ad51e9a). (me);
30 autoSoundcxx . . $ autoSound# sound = PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (point.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 44100.0, 0.7, 0.05, 30);
31 if (hum)
32 Sound_filterWithFormantscxx . . $ Sound_filterWithFormants(2aef0a9fc25232a8). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, 6, formant, bandwidth);
33 return soundcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
34 } catch (MelderErrorcxx . . $ MelderError#) {
35 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Sound.");
36 }
37 }
38
39 void Pitch_playcxx . . $ Pitch_play(d20e8862affd570d). (Pitchcxx . . $ Pitch# me, double tmin, double tmax) { // BUG: why no callback?
40 try {
41 Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax);
42 autoSoundcxx . . $ autoSound# sound = Pitch_to_Soundcxx . . $ Pitch_to_Sound(84b4a253447cdfec). (me, tmin, tmax, false);
43 Sound_playPartcxx . . $ Sound_playPart(4a8b47ed00757136). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, nullptrcxx . . $ MelderCallback#MelderCallback(88514059881c9050)., nullptr);
44 } catch (MelderErrorcxx . . $ MelderError#) {
45 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not played.");
46 }
47 }
48
49 void Pitch_humcxx . . $ Pitch_hum(6d01258f0847188f). (Pitchcxx . . $ Pitch# me, double tmin, double tmax, Sound_PlayCallbackcxx . . $ Sound_PlayCallback# playCallback, Thingcxx . . $ Thing# playBoss) {
50 try {
51 Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax);
52 autoSoundcxx . . $ autoSound# sound = Pitch_to_Soundcxx . . $ Pitch_to_Sound(84b4a253447cdfec). (me, tmin, tmax, true);
53 Sound_playPartcxx . . $ Sound_playPart(4a8b47ed00757136). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, playCallback, playBoss);
54 } catch (MelderErrorcxx . . $ MelderError#) {
55 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not played.");
56 }
57 }
58
59 autoSoundcxx . . $ autoSound# Pitch_to_Sound_sinecxx . . $ Pitch_to_Sound_sine(fe56eeba7eae450d). (Pitchcxx . . $ Pitch# me, double tmin, double tmax, double samplingFrequency, bool roundToNearestZeroCrossings) {
60 try {
61 autoPitchTiercxx . . $ autoPitchTier# tier = Pitch_to_PitchTiercxx . . $ Pitch_to_PitchTier(511873a878854c23). (me);
62 autoSoundcxx . . $ autoSound# sound = PitchTier_to_Sound_sinecxx . . $ PitchTier_to_Sound_sine(314b55bd78291e57). (tier.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, samplingFrequency);
63 integercxx . . $ integer# iframe = 1;
64 double unvoicedMin = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
65 double unvoicedMax = mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1. + (iframe - 1.5) * mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.;
66 for (;;) {
67 while (! Pitch_isVoiced_icxx . . $ Pitch_isVoiced_i(fd5b671aa7b53262). (me, iframe)) {
68 unvoicedMax = mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1. + (iframe - 0.5) * mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.;
69 if (++ iframe > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) break;
70 }
71 if (unvoicedMax > unvoicedMin) {
72 Sound_setZerocxx . . $ Sound_setZero(31bbd7258342aec7). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), unvoicedMin, unvoicedMax, roundToNearestZeroCrossings);
73 }
74 if (iframe > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) break;
75 while (Pitch_isVoiced_icxx . . $ Pitch_isVoiced_i(fd5b671aa7b53262). (me, iframe)) {
76 unvoicedMin = mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1. + (iframe - 0.5) * mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.;
77 if (++ iframe > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) break;
78 }
79 if (iframe > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) break;
80 }
81 unvoicedMax = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
82 if (unvoicedMax > unvoicedMin) {
83 Sound_setZerocxx . . $ Sound_setZero(31bbd7258342aec7). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), unvoicedMin, unvoicedMax, roundToNearestZeroCrossings);
84 }
85 return soundcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
86 } catch (MelderErrorcxx . . $ MelderError#) {
87 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Sound (sine).");
88 }
89 }
90
91 /* End of file Pitch_to_Sound.cpp */