Debian Codegraph @

fon/Sound_files.cpp

raw symbols SCIP
1 /* Sound_files.cpp
2 *
3 * Copyright (C) 1992-2018,2020,2022-2024 Paul Boersma & David Weenink
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 /*
20 * pb 2002/07/16 GPL
21 * pb 2003/09/12 MelderFile_checkSoundFile
22 * pb 2004/10/17 test for NULL file pointer when closing in Sound_read(2)FromSoundFile
23 * pb 2005/06/17 Mac headers
24 * pb 2006/01/05 movies for Mac
25 * pb 2006/05/29 QuickTime inclusion made optional
26 * pb 2006/10/28 erased MacOS 9 stuff
27 * pb 2006/12/30 stereo
28 * pb 2006/01/01 more stereo
29 * pb 2007/01/28 removed a warning
30 * pb 2007/01/28 made readFromMovieFile compatible with stereo
31 * pb 2007/03/17 resistant against conflicting declarations of Collection
32 * pb 2007/05/08 removed warning about stereo sounds
33 * pb 2007/10/05 removed FSSpec
34 * pb 2007/10/05 made Sound_readFromMacSoundFile compatible with sampling frequencies between 32768 and 65535 Hz
35 * pb 2008/01/19 double
36 * pb 2009/09/21 made stereo movies readable
37 * pb 2010/12/27 support for multiple channels (i.e. more than two)
38 * pb 2011/06/07 C++
39 * pb 2012/04/29 removed Sound Manager stuff
40 * pb 2012/04/29 removed QuickTime
41 */
42
43 /*
44 static void Sound_ulawDecode (Sound me) {
45 double mu = 100, lnu1 = log (1 + mu);
46 for (integer i = 1; i <= my nx; i ++) {
47 double zabs = (exp (fabs (my z [1] [i]) * lnu1) - 1.0) / mu;
48 my z [1] [i] = my z [1] [i] < 0 ? -zabs : zabs;
49 }
50 }
51 static void Sound_alawDecode (Sound me) {
52 double a = 87.6, lna1 = 1.0 + log (a);
53 for (integer i = 1; i <= my nx; i ++) {
54 double zabs = fabs (my z [1] [i]);
55 if (zabs <= 1.0 / lna1) {
56 my z [1] [i] *= lna1 / a;
57 } else {
58 double t = exp (lna1 * zabs - 1.0) / a;
59 my z [1] [i] = my z [1] [i] > 0 ? t : - t;
60 }
61 }
62 }
63 */
64
65 #include <time.h>
66 #include "Sound.h"cxx . . $ `<file>/fon/Sound.h`/
67
68 autoSoundcxx . . $ autoSound# Sound_readFromSoundFilecxx . . $ Sound_readFromSoundFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file) {
69 try {
70 autoMelderFilecxx . . $ autoMelderFile# mfile = MelderFile_opencxx . . $ autoMelderFile#autoMelderFile(1145552d769d7b5d). (file);
71 int encoding;
72 double sampleRate;
73 integercxx . . $ integer# startOfData, numberOfSamples, numberOfChannels;
74 int fileType = MelderFile_checkSoundFilecxx . . $ MelderFile_checkSoundFile(61aa38baf9d22bef). (file, & numberOfChannels, & encoding, & sampleRate, & startOfData, & numberOfSamples);
75 if (fileType == 0)
76 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Not an audio file.");
77 try {
78 MelderFile_seekcxx . . $ MelderFile_seek(83b357a1fc21c557). (file, startOfData, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!); // start from beginning of Data Chunk
79 } catch (MelderErrorcxx . . $ MelderError#) {
80 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No data in audio file.");
81 }
82 if (numberOfSamples < 1)
83 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Audio file contains 0 samples.");
84 autoSoundcxx . . $ autoSound# me = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (numberOfChannels, numberOfSamples / sampleRate, sampleRate);
85 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! z.ncol == numberOfSamples);
86 if (encoding == Melder_SHORTENcxx . . $ `melder/melder_audiofiles.h:44:9`!)
87 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot unshorten. Write to [email protected] for more information.");
88 Melder_readAudioToFloatcxx . . $ Melder_readAudioToFloat(cd19eb660e26204e). (file, encoding, mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..getcxx . . $ automatrix#get(b2b81450b5bdda66).());
89 mfile.closecxx . . $ autoMelderFile#close(49f6e7a06ebc5aa8). ();
90 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
91 } catch (MelderErrorcxx . . $ MelderError#) {
92 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sound not read from sound file ", file, U".");
93 }
94 }
95
96 autoSoundcxx . . $ autoSound# Sound_readFromSesamFilecxx . . $ Sound_readFromSesamFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file) {
97 try {
98 autofilecxx . . $ autofile# f = Melder_fopencxx . . $ autofile#autofile(8d4262d45fc644ab). (file, "rb");
99 int32cxx . . $ int32# header [1 + 128];
100 for (integercxx . . $ integer# i = 1; i <= 128; i ++)
101 header [i] = bingeti32LEcxx . . $ bingeti32LE(89bc1efcdac0ca22). (f);
102 /*
103 * Try SESAM header.
104 */
105 double samplingFrequency = header [126]; // converting up (from 32 to 54 bits)
106 int32cxx . . $ int32# numberOfSamples = header [127];
107 if (samplingFrequency == 0.0 || numberOfSamples == 0) {
108 /*
109 Try LVS header.
110 */
111 samplingFrequency = header [62];
112 numberOfSamples = (header [6] << 8) - header [68];
113 }
114 if (numberOfSamples < 1 || numberOfSamples > 1000000000 || samplingFrequency < 10.0 || samplingFrequency > 100000000.0)
115 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Not a correct SESAM or LVS file.");
116 autoSoundcxx . . $ autoSound# me = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (1, numberOfSamples / samplingFrequency, samplingFrequency);
117 for (int32cxx . . $ int32# i = 1; i <= numberOfSamples; i ++) {
118 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (double) bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f) * (1.0 / 2048); // 12 bits
119 }
120 f.closecxx . . $ autofile#close(1145552d769d7b5d). (file);
121 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
122 } catch (MelderErrorcxx . . $ MelderError#) {
123 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sound not read from Sesam file ", file, U".");
124 }
125 }
126
127 autoSoundcxx . . $ autoSound# Sound_readFromBellLabsFilecxx . . $ Sound_readFromBellLabsFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file) {
128 try {
129 autofilecxx . . $ autofile# f = Melder_fopencxx . . $ autofile#autofile(8d4262d45fc644ab). (file, "rb");
130
131 /*
132 Check identity of file: first line is "SIG", second line contains a number.
133 */
134 char tag [200];
135 if (fread (tag, 1, 16, f) < 16 || ! strnequcxx . . $ `melder/melder_string32.h:70:9`! (tag, "SIG\n", 4))
136 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Not a Bell-Labs sound file.");
137 char *endOfTag = strchr (tag + 4, '\n');
138 if (! endOfTag)
139 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Second line missing or too long.");
140 integercxx . . $ integer# tagLength = (endOfTag - tag) + 1; // probably 12
141 int64cxx . . $ int64# headerLength = atolcxx . . $ atol(fd364382987d21ca). (tag + 4);
142 if (headerLength <= 0)
143 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Wrong header-length info.");
144
145 /*
146 Read data from header.
147 Use defaults if necessary.
148 */
149 autostring8cxx . . $ autostring8# linescxx . . $ _autostring#_autostring(f153f132b2bc41c2). (headerLength);
150 if ((int64cxx . . $ int64#) fread (lines.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), 1, (size_t) headerLength, f) < headerLength)
151 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Header too short.");
152 integercxx . . $ integer# numberOfSamples = 0;
153 char *psamples = & lines [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).-1];
154 while (!! (psamples = strstr (psamples + 1, "samples "))) // take last occurrence
155 numberOfSamples = atolcxx . . $ atol(fd364382987d21ca). (psamples + 8);
156 if (numberOfSamples < 1) {
157 /* Use file length. */
158 fseek (f, 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:112:9`!); /* Position file pointer at end of file. */
159 numberOfSamples = (ftell (f) - tagLength - headerLength) / 2;
160 }
161 if (numberOfSamples < 1)
162 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No samples found.");
163 double samplingFrequency = 0.0;
164 char *pfrequency = & lines [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).-1];
165 while (!! (pfrequency = strstr (pfrequency + 1, "frequency "))) // take last occurrence
166 samplingFrequency = atofcxx . . $ atof(9b0361fcbc284e4f). (pfrequency + 10);
167 if (samplingFrequency <= 0.0)
168 samplingFrequency = 16000.0;
169
170 /*
171 Create sound.
172 */
173 autoSoundcxx . . $ autoSound# me = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (1, numberOfSamples / samplingFrequency, samplingFrequency);
174
175 /*
176 Read samples.
177 */
178 fseek (f, tagLength + headerLength, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!);
179 for (integercxx . . $ integer# i = 1; i <= numberOfSamples; i ++)
180 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (double) bingeti16cxx . . $ bingeti16(2dcfca5714bad490). (f) * (1.0 / 32768); // 16-bits big-endian
181
182 f.closecxx . . $ autofile#close(1145552d769d7b5d). (file);
183 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
184 } catch (MelderErrorcxx . . $ MelderError#) {
185 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sound not read from Bell Labs sound file ", file, U".");
186 }
187 }
188
189 static void readErrorcxx . . $ readError(49f6e7a06ebc5aa8). () {
190 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Error reading bytes from file.");
191 }
192
193 static autoDaatacxx . . $ autoDaata# Sound_readFromKayFilecxx . . $ Sound_readFromKayFile(da9ba57d6e09e2a7). (MelderFilecxx . . $ MelderFile# file) {
194 FILE *f = file -> filePointercxx . . $ structMelderFile#filePointer.;
195 uint32cxx . . $ uint32# chunkSize = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
196 if (chunkSize & 1)
197 chunkSize += 1; // round up to even
198 if (chunkSize != 32 && chunkSize != 44)
199 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown chunk size ", chunkSize, U". Please report to [email protected].");
200 char data [100];
201 if (fread (data, 1, 20, f) < 20)
202 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
203 const double samplingFrequency = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f); // converting up (from 32 to 53 bits)
204 const integercxx . . $ integer# numberOfSamples = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
205 if (samplingFrequency <= 0 || samplingFrequency > 1e7 || numberOfSamples >= 1000000000)
206 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Not a correct Kay file.");
207 const int16cxx . . $ int16# tmp1 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
208 const int16cxx . . $ int16# tmp2 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
209 integercxx . . $ integer# numberOfChannels = ( tmp1 == -1 || tmp2 == -1 ? 1 : 2 );
210 if (chunkSize == 44) {
211 const int16cxx . . $ int16# tmp3 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
212 if (tmp3 != -1)
213 numberOfChannels ++;
214 const int16cxx . . $ int16# tmp4 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
215 if (tmp4 != -1)
216 numberOfChannels ++;
217 const int16cxx . . $ int16# tmp5 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
218 if (tmp5 != -1)
219 numberOfChannels ++;
220 const int16cxx . . $ int16# tmp6 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
221 if (tmp6 != -1)
222 numberOfChannels ++;
223 const int16cxx . . $ int16# tmp7 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
224 if (tmp7 != -1)
225 numberOfChannels ++;
226 const int16cxx . . $ int16# tmp8 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
227 if (tmp8 != -1)
228 numberOfChannels ++;
229 }
230 /*
231 SD chunk.
232 */
233 autoSoundcxx . . $ autoSound# me = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (numberOfChannels, numberOfSamples / samplingFrequency, samplingFrequency);
234 for (integercxx . . $ integer# ichan = 1; ichan <= numberOfChannels; ichan ++) {
235 if (fread (data, 1, 4, f) < 4)
236 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
237 while (! strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "SD", 2)) {
238 if (feof ((FILE *) f))
239 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing or unreadable SD chunk. Please report to [email protected].");
240 chunkSize = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
241 if (chunkSize & 1)
242 chunkSize += 1; // round up to even
243 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Chunk ",
244 data [0], U" ", data [1], U" ", data [2], U" ", data [3], U" ", chunkSize);
245 fseek (f, chunkSize, SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!);
246 if (fread (data, 1, 4, f) < 4)
247 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
248 }
249 chunkSize = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
250 integercxx . . $ integer# residual = chunkSize - numberOfSamples * 2;
251 if (residual == -2 || residual == 2) {
252 const integercxx . . $ integer# localNumberOfSamples = numberOfSamples + residual / 2;
253 //TRACE
254 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Reading ", localNumberOfSamples, U" samples instead of the promised ", numberOfSamples, U".");
255 if (ichan == 1) {
256 me =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_extractPartcxx . . $ Sound_extractPart(e1651eb055dd2f09). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, localNumberOfSamples / samplingFrequency, kSound_windowShapecxx . . $ kSound_windowShape#::RECTANGULARcxx . . $ kSound_windowShape#RECTANGULAR., 1.0, true);
257 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! nx == localNumberOfSamples);
258 } else {
259 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! nx == localNumberOfSamples,
260 U"Not all channels have the same numbers of samples.");
261 }
262 for (integercxx . . $ integer# i = 1; i <= localNumberOfSamples; i ++)
263 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ichan] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (double) bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f) / 32768.0;
264 } else if (residual != 0) {
265 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Incomplete SD chunk: attested size ", chunkSize, U" bytes,"
266 U" announced size ", numberOfSamples * 2, U" bytes. Please report to [email protected].");
267 } else {
268 for (integercxx . . $ integer# i = 1; i <= numberOfSamples; i ++)
269 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ichan] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (double) bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f) / 32768.0;
270 }
271 }
272 //Melder_casual (ftell (f));
273 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21).;
274 }
275 static autoDaatacxx . . $ autoDaata# Sounds_readFromKayNasalityFilecxx . . $ Sounds_readFromKayNasalityFile(da9ba57d6e09e2a7). (MelderFilecxx . . $ MelderFile# file) {
276 FILE *f = file -> filePointercxx . . $ structMelderFile#filePointer.;
277 uint32cxx . . $ uint32# chunkSize = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
278 if (chunkSize & 1)
279 chunkSize += 1; // round up to even
280 if (chunkSize != 100)
281 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown chunk size ", chunkSize, U". Please report to [email protected].");
282 char data [100];
283 if (fread (data, 1, 20, f) < 20)
284 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
285 const int16cxx . . $ int16# tmp1 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
286 const int16cxx . . $ int16# tmp2 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
287 integercxx . . $ integer# numberOfChannels = ( tmp1 == -1 || tmp2 == -1 ? 1 : 2 );
288 const int16cxx . . $ int16# tmp3 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
289 if (tmp3 != -1)
290 numberOfChannels ++;
291 const int16cxx . . $ int16# tmp4 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
292 if (tmp4 != -1)
293 numberOfChannels ++;
294 const int16cxx . . $ int16# tmp5 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
295 if (tmp5 != -1)
296 numberOfChannels ++;
297 const int16cxx . . $ int16# tmp6 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
298 if (tmp6 != -1)
299 numberOfChannels ++;
300 const int16cxx . . $ int16# tmp7 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
301 if (tmp7 != -1)
302 numberOfChannels ++;
303 const int16cxx . . $ int16# tmp8 = bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f);
304 if (tmp8 != -1)
305 numberOfChannels ++;
306 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfChannels >= 2,
307 U"Expecting at least two channels (nasal and oral) instead of ", numberOfChannels,
308 U". Please report to [email protected]."
309 );
310 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfChannels <= 3,
311 U"Expecting at most three channels (nasal, oral and nasalance) instead of ", numberOfChannels,
312 U". Please report to [email protected]."
313 );
314 double channelSamplingFrequencies [1+8] = { 0.0, undefinedcxx . . $ undefined., undefinedcxx . . $ undefined., undefinedcxx . . $ undefined., undefinedcxx . . $ undefined., undefinedcxx . . $ undefined., undefinedcxx . . $ undefined., undefinedcxx . . $ undefined., undefinedcxx . . $ undefined. };
315 for (int ichan = 1; ichan <= 8; ichan ++)
316 channelSamplingFrequencies [ichan] = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f); // converting up (from 32 to 53 bits)
317 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (channelSamplingFrequencies [2] == channelSamplingFrequencies [1],
318 U"Expecting equal sampling frequencies for channels 1 (nasal) and 2 (oral), "
319 "but found differing sampling frequencies (", channelSamplingFrequencies [1],
320 U" and ", channelSamplingFrequencies [2], U" Hz, respectively). Please report to [email protected]."
321 );
322 for (integercxx . . $ integer# ichan = numberOfChannels + 1; ichan <= 8; ichan ++)
323 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (channelSamplingFrequencies [ichan] == 0.0,
324 U"Sampling frequency of non-existent channel ", ichan,
325 U" should be 0 but is ", channelSamplingFrequencies [ichan],
326 U" Hz. Please report to [email protected]."
327 );
328 integercxx . . $ integer# channelNumbersOfSamples [1+8] = { 0, -1, -1, -1, -1, -1, -1, -1, -1 };
329 for (integercxx . . $ integer# ichan = 1; ichan <= 8; ichan ++)
330 channelNumbersOfSamples [ichan] = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
331 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (channelNumbersOfSamples [2] == channelNumbersOfSamples [1],
332 U"Expecting equal numbers of samples in channels 1 (nasal) and 2 (oral), "
333 "but found differing numbers of samples (", channelNumbersOfSamples [1],
334 U" and ", channelNumbersOfSamples [2], U", respectively). Please report to [email protected]."
335 );
336 for (integercxx . . $ integer# ichan = numberOfChannels + 1; ichan <= 8; ichan ++)
337 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (channelNumbersOfSamples [ichan] == 0,
338 U"Sample count of non-existent channel ", ichan,
339 U" should be 0 but is ", channelNumbersOfSamples [ichan],
340 U". Please report to [email protected]."
341 );
342 /*
343 SD chunk.
344 */
345 autoCollectioncxx . . $ autoCollection# me = Collection_createcxx . . $ Collection_create(859008c51157a0cd). ();
346 for (integercxx . . $ integer# ichan = 1; ichan <= numberOfChannels; ichan ++) {
347 if (fread (data, 1, 4, f) < 4)
348 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
349 while (! strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "SD", 2)) {
350 if (feof ((FILE *) f))
351 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing or unreadable SD chunk. Please report to [email protected].");
352 chunkSize = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
353 if (chunkSize & 1)
354 chunkSize += 1; // round up to even
355 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Chunk ",
356 data [0], U" ", data [1], U" ", data [2], U" ", data [3], U" ", chunkSize);
357 fseek (f, chunkSize, SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!);
358 if (fread (data, 1, 4, f) < 4)
359 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
360 }
361 chunkSize = bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (f);
362 #if 0
363 integer residual = chunkSize - numberOfSamples * 2;
364 if (residual < 0)
365 Melder_throw (U"Incomplete SD chunk: attested size ", chunkSize, U" bytes,"
366 U" announced size ", numberOfSamples * 2, U" bytes. Please report to [email protected].");
367 #endif
368 autoSoundcxx . . $ autoSound# you = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (1,
369 channelNumbersOfSamples [ichan] / channelSamplingFrequencies [ichan],
370 channelSamplingFrequencies [ichan]
371 );
372 if (channelNumbersOfSamples [ichan] == channelNumbersOfSamples [1])
373 for (integercxx . . $ integer# i = 1; i <= channelNumbersOfSamples [ichan]; i ++)
374 yourcxx . . $ `melder/melder.h:46:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (double) bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f) / 32768.0;
375 else
376 for (integercxx . . $ integer# i = 1; i <= channelNumbersOfSamples [ichan]; i ++)
377 yourcxx . . $ `melder/melder.h:46:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (double) bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (f) / 100.0;
378 //fseek (f, residual, SEEK_CUR);
379 Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (you.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ichan == 1 ? U"_nasal" : ichan == 2 ? U"_oral" : U"_nasalance");
380 mycxx . . $ `melder/melder.h:44:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (youcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
381 }
382 //Melder_casual (ftell (f));
383 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21).;
384 }
385
386 autoDaatacxx . . $ autoDaata# Sound_readFromAnyKayFilecxx . . $ Sound_readFromAnyKayFile(da9ba57d6e09e2a7). (MelderFilecxx . . $ MelderFile# file) {
387 try {
388 autofilecxx . . $ autofile# f = Melder_fopencxx . . $ autofile#autofile(8d4262d45fc644ab). (file, "rb");
389 /*
390 Read header of KAY file: 12 bytes.
391 */
392 char data [100];
393 if (fread (data, 1, 8, f) < 8)
394 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
395 if (! strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "FORMDS16", 8))
396 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Not a KAY DS-16 file.");
397 if (fread (data, 1, 4, f) < 4) // this contains the size of the DS16 chunk: typically 12 bytes less than the size of the file
398 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
399 /*
400 Read header of HEDR or HDR8 or NHDR chunk.
401 */
402 if (fread (data, 1, 4, f) < 4)
403 readErrorcxx . . $ readError(49f6e7a06ebc5aa8). ();
404 if (! strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "HEDR", 4) && ! strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "HDR8", 4) && ! strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "NHDR", 4))
405 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing HEDR or HDR8 or NHDR chunk. Please report to [email protected].");
406 /*
407 Read remainder of HEDR or HDR8 or NHDR chunk.
408 */
409 file -> filePointercxx . . $ structMelderFile#filePointer. = f;
410 autoDaatacxx . . $ autoDaata# result = ( strnequcxx . . $ `melder/melder_string32.h:70:9`! (data, "NHDR", 4) ? Sounds_readFromKayNasalityFilecxx . . $ Sounds_readFromKayNasalityFile(da9ba57d6e09e2a7). (file) : Sound_readFromKayFilecxx . . $ Sound_readFromKayFile(da9ba57d6e09e2a7). (file) );
411 f.closecxx . . $ autofile#close(1145552d769d7b5d). (file);
412 return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
413 } catch (MelderErrorcxx . . $ MelderError#) {
414 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sound not read from Kay file ", file, U".");
415 }
416 }
417
418 autoSoundcxx . . $ autoSound# Sound_readFromRawAlawFilecxx . . $ Sound_readFromRawAlawFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file) {
419 try {
420 double sampleRate = 8000.0;
421 autoMelderFilecxx . . $ autoMelderFile# mfile = MelderFile_opencxx . . $ autoMelderFile#autoMelderFile(1145552d769d7b5d). (file);
422 MelderFile_seekcxx . . $ MelderFile_seek(83b357a1fc21c557). (file, 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:112:9`!);
423 integercxx . . $ integer# numberOfSamples = MelderFile_tellcxx . . $ MelderFile_tell(4c086c6b3713bb2e). (file);
424 MelderFile_rewindcxx . . $ MelderFile_rewind(1145552d769d7b5d). (file);
425 autoSoundcxx . . $ autoSound# me = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (1, numberOfSamples / sampleRate, sampleRate);
426 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! z.ncol == numberOfSamples);
427 Melder_readAudioToFloatcxx . . $ Melder_readAudioToFloat(cd19eb660e26204e). (file, Melder_ALAWcxx . . $ `melder/melder_audiofiles.h:43:9`!, mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..getcxx . . $ automatrix#get(b2b81450b5bdda66).());
428 mfile.closecxx . . $ autoMelderFile#close(49f6e7a06ebc5aa8). ();
429 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
430 } catch (MelderErrorcxx . . $ MelderError#) {
431 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sound not read from raw A-law file ", file, U".");
432 }
433 }
434
435 void Sound_saveAsAudioFilecxx . . $ Sound_saveAsAudioFile(5caabbbba2b52333). (constSoundcxx . . $ constSound# me, MelderFilecxx . . $ MelderFile# file, int audioFileType, int numberOfBitsPerSamplePoint) {
436 try {
437 autoMelderFilecxx . . $ autoMelderFile# mfile = MelderFile_createcxx . . $ autoMelderFile#autoMelderFile(1145552d769d7b5d). (file);
438 MelderFile_writeAudioFileHeadercxx . . $ MelderFile_writeAudioFileHeader(2bed0b35f5c41b2b). (file, audioFileType, Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (1.0 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.), mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny., numberOfBitsPerSamplePoint);
439 MelderFile_writeFloatToAudiocxx . . $ MelderFile_writeFloatToAudio(a1ad9e07d2cef856). (file, mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), Melder_defaultAudioFileEncodingcxx . . $ Melder_defaultAudioFileEncoding(9b79fb6aee4c0440). (audioFileType, numberOfBitsPerSamplePoint), true);
440 MelderFile_writeAudioFileTrailercxx . . $ MelderFile_writeAudioFileTrailer(2bed0b35f5c41b2b). (file, audioFileType, Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (1.0 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.), mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny., numberOfBitsPerSamplePoint);
441 mfile.closecxx . . $ autoMelderFile#close(49f6e7a06ebc5aa8). ();
442 } catch (MelderErrorcxx . . $ MelderError#) {
443 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not written to 16-bit sound file ", file, U".");
444 }
445 }
446
447 void Sound_saveAsSesamFilecxx . . $ Sound_saveAsSesamFile(6683fe382a6f5fcb). (constSoundcxx . . $ constSound# me, MelderFilecxx . . $ MelderFile# file) {
448 try {
449 autofilecxx . . $ autofile# f = Melder_fopencxx . . $ autofile#autofile(8d4262d45fc644ab). (file, "wb");
450 integercxx . . $ integer# header [1 + 128];
451 for (integercxx . . $ integer# i = 1; i <= 128; i ++)
452 header [i] = 0;
453 /*
454 ILS header.
455 */
456 header [6] = ((mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx. - 1) >> 8) + 1; // number of disk blocks
457 header [64] = 32149; // ILS magic
458 /*
459 LVS header.
460 */
461 header [62] = Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (1.0 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.); // sampling frequency, rounded to n Hz
462 header [63] = -32000; // magic: "sampled signal"
463 header [66] = INT12_MAXcxx . . $ `melder/melder_int.h:41:10`!; // maximum absolute value: 12 bits
464 header [67] = 2047; // LVS magic
465 header [68] = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx. % 256; // number of samples in last block
466 header [69] = 1; // ?
467 /*
468 Sesam header.
469 */
470 header [126] = Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (1.0 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.); // sampling frequency, rounded to n Hz
471 header [127] = mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; // number of samples
472 for (integercxx . . $ integer# i = 1; i <= 128; i ++)
473 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (header [i], f);
474 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; i ++)
475 binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * 2048.0), f);
476 integercxx . . $ integer# tail = 256 - mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx. % 256;
477 if (tail == 256)
478 tail = 0;
479 for (integercxx . . $ integer# i = 1; i <= tail; i ++)
480 binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (0, f); // pad last block with zeroes
481 f.closecxx . . $ autofile#close(1145552d769d7b5d). (file);
482 } catch (MelderErrorcxx . . $ MelderError#) {
483 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not written to Sesam file ", file, U".");
484 }
485 }
486
487 void Sound_saveAsKayFilecxx . . $ Sound_saveAsKayFile(6683fe382a6f5fcb). (constSoundcxx . . $ constSound# me, MelderFilecxx . . $ MelderFile# file) {
488 try {
489 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! ny <= 8,
490 U"Cannot write more than 8 channels into a Kay sound file.");
491 constexpr int32cxx . . $ int32# maximumNumberOfSamples32 = (INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`! - 48) / 2;
492 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! nx <= maximumNumberOfSamples32,
493 U"Cannot write more than ", maximumNumberOfSamples32, U" samples into a Kay sound file.");
494 const int32cxx . . $ int32# numberOfSamples32 = int (mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.);
495
496 autoMelderFilecxx . . $ autoMelderFile# mfile = MelderFile_createcxx . . $ autoMelderFile#autoMelderFile(1145552d769d7b5d). (file);
497
498 /*
499 Form Chunk: contains all other chunks.
500 */
501 fwrite ("FORMDS16", 1, 8, file -> filePointercxx . . $ structMelderFile#filePointer.);
502 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (48 + numberOfSamples32 * 2, file -> filePointercxx . . $ structMelderFile#filePointer.); // size of Form Chunk
503 fwrite (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. > 2 ? "HDR8" : "HEDR", 1, 4, file -> filePointercxx . . $ structMelderFile#filePointer.);
504 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. > 2 ? 44 : 32, file -> filePointercxx . . $ structMelderFile#filePointer.);
505
506 char date [100];
507 time_tcxx . . $ time_t# today = time (nullptr);
508 strcpy (date, ctime (& today));
509 fwrite (date+4, 1, 20, file -> filePointercxx . . $ structMelderFile#filePointer.); // skip weekday
510
511 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (1.0 / mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx.), file -> filePointercxx . . $ structMelderFile#filePointer.); // sampling frequency
512 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (numberOfSamples32, file -> filePointercxx . . $ structMelderFile#filePointer.); // number of samples
513 int maximumA = 0;
514 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; i ++) {
515 const integercxx . . $ integer# value = Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * 32768.0);
516 if (value < - maximumA)
517 maximumA = - value;
518 if (value > maximumA)
519 maximumA = value;
520 }
521 binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (maximumA, file -> filePointercxx . . $ structMelderFile#filePointer.); // absolute maximum window A
522 if (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. == 1) {
523 binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (-1, file -> filePointercxx . . $ structMelderFile#filePointer.);
524 } else {
525 for (integercxx . . $ integer# ichannel = 2; ichannel <= mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.; ichannel ++) {
526 int maximum = 0;
527 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; i ++) {
528 const integercxx . . $ integer# value = Melder_iround_tieDowncxx . . $ Melder_iround_tieDown(a6e4a4c8b00c35a3). (mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ichannel] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] * 32768.0);
529 if (value < - maximum)
530 maximum = - value;
531 if (value > maximum)
532 maximum = value;
533 }
534 binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (maximum, file -> filePointercxx . . $ structMelderFile#filePointer.); // absolute maximum window B
535 }
536 if (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. > 2)
537 for (integercxx . . $ integer# ichannel = mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. + 1; ichannel <= 8; ichannel ++)
538 binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (-1, file -> filePointercxx . . $ structMelderFile#filePointer.);
539 }
540 fwrite ("SDA_", 1, 4, file -> filePointercxx . . $ structMelderFile#filePointer.);
541 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (numberOfSamples32 * 2, file -> filePointercxx . . $ structMelderFile#filePointer.); // chunk size
542 MelderFile_writeFloatToAudiocxx . . $ MelderFile_writeFloatToAudio(a1ad9e07d2cef856). (file,
543 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..horizontalBandcxx . . $ automatrix#horizontalBand(244fa7aab97a21b1). (1, 1), Melder_LINEAR_16_LITTLE_ENDIANcxx . . $ `melder/melder_audiofiles.h:37:9`!, true);
544 if (mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny. > 1) {
545 fwrite ("SD_B", 1, 4, file -> filePointercxx . . $ structMelderFile#filePointer.);
546 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (numberOfSamples32 * 2, file -> filePointercxx . . $ structMelderFile#filePointer.); // chunk size
547 MelderFile_writeFloatToAudiocxx . . $ MelderFile_writeFloatToAudio(a1ad9e07d2cef856). (file,
548 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..horizontalBandcxx . . $ automatrix#horizontalBand(244fa7aab97a21b1). (2, 2), Melder_LINEAR_16_LITTLE_ENDIANcxx . . $ `melder/melder_audiofiles.h:37:9`!, true);
549 }
550 for (integercxx . . $ integer# ichannel = 3; ichannel <= mycxx . . $ `melder/melder.h:44:9`! nycxx . . $ structSampledXY#ny.; ichannel ++) {
551 fwrite (Melder_peek32to8 (Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"SD_", ichannel)), 1, 4, file -> filePointercxx . . $ structMelderFile#filePointer.);
552 binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (numberOfSamples32 * 2, file -> filePointercxx . . $ structMelderFile#filePointer.); // chunk size
553 MelderFile_writeFloatToAudiocxx . . $ MelderFile_writeFloatToAudio(a1ad9e07d2cef856). (file,
554 mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..horizontalBandcxx . . $ automatrix#horizontalBand(244fa7aab97a21b1). (ichannel, ichannel), Melder_LINEAR_16_LITTLE_ENDIANcxx . . $ `melder/melder_audiofiles.h:37:9`!, true);
555 }
556 mfile.closecxx . . $ autoMelderFile#close(49f6e7a06ebc5aa8). ();
557 } catch (MelderErrorcxx . . $ MelderError#) {
558 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not written to Kay sound file ", file, U".");
559 }
560 }
561
562 void Sound_saveAsRawSoundFilecxx . . $ Sound_saveAsRawSoundFile(c265c8f135494a56). (constSoundcxx . . $ constSound# me, MelderFilecxx . . $ MelderFile# file, int encoding) {
563 try {
564 autoMelderFilecxx . . $ autoMelderFile# mfile = MelderFile_createcxx . . $ autoMelderFile#autoMelderFile(1145552d769d7b5d). (file);
565 MelderFile_writeFloatToAudiocxx . . $ MelderFile_writeFloatToAudio(a1ad9e07d2cef856). (file, mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), encoding, true);
566 mfile.closecxx . . $ autoMelderFile#close(49f6e7a06ebc5aa8). ();
567 } catch (MelderErrorcxx . . $ MelderError#) {
568 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not written to raw sound file ", file, U".");
569 }
570 }
571
572 /* End of file Sound_files.cpp */