Debian Codegraph @

fon/Manipulation.cpp

raw symbols SCIP
1 /* Manipulation.cpp
2 *
3 * Copyright (C) 1992-2012,2014-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 "Manipulation.h"cxx . . $ `<file>/fon/Manipulation.h`/
20 #include "Sound_to_Pitch.h"cxx . . $ `<file>/fon/Sound_to_Pitch.h`/
21 #include "Pitch_to_PitchTier.h"cxx . . $ `<file>/fon/Pitch_to_PitchTier.h`/
22 #include "Pitch_AnyTier_to_PitchTier.h"cxx . . $ `<file>/fon/Pitch_AnyTier_to_PitchTier.h`/
23 #include "PitchTier_to_PointProcess.h"cxx . . $ `<file>/fon/PitchTier_to_PointProcess.h`/
24 #include "Pitch_to_PointProcess.h"cxx . . $ `<file>/fon/Pitch_to_PointProcess.h`/
25 #include "PointProcess_and_Sound.h"cxx . . $ `<file>/fon/PointProcess_and_Sound.h`/
26 #include "Sound_and_LPC.h"cxx . . $ `<file>/LPC/Sound_and_LPC.h`/
27
28 #define MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`! 0.02000000001 /* Maximum interval between two voice pulses (otherwise voiceless). */
29
30 #include "oo_DESTROY.h"cxx . . $ `<file>/sys/oo_DESTROY.h`/
31 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
32 #include "oo_COPY.h"cxx . . $ `<file>/sys/oo_COPY.h`/
33 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
34 #include "oo_EQUAL.h"cxx . . $ `<file>/sys/oo_EQUAL.h`/
35 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
36 #include "oo_CAN_WRITE_AS_ENCODING.h"cxx . . $ `<file>/sys/oo_CAN_WRITE_AS_ENCODING.h`/
37 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
38 #include "oo_WRITE_TEXT.h"cxx . . $ `<file>/sys/oo_WRITE_TEXT.h`/
39 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
40 #include "oo_READ_TEXT.h"cxx . . $ `<file>/sys/oo_READ_TEXT.h`/
41 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
42 #include "oo_WRITE_BINARY.h"cxx . . $ `<file>/sys/oo_WRITE_BINARY.h`/
43 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
44 #include "oo_READ_BINARY.h"cxx . . $ `<file>/sys/oo_READ_BINARY.h`/
45 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
46 #include "oo_DESCRIPTION.h"cxx . . $ `<file>/sys/oo_DESCRIPTION.h`/
47 #include "Manipulation_def.h"cxx . . $ `<file>/fon/Manipulation_def.h`/
48
49 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Manipulation, Function, 5);
50
51 void structManipulation :: v_shiftX (double xfrom, double xto) {
52 Manipulation_Parent :: v_shiftXcxx . . $ structFunction#v_shiftX(bc12c9ec15586e6a). (xfrom, xto);
53 if (ourcxx . . $ `melder/melder.h:42:9`! sound ) Function_shiftXTocxx . . $ Function_shiftXTo(ac72a71dd6ac1bfb). (ourcxx . . $ `melder/melder.h:42:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), xfrom, xto);
54 if (ourcxx . . $ `melder/melder.h:42:9`! pulses ) Function_shiftXTocxx . . $ Function_shiftXTo(ac72a71dd6ac1bfb). (ourcxx . . $ `melder/melder.h:42:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), xfrom, xto);
55 if (ourcxx . . $ `melder/melder.h:42:9`! pitch ) Function_shiftXTocxx . . $ Function_shiftXTo(ac72a71dd6ac1bfb). (ourcxx . . $ `melder/melder.h:42:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), xfrom, xto);
56 if (ourcxx . . $ `melder/melder.h:42:9`! duration) Function_shiftXTocxx . . $ Function_shiftXTo(ac72a71dd6ac1bfb). (ourcxx . . $ `melder/melder.h:42:9`! duration.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), xfrom, xto);
57 if (ourcxx . . $ `melder/melder.h:42:9`! lpc ) Function_shiftXTocxx . . $ Function_shiftXTo(ac72a71dd6ac1bfb). (ourcxx . . $ `melder/melder.h:42:9`! lpc.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), xfrom, xto);
58 }
59
60 void structManipulation :: v_scaleX (double xminfrom, double xmaxfrom, double xminto, double xmaxto) {
61 Manipulation_Parent :: v_scaleXcxx . . $ structFunction#v_scaleX(52a61fa14d44b641). (xminfrom, xmaxfrom, xminto, xmaxto);
62 if (ourcxx . . $ `melder/melder.h:42:9`! sound ) ourcxx . . $ `melder/melder.h:42:9`! sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_scaleXcxx . . $ structSampled#v_scaleX(52a61fa14d44b641). (xminfrom, xmaxfrom, xminto, xmaxto);
63 if (ourcxx . . $ `melder/melder.h:42:9`! pulses ) ourcxx . . $ `melder/melder.h:42:9`! pulses ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_scaleXcxx . . $ structPointProcess#v_scaleX(52a61fa14d44b641). (xminfrom, xmaxfrom, xminto, xmaxto);
64 if (ourcxx . . $ `melder/melder.h:42:9`! pitch ) ourcxx . . $ `melder/melder.h:42:9`! pitch ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_scaleXcxx . . $ structRealTier#v_scaleX(52a61fa14d44b641). (xminfrom, xmaxfrom, xminto, xmaxto);
65 if (ourcxx . . $ `melder/melder.h:42:9`! duration) ourcxx . . $ `melder/melder.h:42:9`! duration ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_scaleXcxx . . $ structRealTier#v_scaleX(52a61fa14d44b641). (xminfrom, xmaxfrom, xminto, xmaxto);
66 if (ourcxx . . $ `melder/melder.h:42:9`! lpc ) ourcxx . . $ `melder/melder.h:42:9`! lpc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_scaleXcxx . . $ structSampled#v_scaleX(52a61fa14d44b641). (xminfrom, xmaxfrom, xminto, xmaxto);
67 }
68
69 autoManipulation Manipulation_createcxx . . $ Manipulation_create(703441835d7bb364). (double tmin, double tmax) {
70 try {
71 autoManipulation me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Manipulation);
72 mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin. = tmin, mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax. = tmax;
73 mycxx . . $ `melder/melder.h:44:9`! duration =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). DurationTier_createcxx . . $ DurationTier_create(a86647bd247c7eaf). (tmin, tmax);
74 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
75 } catch (MelderErrorcxx . . $ MelderError#) {
76 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Manipulation object not created.");
77 }
78 }
79
80 void Manipulation_replaceOriginalSoundcxx . . $ Manipulation_replaceOriginalSound(42ff95da0dc92020). (Manipulation me, Soundcxx . . $ Sound# sound) {
81 try {
82 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_convertToMonocxx . . $ Sound_convertToMono(4e9053a6db58af83). (sound);
83 Vector_subtractMeancxx . . $ Vector_subtractMean(8ab8c8e01f03cabf). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
84 mycxx . . $ `melder/melder.h:44:9`! lpc =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). autoLPCcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).();
85 } catch (MelderErrorcxx . . $ MelderError#) {
86 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": original Sound not replaced with ", sound, U".");
87 }
88 }
89
90 void Manipulation_replacePulsescxx . . $ Manipulation_replacePulses(b728bebfed846588). (Manipulation me, PointProcesscxx . . $ PointProcess# pulses) {
91 try {
92 mycxx . . $ `melder/melder.h:44:9`! pulses =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (pulses);
93 } catch (MelderErrorcxx . . $ MelderError#) {
94 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pulses not replaced with ", pulses, U".");
95 }
96 }
97
98 void Manipulation_replacePitchTiercxx . . $ Manipulation_replacePitchTier(43acf25292e6488f). (Manipulation me, PitchTiercxx . . $ PitchTier# pitch) {
99 try {
100 mycxx . . $ `melder/melder.h:44:9`! pitch =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (pitch);
101 } catch (MelderErrorcxx . . $ MelderError#) {
102 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pitch tier not replaced with ", pitch, U".");
103 }
104 }
105
106 void Manipulation_replaceDurationTiercxx . . $ Manipulation_replaceDurationTier(b13f27a8dfde78e). (Manipulation me, DurationTiercxx . . $ DurationTier# duration) {
107 try {
108 mycxx . . $ `melder/melder.h:44:9`! duration =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (duration);
109 } catch (MelderErrorcxx . . $ MelderError#) {
110 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": duration tier not replaced with ", duration, U".");
111 }
112 }
113
114 autoManipulation Sound_to_Manipulationcxx . . $ Sound_to_Manipulation(30f887474585d5d9). (Soundcxx . . $ Sound# me, double timeStep, double pitchFloor, double pitchCeiling) {
115 try {
116 autoManipulation thee = Manipulation_createcxx . . $ Manipulation_create(703441835d7bb364). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.);
117 thycxx . . $ `melder/melder.h:45:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_convertToMonocxx . . $ Sound_convertToMono(4e9053a6db58af83). (me);
118 Vector_subtractMeancxx . . $ Vector_subtractMean(8ab8c8e01f03cabf). (thycxx . . $ `melder/melder.h:45:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
119 autoPitchcxx . . $ autoPitch# pitch = Sound_to_Pitchcxx . . $ Sound_to_Pitch(c773ddec40eb7e2b). (thycxx . . $ `melder/melder.h:45:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), timeStep, pitchFloor, pitchCeiling);
120 thycxx . . $ `melder/melder.h:45:9`! pulses =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_Pitch_to_PointProcess_cccxx . . $ Sound_Pitch_to_PointProcess_cc(f94f2d65883a605d). (thycxx . . $ `melder/melder.h:45:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
121 thycxx . . $ `melder/melder.h:45:9`! pitch =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Pitch_to_PitchTiercxx . . $ Pitch_to_PitchTier(511873a878854c23). (pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
122 /* (DurationTier has been done at creation time) */
123 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
124 } catch (MelderErrorcxx . . $ MelderError#) {
125 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Manipulation.");
126 }
127 }
128
129 autoManipulation Sound_Pitch_to_Manipulationcxx . . $ Sound_Pitch_to_Manipulation(2e1e2cc711a6a618). (Soundcxx . . $ Sound# sound, Pitchcxx . . $ Pitch# pitch) {
130 try {
131 autoManipulation me = Manipulation_createcxx . . $ Manipulation_create(703441835d7bb364). (sound -> xmincxx . . $ structFunction#xmin., sound -> xmaxcxx . . $ structFunction#xmax.);
132 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_convertToMonocxx . . $ Sound_convertToMono(4e9053a6db58af83). (sound);
133 Vector_subtractMeancxx . . $ Vector_subtractMean(8ab8c8e01f03cabf). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
134 mycxx . . $ `melder/melder.h:44:9`! pulses =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_Pitch_to_PointProcess_cccxx . . $ Sound_Pitch_to_PointProcess_cc(f94f2d65883a605d). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pitch);
135 mycxx . . $ `melder/melder.h:44:9`! pitch =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Pitch_to_PitchTiercxx . . $ Pitch_to_PitchTier(511873a878854c23). (pitch);
136 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
137 } catch (MelderErrorcxx . . $ MelderError#) {
138 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (sound, U" & ", pitch, U": not converted to Manipulation.");
139 }
140 }
141
142 autoManipulation Sound_PointProcess_to_Manipulationcxx . . $ Sound_PointProcess_to_Manipulation(5045a1b881ee9bd4). (Soundcxx . . $ Sound# sound, PointProcesscxx . . $ PointProcess# point) {
143 try {
144 autoManipulation me = Manipulation_createcxx . . $ Manipulation_create(703441835d7bb364). (sound -> xmincxx . . $ structFunction#xmin., sound -> xmaxcxx . . $ structFunction#xmax.);
145 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_convertToMonocxx . . $ Sound_convertToMono(4e9053a6db58af83). (sound);
146 Vector_subtractMeancxx . . $ Vector_subtractMean(8ab8c8e01f03cabf). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
147 mycxx . . $ `melder/melder.h:44:9`! pulses =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (point);
148 mycxx . . $ `melder/melder.h:44:9`! pitch =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). PointProcess_to_PitchTiercxx . . $ PointProcess_to_PitchTier(abb1168919acef87). (point, MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
149 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
150 } catch (MelderErrorcxx . . $ MelderError#) {
151 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (sound, U" & ", point, U": not converted to Manipulation.");
152 }
153 }
154
155 void Manipulation_playPartcxx . . $ Manipulation_playPart(43fb68d856ffd33a). (Manipulation me, double tmin, double tmax, int method) {
156 try {
157 if (method == Manipulation_OVERLAPADDcxx . . $ `fon/Manipulation.h:53:9`!) {
158 if (! mycxx . . $ `melder/melder.h:44:9`! sound)
159 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot synthesize overlap-add without a sound.");
160 autoSoundcxx . . $ autoSound# part = Data_copycxx . . $ Data_copy(97a542a26794c80e). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
161 integercxx . . $ integer# imin = Sampled_xToLowIndexcxx . . $ Sampled_xToLowIndex(405c2491bc3636e9). (part.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin), imax = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (part.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmax);
162 VECcxx . . $ VEC# amp = part ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1);
163 for (integercxx . . $ integer# i = 1; i <= imin; i ++)
164 amp [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = 0.0;
165 for (integercxx . . $ integer# i = imax; i <= part ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx.; i ++)
166 amp [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = 0.0;
167 autoSoundcxx . . $ autoSound# saved = mycxx . . $ `melder/melder.h:44:9`! sound.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
168 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). part.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
169 try {
170 autoSoundcxx . . $ autoSound# played = Manipulation_to_Soundcxx . . $ Manipulation_to_Sound(7deae98ef053e36b). (me, Manipulation_OVERLAPADDcxx . . $ `fon/Manipulation.h:53:9`!);
171 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). saved.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
172 amp =cxx . . $ vector#`operator=`(b5ebf627ac2fae1e). played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1);
173 for (imin = 1; imin <= played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx.; imin ++)
174 if (amp [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).imin] != 0.0)
175 break;
176 for (imax = played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx.; imax >= 1; imax --)
177 if (amp [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).imax] != 0.0)
178 break;
179 Sound_playPartcxx . . $ Sound_playPart(4a8b47ed00757136). (played.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). x1cxx . . $ structSampled#x1. + (imin - 1.5) * played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). x1cxx . . $ structSampled#x1. + (imax - 0.5) * played ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., nullptrcxx . . $ MelderCallback#MelderCallback(88514059881c9050)., nullptr);
180 } catch (MelderErrorcxx . . $ MelderError#) {
181 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). saved.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
182 throw;
183 }
184 } else {
185 autoSoundcxx . . $ autoSound# sound = Manipulation_to_Soundcxx . . $ Manipulation_to_Sound(7deae98ef053e36b). (me, method);
186 Sound_playPartcxx . . $ Sound_playPart(4a8b47ed00757136). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, nullptrcxx . . $ MelderCallback#MelderCallback(88514059881c9050)., nullptr);
187 }
188 } catch (MelderErrorcxx . . $ MelderError#) {
189 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not played.");
190 }
191 }
192
193 void Manipulation_playcxx . . $ Manipulation_play(15af01879a98877c). (Manipulation me, int method) {
194 try {
195 autoSoundcxx . . $ autoSound# sound = Manipulation_to_Soundcxx . . $ Manipulation_to_Sound(7deae98ef053e36b). (me, method);
196 Sound_playcxx . . $ Sound_play(8cd75def0156a342). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptrcxx . . $ MelderCallback#MelderCallback(88514059881c9050)., nullptr);
197 } catch (MelderErrorcxx . . $ MelderError#) {
198 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not played.");
199 }
200 }
201
202 static integercxx . . $ integer# PointProcess_getFirstVoicedPointcxx . . $ PointProcess_getFirstVoicedPoint(530dc1bca782083d). (PointProcesscxx . . $ PointProcess# me, double maxT) {
203 for (integercxx . . $ integer# i = 1; i < mycxx . . $ `melder/melder.h:44:9`! ntcxx . . $ structPointProcess#nt.; i ++)
204 if (mycxx . . $ `melder/melder.h:44:9`! tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + 1] - mycxx . . $ `melder/melder.h:44:9`! tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] <= maxT)
205 return i;
206 return 0;
207 }
208
209 static void copyRisecxx . . $ copyRise(54573cefd6e9b066). (Soundcxx . . $ Sound# me, double tmin, double tmax, Soundcxx . . $ Sound# thee, double tmaxTarget) {
210 integercxx . . $ integer# imin = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, tmin);
211 if (imin < 1)
212 imin = 1;
213 integercxx . . $ integer# imax = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, tmax) - 1; // not xToLowIndex: ensure separation of subsequent calls
214 if (imax > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.)
215 imax = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
216 if (imax < imin)
217 return;
218 integercxx . . $ integer# imaxTarget = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (thee, tmaxTarget) - 1;
219 integercxx . . $ integer# distance = imaxTarget - imax;
220 double dphase = NUMpicxx . . $ NUMpi. / (imax - imin + 1);
221 for (integercxx . . $ integer# i = imin; i <= imax; i ++) {
222 integercxx . . $ integer# iTarget = i + distance;
223 if (iTarget >= 1 && iTarget <= thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.)
224 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iTarget] += mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * 0.5 * (1.0 - coscxx . . $ cos(fee4f1d22bc8e617). (dphase * (i - imin + 0.5)));
225 }
226 }
227
228 static void copyFallcxx . . $ copyFall(54573cefd6e9b066). (Soundcxx . . $ Sound# me, double tmin, double tmax, Soundcxx . . $ Sound# thee, double tminTarget) {
229 integercxx . . $ integer# imin = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, tmin);
230 if (imin < 1)
231 imin = 1;
232 integercxx . . $ integer# imax = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, tmax) - 1; // not xToLowIndex: ensure separation of subsequent calls
233 if (imax > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.)
234 imax = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
235 if (imax < imin)
236 return;
237 integercxx . . $ integer# iminTarget = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (thee, tminTarget);
238 integercxx . . $ integer# distance = iminTarget - imin;
239 double dphase = NUMpicxx . . $ NUMpi. / (imax - imin + 1);
240 for (integercxx . . $ integer# i = imin; i <= imax; i ++) {
241 integercxx . . $ integer# iTarget = i + distance;
242 if (iTarget >= 1 && iTarget <= thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.)
243 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iTarget] += mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * 0.5 * (1.0 + coscxx . . $ cos(fee4f1d22bc8e617). (dphase * (i - imin + 0.5)));
244 }
245 }
246
247 static void copyBellcxx . . $ copyBell(cdef74ba279788e5). (Soundcxx . . $ Sound# me, double tmid, double leftWidth, double rightWidth, Soundcxx . . $ Sound# thee, double tmidTarget) {
248 copyRisecxx . . $ copyRise(54573cefd6e9b066). (me, tmid - leftWidth, tmid, thee, tmidTarget);
249 copyFallcxx . . $ copyFall(54573cefd6e9b066). (me, tmid, tmid + rightWidth, thee, tmidTarget);
250 }
251
252 static void copyBell2cxx . . $ copyBell2(d3f110f3a1990613). (Soundcxx . . $ Sound# me, PointProcesscxx . . $ PointProcess# source, integercxx . . $ integer# isource, double leftWidth, double rightWidth,
253 Soundcxx . . $ Sound# thee, double tmidTarget, double maxT)
254 {
255 /*
256 Replace 'leftWidth' and 'rightWidth' by the lengths of the intervals in the source (instead of target),
257 if these are shorter.
258 */
259 const double tmid = source -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isource];
260 if (isource > 1 && tmid - source -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isource - 1] <= maxT) {
261 const double sourceLeftWidth = tmid - source -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isource - 1];
262 if (sourceLeftWidth < leftWidth)
263 leftWidth = sourceLeftWidth;
264 }
265 if (isource < source -> ntcxx . . $ structPointProcess#nt. && source -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isource + 1] - tmid <= maxT) {
266 const double sourceRightWidth = source -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).isource + 1] - tmid;
267 if (sourceRightWidth < rightWidth)
268 rightWidth = sourceRightWidth;
269 }
270 copyBellcxx . . $ copyBell(cdef74ba279788e5). (me, tmid, leftWidth, rightWidth, thee, tmidTarget);
271 }
272
273 static void copyFlatcxx . . $ copyFlat(54573cefd6e9b066). (Soundcxx . . $ Sound# me, double tmin, double tmax, Soundcxx . . $ Sound# thee, double tminTarget) {
274 integercxx . . $ integer# imin = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, tmin);
275 if (imin < 1) imin = 1;
276 integercxx . . $ integer# imax = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, tmax) - 1; // not xToLowIndex: ensure separation of subsequent calls
277 if (imax > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) imax = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
278 if (imax < imin) return;
279 integercxx . . $ integer# iminTarget = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (thee, tminTarget);
280 if (iminTarget < 1) iminTarget = 1;
281 tracecxx . . $ `melder/melder_debug.h:60:10`! (tmin, U" ", tmax, U" ", tminTarget, U" ", imin, U" ", imax, U" ", iminTarget);
282 const integercxx . . $ integer# imaxTarget = iminTarget + (imax - imin);
283 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (imaxTarget <= thycxx . . $ `melder/melder.h:45:9`! nx);
284 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1).partcxx . . $ vector#part(ae267db9e2c04be7). (iminTarget, imaxTarget) <<=cxx . . $ `operator<<=`(adea042513329390). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1).partcxx . . $ vector#part(ae267db9e2c04be7). (imin, imax);
285 }
286
287 autoSoundcxx . . $ autoSound# Sound_Point_Point_to_Soundcxx . . $ Sound_Point_Point_to_Sound(e3d45e54be0b8c1f). (Soundcxx . . $ Sound# me, PointProcesscxx . . $ PointProcess# source, PointProcesscxx . . $ PointProcess# target, double maxT) {
288 try {
289 autoSoundcxx . . $ autoSound# thee = Sound_createcxx . . $ Sound_create(39ab106d6b9a0135). (1, mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1.);
290 if (source -> ntcxx . . $ structPointProcess#nt. < 2 || target -> ntcxx . . $ structPointProcess#nt. < 2) { // almost completely voiceless?
291 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..allcxx . . $ automatrix#all(2114117ba8ed4224).();
292 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
293 }
294 for (integercxx . . $ integer# i = 1; i <= target -> ntcxx . . $ structPointProcess#nt.; i ++) {
295 double tmid = target -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
296 double tleft = i > 1 ? target -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i - 1] : mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
297 double tright = i < target -> ntcxx . . $ structPointProcess#nt. ? target -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + 1] : mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
298 double leftWidth = tmid - tleft, rightWidth = tright - tmid;
299 int leftVoiced = i > 1 && leftWidth <= maxT;
300 int rightVoiced = i < target -> ntcxx . . $ structPointProcess#nt. && rightWidth <= maxT;
301 integercxx . . $ integer# isource = PointProcess_getNearestIndexcxx . . $ PointProcess_getNearestIndex(530dc1bca782083d). (source, tmid);
302 if (! leftVoiced) leftWidth = rightWidth; // symmetric bell
303 if (! rightVoiced) rightWidth = leftWidth; // symmetric bell
304 if (leftVoiced || rightVoiced) {
305 copyBell2cxx . . $ copyBell2(d3f110f3a1990613). (me, source, isource, leftWidth, rightWidth, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmid, maxT);
306 if (! leftVoiced) {
307 double startOfFlat = ( i == 1 ? tleft : (tleft + tmid) / 2.0 );
308 double endOfFlat = tmid - leftWidth;
309 copyFlatcxx . . $ copyFlat(54573cefd6e9b066). (me, startOfFlat, endOfFlat, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), startOfFlat);
310 copyFallcxx . . $ copyFall(54573cefd6e9b066). (me, endOfFlat, tmid, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), endOfFlat);
311 } else if (! rightVoiced) {
312 double startOfFlat = tmid + rightWidth;
313 double endOfFlat = ( i == target -> ntcxx . . $ structPointProcess#nt. ? tright : (tmid + tright) / 2.0 );
314 copyRisecxx . . $ copyRise(54573cefd6e9b066). (me, tmid, startOfFlat, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), startOfFlat);
315 copyFlatcxx . . $ copyFlat(54573cefd6e9b066). (me, startOfFlat, endOfFlat, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), startOfFlat);
316 }
317 } else {
318 double startOfFlat = ( i == 1 ? tleft : (tleft + tmid) / 2.0 );
319 double endOfFlat = ( i == target -> ntcxx . . $ structPointProcess#nt. ? tright : (tmid + tright) / 2.0 );
320 copyFlatcxx . . $ copyFlat(54573cefd6e9b066). (me, startOfFlat, endOfFlat, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), startOfFlat);
321 }
322 }
323 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
324 } catch (MelderErrorcxx . . $ MelderError#) {
325 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not manipulated.");
326 }
327 }
328
329 autoSoundcxx . . $ autoSound# Sound_Point_Pitch_Duration_to_Soundcxx . . $ Sound_Point_Pitch_Duration_to_Sound(f5fdd517ed726be5). (Soundcxx . . $ Sound# me, PointProcesscxx . . $ PointProcess# pulses,
330 PitchTiercxx . . $ PitchTier# pitch, DurationTiercxx . . $ DurationTier# duration, double maxT)
331 {
332 try {
333 integercxx . . $ integer# ipointleft, ipointright;
334 double deltat = 0.0, handledTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
335 double startOfSourceNoise, endOfSourceNoise, startOfTargetNoise, endOfTargetNoise;
336 double durationOfSourceNoise, durationOfTargetNoise;
337 double startOfSourceVoice, endOfSourceVoice, startOfTargetVoice, endOfTargetVoice;
338 double durationOfSourceVoice, durationOfTargetVoice;
339 double startingPeriod, finishingPeriod, ttarget, voicelessPeriod;
340 if (duration -> pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size. == 0)
341 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No duration points.");
342
343 /*
344 * Create a Sound long enough to hold the longest possible duration-manipulated sound.
345 */
346 autoSoundcxx . . $ autoSound# thee = Sound_createcxx . . $ Sound_create(39ab106d6b9a0135). (1, mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin. + 3 * (mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax. - mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.), 3 * mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1.);
347
348 /*
349 * Below, I'll abbreviate the voiced interval as "voice" and the voiceless interval as "noise".
350 */
351 if (pitch && pitch -> pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size.) for (ipointleft = 1; ipointleft <= pulses -> ntcxx . . $ structPointProcess#nt.; ipointleft = ipointright + 1) {
352 /*
353 * Find the beginning of the voice.
354 */
355 startOfSourceVoice = pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointleft]; // the first pulse of the voice
356 startingPeriod = 1.0 / RealTier_getValueAtTimecxx . . $ RealTier_getValueAtTime(22f4103126fb5be4). (pitch, startOfSourceVoice);
357 startOfSourceVoice -= 0.5 * startingPeriod; // the first pulse is in the middle of a period
358
359 /*
360 * Measure one noise.
361 */
362 startOfSourceNoise = handledTime;
363 endOfSourceNoise = startOfSourceVoice;
364 durationOfSourceNoise = endOfSourceNoise - startOfSourceNoise;
365 startOfTargetNoise = startOfSourceNoise + deltat;
366 endOfTargetNoise = startOfTargetNoise + RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, startOfSourceNoise, endOfSourceNoise);
367 durationOfTargetNoise = endOfTargetNoise - startOfTargetNoise;
368
369 /*
370 * Copy the noise.
371 */
372 voicelessPeriod = NUMrandomUniformcxx . . $ NUMrandomUniform(d8e7e0733fa41c87). (0.008, 0.012);
373 ttarget = startOfTargetNoise + 0.5 * voicelessPeriod;
374 while (ttarget < endOfTargetNoise) {
375 double tleft = startOfSourceNoise, tright = endOfSourceNoise;
376 for (int i = 1; i <= 15; i ++) {
377 const double tsourcemid = 0.5 * (tleft + tright);
378 const double ttargetmid = startOfTargetNoise + RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, startOfSourceNoise, tsourcemid);
379 if (ttargetmid < ttarget)
380 tleft = tsourcemid;
381 else
382 tright = tsourcemid;
383 }
384 const double tsource = 0.5 * (tleft + tright);
385 copyBellcxx . . $ copyBell(cdef74ba279788e5). (me, tsource, voicelessPeriod, voicelessPeriod, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ttarget);
386 voicelessPeriod = NUMrandomUniformcxx . . $ NUMrandomUniform(d8e7e0733fa41c87). (0.008, 0.012);
387 ttarget += voicelessPeriod;
388 }
389 deltat += durationOfTargetNoise - durationOfSourceNoise;
390
391 /*
392 * Find the end of the voice.
393 */
394 for (ipointright = ipointleft + 1; ipointright <= pulses -> ntcxx . . $ structPointProcess#nt.; ipointright ++)
395 if (pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointright] - pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointright - 1] > maxT)
396 break;
397 ipointright --;
398 endOfSourceVoice = pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointright]; // the last pulse of the voice
399 const double finishingPitch = RealTier_getValueAtTimecxx . . $ RealTier_getValueAtTime(22f4103126fb5be4). (pitch, endOfSourceVoice);
400 if (finishingPitch == 0.0) {
401 for (integercxx . . $ integer# ipoint = 1; ipoint <= pitch -> pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size.; ipoint ++)
402 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Pitch point ", ipoint, U" is ", pitch -> pointscxx . . $ structRealTier#points..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).ipoint], U" Hz");
403 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"ipointleft = ", ipointleft);
404 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unexpected zero pitch value.");
405 }
406 finishingPeriod = 1.0 / finishingPitch;
407 endOfSourceVoice += 0.5 * finishingPeriod; // the last pulse is in the middle of a period
408 /*
409 * Measure one voice.
410 */
411 durationOfSourceVoice = endOfSourceVoice - startOfSourceVoice;
412
413 /*
414 * This will be copied to an interval with a different location and duration.
415 */
416 startOfTargetVoice = startOfSourceVoice + deltat;
417 endOfTargetVoice = startOfTargetVoice +
418 RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, startOfSourceVoice, endOfSourceVoice);
419 durationOfTargetVoice = endOfTargetVoice - startOfTargetVoice;
420
421 /*
422 * Copy the voiced part.
423 */
424 ttarget = startOfTargetVoice + 0.5 * startingPeriod;
425 while (ttarget < endOfTargetVoice) {
426 double tleft = startOfSourceVoice, tright = endOfSourceVoice;
427 for (int i = 1; i <= 15; i ++) {
428 const double tsourcemid = 0.5 * (tleft + tright);
429 const double ttargetmid = startOfTargetVoice +
430 RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, startOfSourceVoice, tsourcemid);
431 if (ttargetmid < ttarget)
432 tleft = tsourcemid;
433 else
434 tright = tsourcemid;
435 }
436 const double tsource = 0.5 * (tleft + tright);
437 const double period = 1.0 / RealTier_getValueAtTimecxx . . $ RealTier_getValueAtTime(22f4103126fb5be4). (pitch, tsource);
438 const integercxx . . $ integer# isourcepulse = PointProcess_getNearestIndexcxx . . $ PointProcess_getNearestIndex(530dc1bca782083d). (pulses, tsource);
439 copyBell2cxx . . $ copyBell2(d3f110f3a1990613). (me, pulses, isourcepulse, period, period, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ttarget, maxT);
440 ttarget += period;
441 }
442 deltat += durationOfTargetVoice - durationOfSourceVoice;
443 handledTime = endOfSourceVoice;
444 }
445
446 /*
447 * Copy the remaining unvoiced part, if we are at the end.
448 */
449 startOfSourceNoise = handledTime;
450 endOfSourceNoise = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
451 durationOfSourceNoise = endOfSourceNoise - startOfSourceNoise;
452 startOfTargetNoise = startOfSourceNoise + deltat;
453 endOfTargetNoise = startOfTargetNoise + RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, startOfSourceNoise, endOfSourceNoise);
454 durationOfTargetNoise = endOfTargetNoise - startOfTargetNoise;
455 voicelessPeriod = NUMrandomUniformcxx . . $ NUMrandomUniform(d8e7e0733fa41c87). (0.008, 0.012);
456 ttarget = startOfTargetNoise + 0.5 * voicelessPeriod;
457 while (ttarget < endOfTargetNoise) {
458 double tleft = startOfSourceNoise, tright = endOfSourceNoise;
459 for (int i = 1; i <= 15; i ++) {
460 const double tsourcemid = 0.5 * (tleft + tright);
461 const double ttargetmid = startOfTargetNoise +
462 RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, startOfSourceNoise, tsourcemid);
463 if (ttargetmid < ttarget)
464 tleft = tsourcemid;
465 else
466 tright = tsourcemid;
467 }
468 const double tsource = 0.5 * (tleft + tright);
469 copyBellcxx . . $ copyBell(cdef74ba279788e5). (me, tsource, voicelessPeriod, voicelessPeriod, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ttarget);
470 voicelessPeriod = NUMrandomUniformcxx . . $ NUMrandomUniform(d8e7e0733fa41c87). (0.008, 0.012);
471 ttarget += voicelessPeriod;
472 }
473
474 /*
475 * Find the number of trailing zeroes and hack the sound's time domain.
476 */
477 thycxx . . $ `melder/melder.h:45:9`! xmaxcxx . . $ structFunction#xmax. = thycxx . . $ `melder/melder.h:45:9`! xmincxx . . $ structFunction#xmin. + RealTier_getAreacxx . . $ RealTier_getArea(275ea9f7b70e8f4c). (duration, mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.);
478 if (fabscxx . . $ fabs(fee4f1d22bc8e617). (thycxx . . $ `melder/melder.h:45:9`! xmaxcxx . . $ structFunction#xmax. - mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.) < 1e-12) // common situation
479 thycxx . . $ `melder/melder.h:45:9`! xmaxcxx . . $ structFunction#xmax. = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
480 thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx. = Sampled_xToLowIndexcxx . . $ Sampled_xToLowIndex(405c2491bc3636e9). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thycxx . . $ `melder/melder.h:45:9`! xmaxcxx . . $ structFunction#xmax.);
481 if (thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx. > 3 * mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.)
482 thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx. = 3 * mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
483 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..ncolcxx . . $ automatrix#ncol. = thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.; // maintain invariant
484
485 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
486 } catch (MelderErrorcxx . . $ MelderError#) {
487 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not manipulated.");
488 }
489 }
490
491 static autoSoundcxx . . $ autoSound# synthesize_overlapAdd_nodurcxx . . $ synthesize_overlapAdd_nodur(468fe72d94f7b60a). (Manipulation me) {
492 try {
493 if (! mycxx . . $ `melder/melder.h:44:9`! sound) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing original sound.");
494 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
495 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch manipulation.");
496 autoPointProcesscxx . . $ autoPointProcess# targetPulses = PitchTier_Point_to_PointProcesscxx . . $ PitchTier_Point_to_PointProcess(cf9e1213cef3e948). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
497 return Sound_Point_Point_to_Soundcxx . . $ Sound_Point_Point_to_Sound(e3d45e54be0b8c1f). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), targetPulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
498 } catch (MelderErrorcxx . . $ MelderError#) {
499 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": overlap-add synthesis (without duration) not performed.");
500 }
501 }
502
503 static autoSoundcxx . . $ autoSound# synthesize_overlapAddcxx . . $ synthesize_overlapAdd(468fe72d94f7b60a). (Manipulation me) {
504 if (! mycxx . . $ `melder/melder.h:44:9`! duration || mycxx . . $ `melder/melder.h:44:9`! duration ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). pointscxx . . $ structRealTier#points..sizecxx . . $ CollectionOf#size. == 0) return synthesize_overlapAdd_nodurcxx . . $ synthesize_overlapAdd_nodur(468fe72d94f7b60a). (me);
505 try {
506 if (! mycxx . . $ `melder/melder.h:44:9`! sound) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing original sound.");
507 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
508 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch manipulation.");
509 return Sound_Point_Pitch_Duration_to_Soundcxx . . $ Sound_Point_Pitch_Duration_to_Sound(f5fdd517ed726be5). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! duration.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
510 } catch (MelderErrorcxx . . $ MelderError#) {
511 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": overlap-add synthesis not performed.");
512 }
513 }
514
515 static autoSoundcxx . . $ autoSound# synthesize_pulsescxx . . $ synthesize_pulses(468fe72d94f7b60a). (Manipulation me) {
516 try {
517 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
518 return PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 44100.0, 0.7, 0.05, 30);
519 } catch (MelderErrorcxx . . $ MelderError#) {
520 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pulses synthesis not performed.");
521 }
522 }
523
524 static autoSoundcxx . . $ autoSound# synthesize_pulses_humcxx . . $ synthesize_pulses_hum(468fe72d94f7b60a). (Manipulation me) {
525 try {
526 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
527 return PointProcess_to_Sound_humcxx . . $ PointProcess_to_Sound_hum(e320a0d398950b85). (mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
528 } catch (MelderErrorcxx . . $ MelderError#) {
529 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pulses hum synthesis not performed.");
530 }
531 }
532
533 static autoSoundcxx . . $ autoSound# synthesize_pitchcxx . . $ synthesize_pitch(468fe72d94f7b60a). (Manipulation me) {
534 try {
535 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch tier.");
536 autoPointProcesscxx . . $ autoPointProcess# pulses = PitchTier_to_PointProcesscxx . . $ PitchTier_to_PointProcess(f0370c77e10beb54). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
537 return PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 44100.0, 0.7, 0.05, 30);
538 } catch (MelderErrorcxx . . $ MelderError#) {
539 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pitch manipulation not synthesized.");
540 }
541 }
542
543 static autoSoundcxx . . $ autoSound# synthesize_pitch_humcxx . . $ synthesize_pitch_hum(468fe72d94f7b60a). (Manipulation me) {
544 try {
545 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch tier.");
546 autoPointProcesscxx . . $ autoPointProcess# pulses = PitchTier_to_PointProcesscxx . . $ PitchTier_to_PointProcess(f0370c77e10beb54). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
547 return PointProcess_to_Sound_humcxx . . $ PointProcess_to_Sound_hum(e320a0d398950b85). (pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
548 } catch (MelderErrorcxx . . $ MelderError#) {
549 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pitch hum manipulation not synthesized.");
550 }
551 }
552
553 static autoSoundcxx . . $ autoSound# synthesize_pulses_pitchcxx . . $ synthesize_pulses_pitch(468fe72d94f7b60a). (Manipulation me) {
554 try {
555 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
556 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch tier.");
557 autoPointProcesscxx . . $ autoPointProcess# pulses = PitchTier_Point_to_PointProcesscxx . . $ PitchTier_Point_to_PointProcess(cf9e1213cef3e948). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
558 return PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 44100.0, 0.7, 0.05, 30);
559 } catch (MelderErrorcxx . . $ MelderError#) {
560 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pitch pulses manipulation not synthesized.");
561 }
562 }
563
564 static autoSoundcxx . . $ autoSound# synthesize_pulses_pitch_humcxx . . $ synthesize_pulses_pitch_hum(468fe72d94f7b60a). (Manipulation me) {
565 try {
566 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
567 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch tier.");
568 autoPointProcesscxx . . $ autoPointProcess# pulses = PitchTier_Point_to_PointProcesscxx . . $ PitchTier_Point_to_PointProcess(cf9e1213cef3e948). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
569 return PointProcess_to_Sound_humcxx . . $ PointProcess_to_Sound_hum(e320a0d398950b85). (pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
570 } catch (MelderErrorcxx . . $ MelderError#) {
571 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pitch pulses hum manipulation not synthesized.");
572 }
573 }
574
575 /*
576 void Sound_Formant_Intensity_filter (Sound me, FormantTier formantTier, IntensityTier intensity) {
577 Sound_FormantTier_filter_inplace (me, formantTier);
578 if (intensity)
579 Sound_IntensityTier_multiply_inplace (me, intensity);
580 VECdeemphasize_f_inplace (my z.row (1), my dx, 50.0);
581 Vector_scale (me, 0.99);
582 }
583
584 static Sound synthesize_pulses_formant (Manipulation me, int useIntensity) {
585 try {
586 if (! my pulses) Melder_throw (U"Missing pulses analysis.");
587 if (! my formant) Melder_throw (U"Missing formant information.");
588 autoSound thee = PointProcess_to_Sound (my pulses, 44100, 0.7, 0.05, 30);
589 Sound_Formant_Intensity_filter (get(), my formant, useIntensity ? my intensity : nullptr);
590 return thee;
591 } catch (MelderError) {
592 Melder_throw (me, U": formant and pulses manipulation not synthesized.");
593 }
594 }
595 */
596
597 static void Sound_PointProcess_fillVoicelesscxx . . $ Sound_PointProcess_fillVoiceless(763893b0251091e4). (Soundcxx . . $ Sound# me, PointProcesscxx . . $ PointProcess# pulses) {
598 integercxx . . $ integer# ipointleft, ipointright;
599 double beginVoiceless = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., endVoiceless;
600 for (ipointleft = 1; ipointleft <= pulses -> ntcxx . . $ structPointProcess#nt.; ipointleft = ipointright + 1) {
601 integercxx . . $ integer# i1, i2, i;
602 endVoiceless = pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointleft] - 0.005;
603 i1 = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, beginVoiceless);
604 if (i1 < 1) i1 = 1; if (i1 > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) i1 = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
605 i2 = Sampled_xToLowIndexcxx . . $ Sampled_xToLowIndex(405c2491bc3636e9). (me, endVoiceless);
606 if (i2 < 1) i2 = 1; if (i2 > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) i2 = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
607 if (i2 - i1 > 10) for (i = i1; i <= i2; i ++)
608 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = NUMrandomGausscxx . . $ NUMrandomGauss(d8e7e0733fa41c87). (0.0, 0.3);
609 for (ipointright = ipointleft + 1; ipointright <= pulses -> ntcxx . . $ structPointProcess#nt.; ipointright ++)
610 if (pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointright] - pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointright - 1] > MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!)
611 break;
612 ipointright --;
613 beginVoiceless = pulses -> tcxx . . $ structPointProcess#t. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ipointright] + 0.005;
614 }
615 endVoiceless = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
616 {
617 integercxx . . $ integer# i1, i2, i;
618 i1 = Sampled_xToHighIndexcxx . . $ Sampled_xToHighIndex(405c2491bc3636e9). (me, beginVoiceless);
619 if (i1 < 1) i1 = 1; if (i1 > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) i1 = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
620 i2 = Sampled_xToLowIndexcxx . . $ Sampled_xToLowIndex(405c2491bc3636e9). (me, endVoiceless);
621 if (i2 < 1) i2 = 1; if (i2 > mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.) i2 = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.;
622 if (i2 - i1 > 10) for (i = i1; i <= i2; i ++)
623 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = NUMrandomGausscxx . . $ NUMrandomGauss(d8e7e0733fa41c87). (0.0, 0.3);
624 }
625 }
626
627 static autoSoundcxx . . $ autoSound# synthesize_pulses_lpccxx . . $ synthesize_pulses_lpc(468fe72d94f7b60a). (Manipulation me) {
628 try {
629 if (! mycxx . . $ `melder/melder.h:44:9`! lpc) {
630 if (! mycxx . . $ `melder/melder.h:44:9`! sound) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing original sound.");
631 autoSoundcxx . . $ autoSound# sound10k = Sound_resamplecxx . . $ Sound_resample(872961da5f5e69e5). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 10000.0, 50);
632 mycxx . . $ `melder/melder.h:44:9`! lpc =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_to_LPC_burgcxx . . $ Sound_to_LPC_burg(ed41325f50f429a4). (sound10k.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 20, 0.025, 0.01, 50.0);
633 }
634 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
635 autoSoundcxx . . $ autoSound# train = PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1.0 / mycxx . . $ `melder/melder.h:44:9`! lpc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). samplingPeriodcxx . . $ structLPC#samplingPeriod., 0.7, 0.05, 30);
636 train ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx. = mycxx . . $ `melder/melder.h:44:9`! lpc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). samplingPeriodcxx . . $ structLPC#samplingPeriod.; // to be exact
637 Sound_PointProcess_fillVoicelesscxx . . $ Sound_PointProcess_fillVoiceless(763893b0251091e4). (train.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
638 autoSoundcxx . . $ autoSound# result = LPC_Sound_filtercxx . . $ LPC_Sound_filter(94682ef9887ad8d9). (mycxx . . $ `melder/melder.h:44:9`! lpc.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), train.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), true);
639 VECdeemphasize_f_inplacecxx . . $ VECdeemphasize_f_inplace(963991e5268b1933). (resultcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1), result ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., 50.0);
640 Vector_scalecxx . . $ Vector_scale(54f31cdb89d1acde). (result.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.99);
641 return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
642 } catch (MelderErrorcxx . . $ MelderError#) {
643 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": LPC synthesis not performed.");
644 }
645 }
646
647 static autoSoundcxx . . $ autoSound# synthesize_pitch_lpccxx . . $ synthesize_pitch_lpc(468fe72d94f7b60a). (Manipulation me) {
648 try {
649 if (! mycxx . . $ `melder/melder.h:44:9`! lpc) {
650 if (! mycxx . . $ `melder/melder.h:44:9`! sound) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing original sound.");
651 autoSoundcxx . . $ autoSound# sound10k = Sound_resamplecxx . . $ Sound_resample(872961da5f5e69e5). (mycxx . . $ `melder/melder.h:44:9`! sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 10000.0, 50);
652 mycxx . . $ `melder/melder.h:44:9`! lpc =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_to_LPC_burgcxx . . $ Sound_to_LPC_burg(ed41325f50f429a4). (sound10k.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 20, 0.025, 0.01, 50.0);
653 }
654 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch manipulation.");
655 if (! mycxx . . $ `melder/melder.h:44:9`! pulses) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pulses analysis.");
656 autoPointProcesscxx . . $ autoPointProcess# pulses = PitchTier_Point_to_PointProcesscxx . . $ PitchTier_Point_to_PointProcess(cf9e1213cef3e948). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), MAX_Tcxx . . $ `fon/Manipulation.cpp:28:9`!);
657 autoSoundcxx . . $ autoSound# train = PointProcess_to_Sound_pulseTraincxx . . $ PointProcess_to_Sound_pulseTrain(187ff6b615b4a390). (pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1 / mycxx . . $ `melder/melder.h:44:9`! lpc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). samplingPeriodcxx . . $ structLPC#samplingPeriod., 0.7, 0.05, 30);
658 train ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx. = mycxx . . $ `melder/melder.h:44:9`! lpc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). samplingPeriodcxx . . $ structLPC#samplingPeriod.; // to be exact
659 Sound_PointProcess_fillVoicelesscxx . . $ Sound_PointProcess_fillVoiceless(763893b0251091e4). (train.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! pulses.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
660 autoSoundcxx . . $ autoSound# result = LPC_Sound_filtercxx . . $ LPC_Sound_filter(94682ef9887ad8d9). (mycxx . . $ `melder/melder.h:44:9`! lpc.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), train.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), true);
661 VECdeemphasize_f_inplacecxx . . $ VECdeemphasize_f_inplace(963991e5268b1933). (resultcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (1), result ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dxcxx . . $ structSampled#dx., 50.0);
662 Vector_scalecxx . . $ Vector_scale(54f31cdb89d1acde). (result.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.99);
663 return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
664 } catch (MelderErrorcxx . . $ MelderError#) {
665 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": pitch LPC synthesis not performed.");
666 }
667 }
668
669 autoSoundcxx . . $ autoSound# Manipulation_to_Soundcxx . . $ Manipulation_to_Sound(7deae98ef053e36b). (Manipulation me, int method) {
670 switch (method) {
671 case Manipulation_OVERLAPADDcxx . . $ `fon/Manipulation.h:53:9`!: return synthesize_overlapAddcxx . . $ synthesize_overlapAdd(468fe72d94f7b60a). (me);
672 case Manipulation_PULSEScxx . . $ `fon/Manipulation.h:54:9`!: return synthesize_pulsescxx . . $ synthesize_pulses(468fe72d94f7b60a). (me);
673 case Manipulation_PULSES_HUMcxx . . $ `fon/Manipulation.h:55:9`!: return synthesize_pulses_humcxx . . $ synthesize_pulses_hum(468fe72d94f7b60a). (me);
674 case Manipulation_PITCHcxx . . $ `fon/Manipulation.h:56:9`!: return synthesize_pitchcxx . . $ synthesize_pitch(468fe72d94f7b60a). (me);
675 case Manipulation_PITCH_HUMcxx . . $ `fon/Manipulation.h:57:9`!: return synthesize_pitch_humcxx . . $ synthesize_pitch_hum(468fe72d94f7b60a). (me);
676 case Manipulation_PULSES_PITCHcxx . . $ `fon/Manipulation.h:58:9`!: return synthesize_pulses_pitchcxx . . $ synthesize_pulses_pitch(468fe72d94f7b60a). (me);
677 case Manipulation_PULSES_PITCH_HUMcxx . . $ `fon/Manipulation.h:59:9`!: return synthesize_pulses_pitch_humcxx . . $ synthesize_pulses_pitch_hum(468fe72d94f7b60a). (me);
678 case Manipulation_OVERLAPADD_NODURcxx . . $ `fon/Manipulation.h:60:9`!: return synthesize_overlapAdd_nodurcxx . . $ synthesize_overlapAdd_nodur(468fe72d94f7b60a). (me);
679 case Manipulation_PULSES_FORMANTcxx . . $ `fon/Manipulation.h:61:9`!: return autoSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).();
680 case Manipulation_PULSES_FORMANT_INTENSITYcxx . . $ `fon/Manipulation.h:62:9`!: return autoSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).();
681 case Manipulation_PULSES_LPCcxx . . $ `fon/Manipulation.h:63:9`!: return synthesize_pulses_lpccxx . . $ synthesize_pulses_lpc(468fe72d94f7b60a). (me);
682 case Manipulation_PULSES_LPC_INTENSITYcxx . . $ `fon/Manipulation.h:64:9`!: return autoSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).();
683 case Manipulation_PITCH_LPCcxx . . $ `fon/Manipulation.h:65:9`!: return synthesize_pitch_lpccxx . . $ synthesize_pitch_lpc(468fe72d94f7b60a). (me);
684 case Manipulation_PITCH_LPC_INTENSITYcxx . . $ `fon/Manipulation.h:66:9`!: return autoSoundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).();
685 default: return synthesize_overlapAddcxx . . $ synthesize_overlapAdd(468fe72d94f7b60a). (me);
686 }
687 }
688
689 autoManipulation Manipulation_AnyTier_to_Manipulationcxx . . $ Manipulation_AnyTier_to_Manipulation(8ed2a2dcc2ec7e2f). (Manipulation me, AnyTiercxx . . $ AnyTier# tier) {
690 try {
691 if (! mycxx . . $ `melder/melder.h:44:9`! pitch) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing pitch manipulation.");
692 autoManipulation result = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me);
693 result ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). pitch =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). PitchTier_AnyTier_to_PitchTiercxx . . $ PitchTier_AnyTier_to_PitchTier(fb6231c3ba676981). (mycxx . . $ `melder/melder.h:44:9`! pitch.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tier);
694 return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
695 } catch (MelderErrorcxx . . $ MelderError#) {
696 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted.");
697 }
698 }
699
700 void Manipulation_writeToTextFileWithoutSoundcxx . . $ Manipulation_writeToTextFileWithoutSound(b2c1697b76489b30). (Manipulation me, MelderFilecxx . . $ MelderFile# file) {
701 autoSoundcxx . . $ autoSound# saved = mycxx . . $ `melder/melder.h:44:9`! sound.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
702 try {
703 Data_writeToTextFilecxx . . $ Data_writeToTextFile(c3dcdea1be00195). (me, file);
704 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). saved.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
705 } catch (MelderErrorcxx . . $ MelderError#) {
706 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). saved.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
707 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not saved to text file.");
708 }
709 }
710
711 void Manipulation_writeToBinaryFileWithoutSoundcxx . . $ Manipulation_writeToBinaryFileWithoutSound(b2c1697b76489b30). (Manipulation me, MelderFilecxx . . $ MelderFile# file) {
712 autoSoundcxx . . $ autoSound# saved = mycxx . . $ `melder/melder.h:44:9`! sound.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
713 try {
714 Data_writeToBinaryFilecxx . . $ Data_writeToBinaryFile(c3dcdea1be00195). (me, file);
715 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). saved.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
716 } catch (MelderErrorcxx . . $ MelderError#) {
717 mycxx . . $ `melder/melder.h:44:9`! sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). saved.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
718 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not saved to binary file.");
719 }
720 }
721
722 /* End of file Manipulation.cpp */