Debian Codegraph @

fon/PitchTier_to_Sound.cpp

raw symbols SCIP
1 /* PitchTier_to_Sound.cpp
2 *
3 * Copyright (C) 1992-2011,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 "PitchTier_to_Sound.h"cxx . . $ `<file>/fon/PitchTier_to_Sound.h`/
20 #include "PitchTier_to_PointProcess.h"cxx . . $ `<file>/fon/PitchTier_to_PointProcess.h`/
21 #include "PointProcess_and_Sound.h"cxx . . $ `<file>/fon/PointProcess_and_Sound.h`/
22
23 autoSoundcxx . . $ autoSound# PitchTier_to_Sound_pulseTraincxx . . $ PitchTier_to_Sound_pulseTrain(980e4cb4ebc3e888). (PitchTiercxx . . $ PitchTier# me, double samplingFrequency,
24 double adaptFactor, double adaptTime, integercxx . . $ integer# interpolationDepth, bool hum)
25 {
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 const autoPointProcesscxx . . $ autoPointProcess# point = PitchTier_to_PointProcesscxx . . $ PitchTier_to_PointProcess(f0370c77e10beb54). (me);
30 autoSoundcxx . . $ autoSound# sound = PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (point.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), samplingFrequency, adaptFactor, adaptTime, interpolationDepth);
31 if (hum) {
32 Sound_filterWithFormantscxx . . $ Sound_filterWithFormants(2aef0a9fc25232a8). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 0.0, 6, formant, bandwidth);
33 }
34 return soundcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
35 } catch (MelderErrorcxx . . $ MelderError#) {
36 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Sound (pulse train).");
37 }
38 }
39
40 autoSoundcxx . . $ autoSound# PitchTier_to_Sound_phonationcxx . . $ PitchTier_to_Sound_phonation(6a8eb2d6c3ac684d). (PitchTiercxx . . $ PitchTier# me, double samplingFrequency,
41 double adaptFactor, double maximumPeriod, double openPhase, double collisionPhase, double power1, double power2, bool hum)
42 {
43 static double formant [1 + 6] = { 0.0, 600.0, 1400.0, 2400.0, 3400.0, 4500.0, 5500.0 };
44 static double bandwidth [1 + 6] = { 0.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0 };
45 try {
46 const autoPointProcesscxx . . $ autoPointProcess# point = PitchTier_to_PointProcesscxx . . $ PitchTier_to_PointProcess(f0370c77e10beb54). (me);
47 autoSoundcxx . . $ autoSound# sound = PointProcess_to_Sound_phonationcxx . . $ PointProcess_to_Sound_phonation(b0e41f72db7b1350). (point.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), samplingFrequency, adaptFactor,
48 maximumPeriod, openPhase, collisionPhase, power1, power2);
49 if (hum) {
50 Sound_filterWithFormantscxx . . $ Sound_filterWithFormants(2aef0a9fc25232a8). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 0.0, 6, formant, bandwidth);
51 }
52 return soundcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
53 } catch (MelderErrorcxx . . $ MelderError#) {
54 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Sound (phonation).");
55 }
56 }
57
58 void PitchTier_playPartcxx . . $ PitchTier_playPart(1fd30d1cc30de6fd). (PitchTiercxx . . $ PitchTier# me, double tmin, double tmax, bool hum, Sound_PlayCallbackcxx . . $ Sound_PlayCallback# callback, Thingcxx . . $ Thing# boss) {
59 try {
60 const autoSoundcxx . . $ autoSound# sound = PitchTier_to_Sound_pulseTraincxx . . $ PitchTier_to_Sound_pulseTrain(980e4cb4ebc3e888). (me, 44100.0, 0.7, 0.05, 30, hum);
61 Sound_playPartcxx . . $ Sound_playPart(4a8b47ed00757136). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, callback, boss);
62 } catch (MelderErrorcxx . . $ MelderError#) {
63 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not played.");
64 }
65 }
66
67 void PitchTier_playcxx . . $ PitchTier_play(78e657f01c361bdf). (PitchTiercxx . . $ PitchTier# me, Sound_PlayCallbackcxx . . $ Sound_PlayCallback# callback, Thingcxx . . $ Thing# boss) {
68 PitchTier_playPartcxx . . $ PitchTier_playPart(1fd30d1cc30de6fd). (me, mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., false, callback, boss);
69 }
70
71 void PitchTier_humcxx . . $ PitchTier_hum(78e657f01c361bdf). (PitchTiercxx . . $ PitchTier# me, Sound_PlayCallbackcxx . . $ Sound_PlayCallback# callback, Thingcxx . . $ Thing# boss) {
72 PitchTier_playPartcxx . . $ PitchTier_playPart(1fd30d1cc30de6fd). (me, mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., true, callback, boss);
73 }
74
75 autoSoundcxx . . $ autoSound# PitchTier_to_Sound_sinecxx . . $ PitchTier_to_Sound_sine(314b55bd78291e57). (PitchTiercxx . . $ PitchTier# me, double tmin, double tmax, double samplingFrequency) {
76 try {
77 Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax);
78 integercxx . . $ integer# numberOfSamples = 1 + Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! ((mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax. - mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.) * samplingFrequency); // >= 1
79 double samplingPeriod = 1.0 / samplingFrequency;
80 double tmid = (tmin + tmax) / 2.0;
81 double t1 = tmid - 0.5 * (numberOfSamples - 1) * samplingPeriod;
82 autoSoundcxx . . $ autoSound# thee = Sound_createcxx . . $ Sound_create(39ab106d6b9a0135). (1, tmin, tmax, numberOfSamples, samplingPeriod, t1);
83 double phase = 0.0;
84 for (integercxx . . $ integer# isamp = 2; isamp <= numberOfSamples; isamp ++) {
85 double tleft = t1 + (isamp - 1.5) * samplingPeriod;
86 double fleft = RealTier_getValueAtTimecxx . . $ RealTier_getValueAtTime(22f4103126fb5be4). (me, tleft);
87 phase += fleft * thycxx . . $ `melder/melder.h:45:9`! dxcxx . . $ structSampled#dx.;
88 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = 0.5 * sincxx . . $ sin(fee4f1d22bc8e617). (2.0 * NUMpicxx . . $ NUMpi. * phase);
89 }
90 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
91 } catch (MelderErrorcxx . . $ MelderError#) {
92 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Sound (sine).");
93 }
94 }
95
96 void PitchTier_playPart_sinecxx . . $ PitchTier_playPart_sine(f6068c401382404b). (PitchTiercxx . . $ PitchTier# me, double tmin, double tmax, Sound_PlayCallbackcxx . . $ Sound_PlayCallback# callback, Thingcxx . . $ Thing# boss) {
97 try {
98 Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax);
99 autoSoundcxx . . $ autoSound# sound = PitchTier_to_Sound_sinecxx . . $ PitchTier_to_Sound_sine(314b55bd78291e57). (me, tmin, tmax, 44100.0);
100 Sound_playPartcxx . . $ Sound_playPart(4a8b47ed00757136). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, callback, boss);
101 } catch (MelderErrorcxx . . $ MelderError#) {
102 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not played.");
103 }
104 }
105
106 /* End of file PitchTier_to_Sound.cpp */