Debian Codegraph @

foned/SoundRecorder.cpp

raw symbols SCIP
1 /* SoundRecorder.cpp
2 *
3 * Copyright (C) 1992-2026 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 3 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 /* Linux code originally by Darryl Purnell, Pretoria */
19 /* GTK conversion includes work by Franz Brauße */
20
21 /* This source file describes interactive sound recorders for the following systems:
22 * MacOS
23 * Linux
24 * Windows
25 * Because the behaviour of these sound recorders is partly similar, partly different,
26 * this would seem a good candidate for object-oriented programming
27 * (one audio manager and several audio drivers).
28 * However, the places where sound recorders are similar and where they are different,
29 * are hard to predict. For this reason, everything is done with platform #ifdefs.
30 */
31
32 #include <errno.h>
33 #include "SoundRecorder.h"cxx . . $ `<file>/foned/SoundRecorder.h`/
34 #include "Sound_and_Spectrum.h"cxx . . $ `<file>/fon/Sound_and_Spectrum.h`/
35 #include "machine.h"cxx . . $ `<file>/sys/machine.h`/
36 #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/
37 #if defined (macintosh)
38 #include "pa_mac_core.h"
39 #endif
40
41 #include "enums_getText.h"cxx . . $ `<file>/melder/enums_getText.h`/
42 #include "SoundRecorder_enums.h"cxx . . $ `<file>/foned/SoundRecorder_enums.h`/
43 #include "enums_getValue.h"cxx . . $ `<file>/melder/enums_getValue.h`/
44 #include "SoundRecorder_enums.h"cxx . . $ `<file>/foned/SoundRecorder_enums.h`/
45
46 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (SoundRecorder, Editor, 0);
47
48 #include "Prefs_define.h"cxx . . $ `<file>/sys/Prefs_define.h`/
49 #include "SoundRecorder_prefs.h"cxx . . $ `<file>/foned/SoundRecorder_prefs.h`/
50 #include "Prefs_install.h"cxx . . $ `<file>/sys/Prefs_install.h`/
51 #include "SoundRecorder_prefs.h"cxx . . $ `<file>/foned/SoundRecorder_prefs.h`/
52 #include "Prefs_copyToInstance.h"cxx . . $ `<file>/sys/Prefs_copyToInstance.h`/
53 #include "SoundRecorder_prefs.h"cxx . . $ `<file>/foned/SoundRecorder_prefs.h`/
54
55 static structcxx . . $ $anonymous_type_e7a3ad901293445f_0# {
56 integercxx . . $ integer# bufferSizeInMegabytescxx . . $ $anonymous_type_e7a3ad901293445f_0#bufferSizeInMegabytes.;
57 } preferencescxx . . $ preferences.;
58
59 void SoundRecorder_preferencescxx . . $ SoundRecorder_preferences(49f6e7a06ebc5aa8). () {
60 Preferences_addIntegercxx . . $ Preferences_addInteger(dd1501ba114a3e1c). (U"SoundRecorder.bufferSizeInMegabytes", & preferencescxx . . $ preferences..bufferSizeInMegabytescxx . . $ $anonymous_type_e7a3ad901293445f_0#bufferSizeInMegabytes., 60);
61 }
62
63 integercxx . . $ integer# SoundRecorder_getBufferSizePref_MBcxx . . $ SoundRecorder_getBufferSizePref_MB(da6335ded91d79c2). () {
64 return preferencescxx . . $ preferences..bufferSizeInMegabytescxx . . $ $anonymous_type_e7a3ad901293445f_0#bufferSizeInMegabytes.;
65 }
66 void SoundRecorder_setBufferSizePref_MBcxx . . $ SoundRecorder_setBufferSizePref_MB(1624ee8275b10bda). (integercxx . . $ integer# size) {
67 preferencescxx . . $ preferences..bufferSizeInMegabytescxx . . $ $anonymous_type_e7a3ad901293445f_0#bufferSizeInMegabytes. = Melder_clippedcxx . . $ Melder_clipped(5eb09607cedc971b). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., size, 1000_integercxx . . $ `operator""_integer`(85240eb457c3721a).);
68 }
69
70 #define stepcxx . . $ `foned/SoundRecorder.cpp:70:9`! 1000
71
72 /* For those systems that do not have a pollable audio control panel, */
73 /* the settings are saved only here, so that they are remembered across */
74 /* subsequent creations of a SoundRecorder. Also, this is then the way */
75 /* in which two simultaneously open SoundRecorders would communicate. */
76
77 static structcxx . . $ $anonymous_type_e7a3ad901293445f_1# {
78 int inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource.; // 1 = microphone, 2 = line, 3 = digital
79 int leftGaincxx . . $ $anonymous_type_e7a3ad901293445f_1#leftGain., rightGaincxx . . $ $anonymous_type_e7a3ad901293445f_1#rightGain.; // 0..255
80 double sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.;
81 } theControlPanelcxx . . $ theControlPanel. =
82 #if defined (linuxcxx . . $ `<built-in>:480:9`!)
83 { 1, 200, 200, 44100.0 };
84 #elif defined (macintosh)
85 { 1, 26, 26, 44100.0 };
86 #else
87 { 1, 26, 26, 44100.0 };
88 #endif
89
90 /********** ERROR HANDLING **********/
91
92 #if defined (_WIN32)
93 static void win_fillFormat (SoundRecorder me) {
94 my waveFormat. nSamplesPerSec = (int) theControlPanel. sampleRate;
95 my waveFormat. nChannels = my numberOfChannels;
96 my waveFormat. wFormatTag = WAVE_FORMAT_PCM;
97 my waveFormat. wBitsPerSample = 16;
98 my waveFormat. nBlockAlign = my waveFormat. nChannels * my waveFormat. wBitsPerSample / 8;
99 my waveFormat. nAvgBytesPerSec = my waveFormat. nBlockAlign * my waveFormat. nSamplesPerSec;
100 my waveFormat. cbSize = 0;
101 }
102 static void win_fillHeader (SoundRecorder me, int which) {
103 my waveHeader [which]. dwFlags = 0;
104 my waveHeader [which]. lpData =
105 ( which == 0 ? (char *) my recordBuffer.asArgumentToFunctionThatExpectsZeroBasedArray() :
106 which == 1 ? (char *) my buffertje1: (char *) my buffertje2 );
107 my waveHeader [which]. dwBufferLength =
108 ( which == 0 ? my nmax * my waveFormat. nChannels * 2 : 1000 * my waveFormat. nChannels * 2 );
109 my waveHeader [which]. dwLoops = 0;
110 my waveHeader [which]. lpNext = nullptr;
111 my waveHeader [which]. reserved = 0;
112 }
113 static void win_waveInCheck (SoundRecorder me) {
114 wchar_t messageText [MAXERRORLENGTH];
115 MMRESULT err;
116 if (my err == MMSYSERR_NOERROR) return;
117 err = waveInGetErrorText (my err, messageText, MAXERRORLENGTH);
118 if (err == MMSYSERR_NOERROR)
119 Melder_throw (Melder_peekWto32 (messageText));
120 else if (err == MMSYSERR_BADERRNUM)
121 Melder_throw (U"Error number ", my err, U" out of range.");
122 else if (err == MMSYSERR_NODRIVER)
123 Melder_throw (U"No sound driver present.");
124 else if (err == MMSYSERR_NOMEM)
125 Melder_throw (U"Out of memory.");
126 else
127 Melder_throw (U"Unknown sound error.");
128 }
129 static void win_waveInOpen (SoundRecorder me) {
130 try {
131 my err = waveInOpen (& my hWaveIn, WAVE_MAPPER, & my waveFormat, 0, 0, CALLBACK_NULL);
132 win_waveInCheck (me);
133 if (! (Melder_debug == 8))
134 waveInReset (my hWaveIn);
135 } catch (MelderError) {
136 Melder_throw (U"Audio input not opened.");
137 }
138 }
139 static void win_waveInPrepareHeader (SoundRecorder me, int which) {
140 try {
141 my err = waveInPrepareHeader (my hWaveIn, & my waveHeader [which], sizeof (WAVEHDR));
142 win_waveInCheck (me);
143 } catch (MelderError) {
144 Melder_throw (U"Audio input: cannot prepare header.\nQuit some other programs or go to \"Sound input prefs\" in the Preferences menu.");
145 }
146 }
147 static void win_waveInAddBuffer (SoundRecorder me, int which) {
148 try {
149 my err = waveInAddBuffer (my hWaveIn, & my waveHeader [which], sizeof (WAVEHDR));
150 win_waveInCheck (me);
151 } catch (MelderError) {
152 Melder_throw (U"Audio input: cannot add buffer.");
153 }
154 }
155 static void win_waveInStart (SoundRecorder me) {
156 try {
157 my err = waveInStart (my hWaveIn); // asynchronous
158 win_waveInCheck (me);
159 } catch (MelderError) {
160 Melder_throw (U"Audio input not started.");
161 }
162 }
163 static void win_waveInStop (SoundRecorder me) {
164 try {
165 my err = waveInStop (my hWaveIn);
166 win_waveInCheck (me);
167 } catch (MelderError) {
168 Melder_throw (U"Audio input not stopped.");
169 }
170 }
171 static void win_waveInReset (SoundRecorder me) {
172 try {
173 my err = waveInReset (my hWaveIn);
174 win_waveInCheck (me);
175 } catch (MelderError) {
176 Melder_throw (U"Audio input not reset.");
177 }
178 }
179 static void win_waveInUnprepareHeader (SoundRecorder me, int which) {
180 try {
181 my err = waveInUnprepareHeader (my hWaveIn, & my waveHeader [which], sizeof (WAVEHDR));
182 win_waveInCheck (me);
183 } catch (MelderError) {
184 Melder_throw (U"Audio input: cannot unprepare header.");
185 }
186 }
187 static void win_waveInClose (SoundRecorder me) {
188 try {
189 my err = waveInClose (my hWaveIn);
190 my hWaveIn = 0;
191 win_waveInCheck (me);
192 } catch (MelderError) {
193 Melder_throw (U"Audio input not closed.");
194 }
195 }
196 #endif
197
198 static void stopRecordingcxx . . $ stopRecording(2c647c0fc59fc937). (SoundRecordercxx . . $ SoundRecorder# me) {
199 if (! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.) return;
200 try {
201 mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. = false;
202 if (! mycxx . . $ `melder/melder.h:44:9`! synchronouscxx . . $ structSoundRecorder#synchronous.) {
203 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
204 Pa_StopStream (mycxx . . $ `melder/melder.h:44:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.);
205 Pa_CloseStream (mycxx . . $ `melder/melder.h:44:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.);
206 mycxx . . $ `melder/melder.h:44:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream. = nullptr;
207 } else {
208 #if defined (_WIN32)
209 /*
210 * On newer systems, waveInStop waits until the buffer is full.
211 * Wrong behaviour!
212 * Therefore, we call waveInReset instead.
213 * But on these same newer systems, waveInReset causes the dwBytesRecorded
214 * attribute to go to zero, so we cannot do
215 * my nsamp = my waveHeader [0]. dwBytesRecorded / (sizeof (short) * my numberOfChannels);
216 */
217 MMTIME mmtime;
218 mmtime. wType = TIME_BYTES;
219 my nsamp = 0;
220 if (waveInGetPosition (my hWaveIn, & mmtime, sizeof (MMTIME)) == MMSYSERR_NOERROR)
221 my nsamp = mmtime. u.cb / (sizeof (short) * my numberOfChannels);
222 win_waveInReset (me);
223 if (my nsamp == 0)
224 my nsamp = my waveHeader [0]. dwBytesRecorded / (sizeof (short) * my numberOfChannels);
225 if (my nsamp > my nmax)
226 my nsamp = my nmax;
227 win_waveInUnprepareHeader (me, 0);
228 win_waveInClose (me);
229 #endif
230 }
231 }
232 } catch (MelderErrorcxx . . $ MelderError#) {
233 Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Cannot stop recording.");
234 }
235 }
236
237 void structSoundRecordercxx . . $ structSoundRecorder# :: v9_destroycxx . . $ structSoundRecorder#v9_destroy(ced63f7c635d850d). () noexcept {
238 stopRecordingcxx . . $ stopRecording(2c647c0fc59fc937). (this); // must occur before freeing our buffer
239 MelderAudio_stopPlayingcxx . . $ MelderAudio_stopPlaying(efaadfb7dc14930a). (MelderAudio_IMPLICITcxx . . $ `melder/melder_audio.h:57:9`!); // must also occur before freeing our buffer
240 #if cocoacxx . . $ `sys/Gui.h:35:10`!
241 if (our d_cocoaTimer)
242 CFRunLoopTimerInvalidate (our d_cocoaTimer);
243 #elif gtkcxx . . $ `sys/Gui.h:33:10`!
244 g_idle_remove_by_data (this);
245 #elif motif
246 if (our workProcId)
247 XtRemoveWorkProc (our workProcId);
248 #endif
249
250 if (ourcxx . . $ `melder/melder.h:42:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
251 if (ourcxx . . $ `melder/melder.h:42:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.)
252 Pa_StopStream (ourcxx . . $ `melder/melder.h:42:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.);
253 if (ourcxx . . $ `melder/melder.h:42:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.)
254 Pa_CloseStream (ourcxx . . $ `melder/melder.h:42:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.);
255 } else {
256 #if defined (_WIN32)
257 if (our hWaveIn != 0) {
258 waveInReset (our hWaveIn);
259 waveInUnprepareHeader (our hWaveIn, & our waveHeader [0], sizeof (WAVEHDR));
260 waveInClose (our hWaveIn);
261 }
262 #elif defined (macintosh)
263 #elif defined (UNIXcxx . . $ `<built-in>:479:9`!)
264 if (ourcxx . . $ `melder/melder.h:42:9`! fdcxx . . $ structSoundRecorder#fd. != -1)
265 close (ourcxx . . $ `melder/melder.h:42:9`! fdcxx . . $ structSoundRecorder#fd.);
266 #endif
267 }
268 ourcxx . . $ `melder/melder.h:42:9`! SoundRecorder_Parentcxx . . $ SoundRecorder_Parent# :: v9_destroycxx . . $ structEditor#v9_destroy(ced63f7c635d850d). ();
269 }
270
271 static void showMaximumcxx . . $ showMaximum(471b4a07e72464a). (SoundRecordercxx . . $ SoundRecorder# me, int channel, double maximum) {
272 maximum /= 32768.0;
273 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(),
274 mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 1 || channel == 1 ? 0.0 : -1.0,
275 mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 1 || channel == 2 ? 1.0 : 2.0,
276 -0.1, 1.1);
277 Graphics_setGreycxx . . $ Graphics_setGrey(2514a1c07b6be5e2). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.9);
278 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, maximum, 1.0);
279 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_GREENcxx . . $ Melder_GREEN.);
280 if (maximum < 0.75) {
281 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.0, maximum);
282 } else {
283 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.0, 0.75);
284 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_YELLOWcxx . . $ Melder_YELLOW.);
285 if (maximum < 0.92) {
286 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.75, maximum);
287 } else {
288 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.75, 0.92);
289 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_REDcxx . . $ Melder_RED.);
290 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.92, maximum);
291 }
292 }
293 }
294
295 static void showMetercxx . . $ showMeter(55c0a735bf1829b7). (SoundRecordercxx . . $ SoundRecorder# me, const short *buffertje, integercxx . . $ integer# nsamp) {
296 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! graphics);
297 Graphics_clearWscxx . . $ Graphics_clearWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
298 if (nsamp < 1) {
299 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.0, 1.0);
300 #if defined (macintosh)
301 Graphics_setColour (my graphics.get(), Melder_WHITE);
302 Graphics_fillRectangle (my graphics.get(), 0.2, 0.8, 0.3, 0.7);
303 #endif
304 Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!);
305 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_BLACKcxx . . $ Melder_BLACK.);
306 Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.5, 0.5, U"Not recording.");
307 return;
308 }
309 if (mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_whichcxx . . $ structSoundRecorder#instancePref_meter_which(c9ba0948ac0163b5).() == kSoundRecorder_meter::INTENSITY) {
310 int leftMaximum = 0, rightMaximum = 0;
311 if (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 1) {
312 for (integercxx . . $ integer# i = 0; i < nsamp; i ++) {
313 int value = buffertje [i];
314 if (abscxx . . $ abs(a1851578aea3f541). (value) > leftMaximum)
315 leftMaximum = abscxx . . $ abs(a1851578aea3f541). (value);
316 }
317 } else {
318 for (integercxx . . $ integer# i = 0; i < nsamp; i ++) {
319 int left = buffertje [2 * i], right = buffertje [2 * i + 1];
320 if (abscxx . . $ abs(a1851578aea3f541). (left) > leftMaximum)
321 leftMaximum = abscxx . . $ abs(a1851578aea3f541). (left);
322 if (abscxx . . $ abs(a1851578aea3f541). (right) > rightMaximum)
323 rightMaximum = abscxx . . $ abs(a1851578aea3f541). (right);
324 }
325 }
326 if (mycxx . . $ `melder/melder.h:44:9`! lastLeftMaximumcxx . . $ structSoundRecorder#lastLeftMaximum. > 30000) {
327 int leak = mycxx . . $ `melder/melder.h:44:9`! lastLeftMaximumcxx . . $ structSoundRecorder#lastLeftMaximum. - Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (2000000.0 / theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.);
328 if (leftMaximum < leak)
329 leftMaximum = leak;
330 }
331 showMaximumcxx . . $ showMaximum(471b4a07e72464a). (me, 1, leftMaximum);
332 mycxx . . $ `melder/melder.h:44:9`! lastLeftMaximumcxx . . $ structSoundRecorder#lastLeftMaximum. = leftMaximum;
333 if (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 2) {
334 if (mycxx . . $ `melder/melder.h:44:9`! lastRightMaximumcxx . . $ structSoundRecorder#lastRightMaximum. > 30000) {
335 int leak = mycxx . . $ `melder/melder.h:44:9`! lastRightMaximumcxx . . $ structSoundRecorder#lastRightMaximum. - Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (2000000.0 / theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.);
336 if (rightMaximum < leak)
337 rightMaximum = leak;
338 }
339 showMaximumcxx . . $ showMaximum(471b4a07e72464a). (me, 2, rightMaximum);
340 mycxx . . $ `melder/melder.h:44:9`! lastRightMaximumcxx . . $ structSoundRecorder#lastRightMaximum. = rightMaximum;
341 }
342 } else if (mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_whichcxx . . $ structSoundRecorder#instancePref_meter_which(c9ba0948ac0163b5).() == kSoundRecorder_meter::CENTRE_OF_GRAVITY_VERSUS_INTENSITY) {
343 autoSoundcxx . . $ autoSound# sound = Sound_createcxx . . $ Sound_create(39ab106d6b9a0135). (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.,
344 0.0, nsamp / theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.,
345 nsamp, 1.0 / theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate., 0.5 / theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.);
346 const short *p = & buffertje [0];
347 for (integercxx . . $ integer# isamp = 1; isamp <= nsamp; isamp ++)
348 for (integercxx . . $ integer# ichan = 1; ichan <= mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.; ichan ++)
349 sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ichan] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp] = * (p ++) / 32768.0;
350 Sound_multiplyByWindowcxx . . $ Sound_multiplyByWindow(bbea490a38595013). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), kSound_windowShapecxx . . $ kSound_windowShape#::KAISER_2cxx . . $ kSound_windowShape#KAISER_2.);
351 const double intensity = Sound_getIntensity_dBcxx . . $ Sound_getIntensity_dB(9577c4e030d3505d). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
352 autoSpectrumcxx . . $ autoSpectrum# spectrum = Sound_to_Spectrumcxx . . $ Sound_to_Spectrum(e96f4d575d8eeb8c). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), true);
353 const double centreOfGravity = Spectrum_getCentreOfGravitycxx . . $ Spectrum_getCentreOfGravity(9217fce55a02ebba). (spectrum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1.0);
354 tracecxx . . $ `melder/melder_debug.h:60:10`! (nsamp, U" samples, intensity ", intensity, U" dB, centre of gravity ", centreOfGravity, U" Hz");
355 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(),
356 mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_centreOfGravity_minimumcxx . . $ structSoundRecorder#instancePref_meter_centreOfGravity_minimum(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_centreOfGravity_maximumcxx . . $ structSoundRecorder#instancePref_meter_centreOfGravity_maximum(21b6c25e127938e2).(),
357 mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_intensity_minimumcxx . . $ structSoundRecorder#instancePref_meter_intensity_minimum(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_intensity_maximumcxx . . $ structSoundRecorder#instancePref_meter_intensity_maximum(21b6c25e127938e2).()
358 );
359 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_WHITEcxx . . $ Melder_WHITE.);
360 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(),
361 mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_centreOfGravity_minimumcxx . . $ structSoundRecorder#instancePref_meter_centreOfGravity_minimum(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_centreOfGravity_maximumcxx . . $ structSoundRecorder#instancePref_meter_centreOfGravity_maximum(21b6c25e127938e2).(),
362 mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_intensity_minimumcxx . . $ structSoundRecorder#instancePref_meter_intensity_minimum(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_intensity_maximumcxx . . $ structSoundRecorder#instancePref_meter_intensity_maximum(21b6c25e127938e2).()
363 );
364 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_BLACKcxx . . $ Melder_BLACK.);
365 Graphics_fillCircle_mmcxx . . $ Graphics_fillCircle_mm(8752bb7a78272ca7). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), centreOfGravity, intensity, 3.0);
366 }
367 }
368
369 static bool tooManySamplesInBufferToReturnToGuicxx . . $ tooManySamplesInBufferToReturnToGui(da9a69910d0b1566). (SoundRecordercxx . . $ SoundRecorder# me) {
370 (void) me;
371 return false;
372 }
373
374 static integercxx . . $ integer# getMyNsampcxx . . $ getMyNsamp(cbdff03d494f56b7). (SoundRecordercxx . . $ SoundRecorder# me) {
375 volatile integercxx . . $ integer# nsamp = mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp.; // Prevent inlining.
376 return nsamp;
377 }
378
379 #if cocoacxx . . $ `sys/Gui.h:35:10`!
380 #define WORKPROC_RETURN void
381 #define WORKPROC_ARGS CFRunLoopTimerRef /*timer*/, void *void_SoundRecorder
382 #elif gtkcxx . . $ `sys/Gui.h:33:10`!
383 #define WORKPROC_RETURNcxx . . $ `foned/SoundRecorder.cpp:383:10`! gboolean
384 #define WORKPROC_ARGScxx . . $ `foned/SoundRecorder.cpp:384:10`! void *void_SoundRecorder
385 #else
386 #define WORKPROC_RETURN bool
387 #define WORKPROC_ARGS void *void_SoundRecorder
388 #endif
389
390 static WORKPROC_RETURNcxx . . $ `foned/SoundRecorder.cpp:383:10`! workProccxx . . $ workProc(dedf1e9b1c614a07). (WORKPROC_ARGScxx . . $ `foned/SoundRecorder.cpp:384:10`!) {
391 SoundRecordercxx . . $ SoundRecorder# me = static_cast <SoundRecordercxx . . $ SoundRecorder#> (void_SoundRecorder);
392 try {
393 short buffertje [stepcxx . . $ `foned/SoundRecorder.cpp:70:9`!*2];
394 int stepje = 0;
395
396 /*
397 Determine global audio parameters (may have been changed by an external control panel):
398 1. input source;
399 2. left and right gain;
400 3. sampling frequency.
401 */
402 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
403 } else {
404 }
405
406 /*
407 Set the buttons according to the audio parameters.
408 */
409 if (mycxx . . $ `melder/melder.h:44:9`! recordButtoncxx . . $ structSoundRecorder#recordButton.)
410 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! recordButtoncxx . . $ structSoundRecorder#recordButton., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.);
411 if (mycxx . . $ `melder/melder.h:44:9`! stopButtoncxx . . $ structSoundRecorder#stopButton.)
412 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! stopButtoncxx . . $ structSoundRecorder#stopButton., mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.);
413 if (mycxx . . $ `melder/melder.h:44:9`! playButtoncxx . . $ structSoundRecorder#playButton.)
414 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! playButtoncxx . . $ structSoundRecorder#playButton., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. && mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. > 0);
415 if (mycxx . . $ `melder/melder.h:44:9`! applyButtoncxx . . $ structSoundRecorder#applyButton.)
416 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! applyButtoncxx . . $ structSoundRecorder#applyButton., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. && mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. > 0);
417 if (mycxx . . $ `melder/melder.h:44:9`! okButtoncxx . . $ structSoundRecorder#okButton.)
418 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! okButtoncxx . . $ structSoundRecorder#okButton., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. && mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. > 0);
419 if (mycxx . . $ `melder/melder.h:44:9`! monoButtoncxx . . $ structSoundRecorder#monoButton. && mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 1)
420 GuiRadioButton_setcxx . . $ GuiRadioButton_set(669e3d212ae3e4fb). (mycxx . . $ `melder/melder.h:44:9`! monoButtoncxx . . $ structSoundRecorder#monoButton.);
421 if (mycxx . . $ `melder/melder.h:44:9`! stereoButtoncxx . . $ structSoundRecorder#stereoButton. && mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 2)
422 GuiRadioButton_setcxx . . $ GuiRadioButton_set(669e3d212ae3e4fb). (mycxx . . $ `melder/melder.h:44:9`! stereoButtoncxx . . $ structSoundRecorder#stereoButton.);
423 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IFSAMP_MAXcxx . . $ `foned/SoundRecorder.h:75:9`!; i ++)
424 if (mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. buttoncxx . . $ SoundRecorder_Fsamp#button. && theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate. == mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp.)
425 GuiRadioButton_setcxx . . $ GuiRadioButton_set(669e3d212ae3e4fb). (mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. buttoncxx . . $ SoundRecorder_Fsamp#button.);
426 if (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource.]. buttoncxx . . $ SoundRecorder_Device#button.)
427 GuiRadioButton_setcxx . . $ GuiRadioButton_set(669e3d212ae3e4fb). (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource.]. buttoncxx . . $ SoundRecorder_Device#button.);
428 if (mycxx . . $ `melder/melder.h:44:9`! monoButtoncxx . . $ structSoundRecorder#monoButton.) GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! monoButtoncxx . . $ structSoundRecorder#monoButton., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.);
429 if (mycxx . . $ `melder/melder.h:44:9`! stereoButtoncxx . . $ structSoundRecorder#stereoButton.) GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! stereoButtoncxx . . $ structSoundRecorder#stereoButton., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.);
430 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IFSAMP_MAXcxx . . $ `foned/SoundRecorder.h:75:9`!; i ++)
431 if (mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. buttoncxx . . $ SoundRecorder_Fsamp#button.)
432 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. buttoncxx . . $ SoundRecorder_Fsamp#button., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.);
433 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IDEVICE_MAXcxx . . $ `foned/SoundRecorder.h:59:9`!; i ++)
434 if (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [i]. buttoncxx . . $ SoundRecorder_Device#button.)
435 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [i]. buttoncxx . . $ SoundRecorder_Device#button., ! mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.);
436
437 /*Graphics_setGrey (my graphics, 0.9);
438 Graphics_fillRectangle (my graphics, 0.0, 1.0, 0.0, 32768.0);
439 Graphics_setGrey (my graphics, 0.9);
440 Graphics_fillRectangle (my graphics, 0.0, 1.0, 0.0, 32768.0);*/
441
442 if (mycxx . . $ `melder/melder.h:44:9`! synchronouscxx . . $ structSoundRecorder#synchronous.) {
443 /*
444 Read some samples into 'buffertje'.
445 */
446 do {
447 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
448 /*
449 Asynchronous recording: do nothing.
450 */
451 } else {
452 #if defined (macintosh) || defined (_WIN32)
453 /*
454 Asynchronous recording on these systems: do nothing.
455 */
456 #else
457 // linux
458 if (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd. != -1)
459 stepje = read (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., (void *) buffertje, stepcxx . . $ `foned/SoundRecorder.cpp:70:9`! * (sizeof (short) * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.)) / (sizeof (short) * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.);
460 #endif
461 }
462
463 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.)
464 memcpy (& mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1 + mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.], buffertje, stepje * (sizeof (short) * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.));
465 //showMeter (me, buffertje, stepje);
466 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.) {
467 mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. += stepje;
468 if (mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. > mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax. - stepcxx . . $ `foned/SoundRecorder.cpp:70:9`!)
469 mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. = false;
470 GuiScale_setValuecxx . . $ GuiScale_setValue(f95d34e17396363e). (mycxx . . $ `melder/melder.h:44:9`! progressScalecxx . . $ structSoundRecorder#progressScale., 1000.0 * ((double) mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. / (double) mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax.));
471 }
472 } while (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. && tooManySamplesInBufferToReturnToGuicxx . . $ tooManySamplesInBufferToReturnToGui(da9a69910d0b1566). (me));
473 } else {
474 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.) {
475 /*
476 We have to know how far the buffer has been filled.
477 However, the buffer may be filled at interrupt time,
478 so that the buffer may be being filled during this workproc.
479 So we ask for the buffer filling just once, namely here at the beginning.
480 */
481 mycxx . . $ `melder/melder.h:44:9`! lastSamplecxx . . $ structSoundRecorder#lastSample. = 0;
482 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
483 /*
484 The buffer filling is contained in my nsamp,
485 which has been set during interrupt time and may again be updated behind our backs during this workproc.
486 So we do it in such a way that the compiler cannot ask for my nsamp twice.
487 */
488 mycxx . . $ `melder/melder.h:44:9`! lastSamplecxx . . $ structSoundRecorder#lastSample. = getMyNsampcxx . . $ getMyNsamp(cbdff03d494f56b7). (me);
489 Pa_Sleep (10);
490 } else {
491 #if defined (_WIN32)
492 MMTIME mmtime;
493 mmtime. wType = TIME_BYTES;
494 if (waveInGetPosition (my hWaveIn, & mmtime, sizeof (MMTIME)) == MMSYSERR_NOERROR)
495 my lastSample = mmtime. u.cb / (sizeof (short) * my numberOfChannels);
496 #elif defined (macintosh)
497 #endif
498 }
499 mycxx . . $ `melder/melder.h:44:9`! firstSamplecxx . . $ structSoundRecorder#firstSample. = mycxx . . $ `melder/melder.h:44:9`! lastSamplecxx . . $ structSoundRecorder#lastSample. - 3000;
500 Melder_clipLeftcxx . . $ Melder_clipLeft(6245cd023a7d1552). (0_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & mycxx . . $ `melder/melder.h:44:9`! firstSamplecxx . . $ structSoundRecorder#firstSample.);
501 GuiScale_setValuecxx . . $ GuiScale_setValue(f95d34e17396363e). (mycxx . . $ `melder/melder.h:44:9`! progressScalecxx . . $ structSoundRecorder#progressScale., 1000.0 * ((double) mycxx . . $ `melder/melder.h:44:9`! lastSamplecxx . . $ structSoundRecorder#lastSample. / (double) mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax.));
502 Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
503 } else {
504 #if defined (_WIN32)
505 if (my inputUsesPortAudio) {
506 Pa_Sleep (10);
507 }
508 #endif
509 }
510 }
511 } catch (MelderErrorcxx . . $ MelderError#) {
512 Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). ();
513 }
514 #if cocoacxx . . $ `sys/Gui.h:35:10`!
515 return;
516 #elif gtkcxx . . $ `sys/Gui.h:33:10`!
517 return true;
518 #else
519 return false;
520 #endif
521 }
522
523 static int portaudioStreamCallbackcxx . . $ portaudioStreamCallback(fb4a53f6a51faeed). (
524 const void *input, void * /* output */,
525 unsigned long frameCount,
526 const PaStreamCallbackTimeInfo* /* timeInfo */,
527 PaStreamCallbackFlags /* statusFlags */,
528 void *void_SoundRecorder)
529 {
530 /*
531 This procedure may be called at interrupt time.
532 It therefore accesses only data that is constant during recording,
533 namely me, my buffer, my numberOfChannels, and my nmax.
534 The only thing it changes is my nsamp;
535 the workProc will therefore have to take some care in accessing my nsamp (see there).
536 */
537 SoundRecordercxx . . $ SoundRecorder# me = static_cast <SoundRecordercxx . . $ SoundRecorder#> (void_SoundRecorder);
538 if (Melder_debugcxx . . $ Melder_debug. == 20)
539 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"The PortAudio stream callback receives ", frameCount, U" frames.");
540 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! nsamp <= mycxx . . $ `melder/melder.h:44:9`! nmax);
541 uintegercxx . . $ uinteger# samplesLeft = mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax. - mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp.;
542 if (samplesLeft > 0) {
543 uintegercxx . . $ uinteger# dsamples = samplesLeft > frameCount ? frameCount : samplesLeft;
544 if (Melder_debugcxx . . $ Melder_debug. == 20)
545 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"play ", dsamples, U" ", Pa_GetStreamCpuLoad (mycxx . . $ `melder/melder.h:44:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.));
546 memcpy (& mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1 + mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.], input, 2 * dsamples * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.);
547 mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. += dsamples;
548 if (mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. >= mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax.)
549 return paComplete;
550 } else /*if (my nsamp >= my nmax)*/ {
551 mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. = mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax.;
552 return paComplete;
553 }
554 return paContinue;
555 }
556
557 static void gui_button_cb_recordcxx . . $ gui_button_cb_record(418132222db43621). (SoundRecordercxx . . $ SoundRecorder# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
558 try {
559 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.)
560 return;
561 mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. = 0;
562 mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. = true;
563 mycxx . . $ `melder/melder.h:44:9`! lastLeftMaximumcxx . . $ structSoundRecorder#lastLeftMaximum. = 0;
564 mycxx . . $ `melder/melder.h:44:9`! lastRightMaximumcxx . . $ structSoundRecorder#lastRightMaximum. = 0;
565 if (! mycxx . . $ `melder/melder.h:44:9`! synchronouscxx . . $ structSoundRecorder#synchronous.) {
566 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
567 PaStreamParameters streamParameters = { };
568 streamParameters. device = mycxx . . $ `melder/melder.h:44:9`! deviceIndicescxx . . $ structSoundRecorder#deviceIndices. [theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource.];
569 streamParameters. channelCount = mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.;
570 streamParameters. sampleFormat = paInt16cxx . . $ `external/portaudio/portaudio.h:490:9`!;
571 streamParameters. suggestedLatency = mycxx . . $ `melder/melder.h:44:9`! deviceInfoscxx . . $ structSoundRecorder#deviceInfos. [theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource.] -> defaultLowInputLatency;
572 #if defined (macintosh)
573 PaMacCoreStreamInfo macCoreStreamInfo = { };
574 macCoreStreamInfo. size = sizeof (PaMacCoreStreamInfo);
575 macCoreStreamInfo. hostApiType = paCoreAudio;
576 macCoreStreamInfo. version = 0x01;
577 macCoreStreamInfo. flags = paMacCoreChangeDeviceParameters | paMacCoreFailIfConversionRequired;
578 streamParameters. hostApiSpecificStreamInfo = & macCoreStreamInfo;
579 #endif
580 if (Melder_debugcxx . . $ Melder_debug. == 20)
581 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Before Pa_OpenStream");
582 PaError err = Pa_OpenStream (& mycxx . . $ `melder/melder.h:44:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream., & streamParameters, nullptr,
583 theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate., 0, paNoFlagcxx . . $ `external/portaudio/portaudio.h:656:11`!, portaudioStreamCallbackcxx . . $ portaudioStreamCallback(fb4a53f6a51faeed)., (void *) me);
584 if (Melder_debugcxx . . $ Melder_debug. == 20)
585 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Pa_OpenStream returns ", (int) err);
586 if (err) {
587 conststring32cxx . . $ conststring32# errorText = Melder_peek8to32_u (Pa_GetErrorText (err));
588 if (Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (errorText, U"Invalid number of channels"))
589 if (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 1)
590 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You are trying to record in mono, but your microphone does not seem to support that.\nPerhaps you could try to record in stereo instead.");
591 else
592 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You are trying to record in stereo, but you do not seem to have a stereo microphone.\nPerhaps you could try to record in mono instead.");
593 else
594 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Error opening audio input stream: ", errorText, U".");
595 }
596 Pa_StartStream (mycxx . . $ `melder/melder.h:44:9`! portaudioStreamcxx . . $ structSoundRecorder#portaudioStream.);
597 if (Melder_debugcxx . . $ Melder_debug. == 20)
598 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Pa_StartStream returns ", (int) err);
599 if (err)
600 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Error starting audio input stream: ", Melder_peek8to32_u (Pa_GetErrorText (err)), U".");
601 } else {
602 #if defined (_WIN32)
603 win_fillFormat (me);
604 win_fillHeader (me, 0);
605 win_waveInOpen (me);
606 win_waveInPrepareHeader (me, 0);
607 win_waveInAddBuffer (me, 0);
608 win_waveInStart (me);
609 #elif defined (macintosh)
610 #endif
611 }
612 }
613 Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
614 } catch (MelderErrorcxx . . $ MelderError#) {
615 mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. = false;
616 Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
617 Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"The recording was not started.");
618 }
619 }
620
621 static void gui_button_cb_stopcxx . . $ gui_button_cb_stop(418132222db43621). (SoundRecordercxx . . $ SoundRecorder# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
622 stopRecordingcxx . . $ stopRecording(2c647c0fc59fc937). (me);
623 Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
624 }
625
626 static void gui_button_cb_playcxx . . $ gui_button_cb_play(418132222db43621). (SoundRecordercxx . . $ SoundRecorder# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
627 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording. || mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. == 0)
628 return;
629 MelderAudio_play16cxx . . $ MelderAudio_play16(4eeb2eee1b9aa526). (mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer..asArgumentToFunctionThatExpectsZeroBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsZeroBasedArray(5a2a78a048fb49a8).(),
630 theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate., mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp., mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels., nullptr, nullptr);
631 }
632
633 static void publishcxx . . $ publish(2c647c0fc59fc937). (SoundRecordercxx . . $ SoundRecorder# me) {
634 autoSoundcxx . . $ autoSound# soundcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).;
635 if (mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. == 0)
636 return;
637 double fsamp = theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.;
638 if (fsamp <= 0.0)
639 fsamp = 44100.0; // safe
640 try {
641 sound =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels., (double) mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp. / fsamp, fsamp);
642 } catch (MelderErrorcxx . . $ MelderError#) {
643 Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"You can still save to file.");
644 return;
645 }
646 if (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 1) {
647 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp.; i ++)
648 sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] * (1.0 / 32768);
649 } else {
650 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp.; i ++) {
651 sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + i - 1] * (1.0 / 32768);
652 sound ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).2] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i + i] * (1.0 / 32768);
653 }
654 }
655 if (mycxx . . $ `melder/melder.h:44:9`! soundNamecxx . . $ structSoundRecorder#soundName.) {
656 autostring32cxx . . $ autostring32# name = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! soundNamecxx . . $ structSoundRecorder#soundName.);
657 Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (sound.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), name.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
658 }
659 Editor_broadcastPublicationcxx . . $ Editor_broadcastPublication(87bd169f853965ad). (me, soundcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
660 }
661
662 static void gui_button_cb_cancelcxx . . $ gui_button_cb_cancel(418132222db43621). (SoundRecordercxx . . $ SoundRecorder# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
663 stopRecordingcxx . . $ stopRecording(2c647c0fc59fc937). (me);
664 forgetcxx . . $ `sys/Thing.h:158:9`! (me);
665 }
666
667 static void gui_button_cb_applycxx . . $ gui_button_cb_apply(418132222db43621). (SoundRecordercxx . . $ SoundRecorder# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
668 stopRecordingcxx . . $ stopRecording(2c647c0fc59fc937). (me);
669 publishcxx . . $ publish(2c647c0fc59fc937). (me);
670 }
671
672 static void gui_button_cb_okcxx . . $ gui_button_cb_ok(418132222db43621). (SoundRecordercxx . . $ SoundRecorder# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
673 stopRecordingcxx . . $ stopRecording(2c647c0fc59fc937). (me);
674 publishcxx . . $ publish(2c647c0fc59fc937). (me);
675 forgetcxx . . $ `sys/Thing.h:158:9`! (me);
676 }
677
678 static void initializecxx . . $ initialize(2c647c0fc59fc937). (SoundRecordercxx . . $ SoundRecorder# me) {
679 try {
680 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
681 #if defined (macintoshXXX)
682 my fsamps [SoundRecorder_IFSAMP_8000]. canDo = false;
683 my fsamps [SoundRecorder_IFSAMP_11025]. canDo = false;
684 my fsamps [SoundRecorder_IFSAMP_12000]. canDo = false;
685 my fsamps [SoundRecorder_IFSAMP_16000]. canDo = false;
686 my fsamps [SoundRecorder_IFSAMP_22050]. canDo = false;
687 my fsamps [SoundRecorder_IFSAMP_24000]. canDo = false;
688 my fsamps [SoundRecorder_IFSAMP_32000]. canDo = false;
689 my fsamps [SoundRecorder_IFSAMP_64000]. canDo = false;
690 #else
691 // Accept all standard sample rates.
692 (void) me;
693 #endif
694 } else {
695 #if defined (macintosh)
696 #elif defined (_WIN32)
697 (void) me;
698 #elif defined (linuxcxx . . $ `<built-in>:480:9`!) && ! defined (NO_AUDIO)
699 int sampleRate = (int) theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate., sampleSize = 16;
700 int channels = mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels., stereo = ( mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. == 2 ), val;
701 #if __BYTE_ORDERcxx . . $ `<external>/1758940242695212560/endianness.h:9:9`! == __BIG_ENDIANcxx . . $ `<external>/15579718094795539545/endian.h:31:9`!
702 int format = AFMT_S16_BE;
703 #else
704 int format = AFMT_S16_LEcxx . . $ `<external>/18058040907324014647/soundcard.h:557:10`!;
705 #endif
706 int fd_mixer;
707 mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd. = open ("/dev/dsp", O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`!);
708 if (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd. == -1) {
709 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`!)
710 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Audio device already in use.");
711 else
712 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot open audio device.\n"
713 U"Please switch on PortAudio in the Sound Recording Preferences.");
714 }
715 ioctl (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., SNDCTL_DSP_RESETcxx . . $ `<external>/18058040907324014647/soundcard.h:536:9`!, nullptr);
716 ioctl (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., SNDCTL_DSP_SPEEDcxx . . $ `<external>/18058040907324014647/soundcard.h:538:9`!, & sampleRate);
717 ioctl (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., SNDCTL_DSP_SAMPLESIZEcxx . . $ `<external>/18058040907324014647/soundcard.h:541:9`!, & sampleSize);
718 ioctl (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., SNDCTL_DSP_CHANNELScxx . . $ `<external>/18058040907324014647/soundcard.h:542:9`!, (val = channels, & val));
719 if (channels == 1 && val == 2) {
720 close (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd.);
721 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"This sound card does not support mono.");
722 }
723 ioctl (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., SNDCTL_DSP_STEREOcxx . . $ `<external>/18058040907324014647/soundcard.h:539:9`!, & stereo);
724 ioctl (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd., SNDCTL_DSP_SETFMTcxx . . $ `<external>/18058040907324014647/soundcard.h:551:9`!, & format);
725 fd_mixer = open ("/dev/mixer", O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!);
726 if (fd_mixer == -1) {
727 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot open /dev/mixer.");
728 } else {
729 int dev_mask = theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource. == 2 ? SOUND_MASK_LINEcxx . . $ `<external>/18058040907324014647/soundcard.h:821:9`! : SOUND_MASK_MICcxx . . $ `<external>/18058040907324014647/soundcard.h:822:9`!;
730 if (ioctl (fd_mixer, SOUND_MIXER_WRITE_RECSRCcxx . . $ `<external>/18058040907324014647/soundcard.h:900:9`!, & dev_mask) == -1) {
731 close (fd_mixer);
732 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Can't set recording device in mixer.");
733 }
734 close (fd_mixer);
735 }
736 #endif
737 }
738 } catch (MelderErrorcxx . . $ MelderError#) {
739 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"16-bit audio recording not initialized.");
740 }
741 }
742
743 static void gui_radiobutton_cb_inputcxx . . $ gui_radiobutton_cb_input(2c38aafc33fec274). (SoundRecordercxx . . $ SoundRecorder# me, GuiRadioButtonEventcxx . . $ GuiRadioButtonEvent# event) {
744 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"SoundRecorder:"
745 U" setting the input source from ", theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource.,
746 U" to ", event -> positioncxx . . $ structGuiRadioButtonEvent#position., U".");
747 theControlPanelcxx . . $ theControlPanel.. inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource. = event -> positioncxx . . $ structGuiRadioButtonEvent#position.;
748
749 /* Set system's input source. */
750 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
751 // deferred to the start of recording
752 } else {
753 #if defined (_WIN32)
754 // deferred to the start of recording
755 #elif defined (macintosh)
756 //SPBCloseDevice (my refNum);
757 try {
758 initialize (me);
759 } catch (MelderError) {
760 Melder_flushError ();
761 }
762 #elif defined (linuxcxx . . $ `<built-in>:480:9`!) && ! defined (NO_AUDIO)
763 int fd_mixer = open ("/dev/mixer", O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!);
764 if (fd_mixer == -1)
765 Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"(Sound_record:) Cannot open /dev/mixer.");
766 int dev_mask = theControlPanelcxx . . $ theControlPanel..inputSourcecxx . . $ $anonymous_type_e7a3ad901293445f_1#inputSource. == 2 ? SOUND_MASK_LINEcxx . . $ `<external>/18058040907324014647/soundcard.h:821:9`! : SOUND_MASK_MICcxx . . $ `<external>/18058040907324014647/soundcard.h:822:9`!;
767 if (ioctl (fd_mixer, SOUND_MIXER_WRITE_RECSRCcxx . . $ `<external>/18058040907324014647/soundcard.h:900:9`!, & dev_mask) == -1)
768 Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"(Sound_record:) Can't set recording device in mixer");
769 close (fd_mixer);
770 #endif
771 }
772 }
773
774 static void gui_radiobutton_cb_fsampcxx . . $ gui_radiobutton_cb_fsamp(2c38aafc33fec274). (SoundRecordercxx . . $ SoundRecorder# me, GuiRadioButtonEventcxx . . $ GuiRadioButtonEvent# event) {
775 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.)
776 return;
777 try {
778 double fsamp = undefinedcxx . . $ undefined.;
779 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IFSAMP_MAXcxx . . $ `foned/SoundRecorder.h:75:9`!; i ++)
780 if (event -> togglecxx . . $ structGuiRadioButtonEvent#toggle. == mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. buttoncxx . . $ SoundRecorder_Fsamp#button.)
781 fsamp = mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp.;
782 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (isdefined (fsamp));
783 /*
784 If we push the 48000 button while the sampling frequency is 22050,
785 we first get a message that the 22050 button has changed,
786 and then we get a message that the 48000 button has changed.
787 So the following will work (it used to be different with old Motif versions on Linux):
788 */
789 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"SoundRecorder:"
790 U" setting the sample rate from ", (integercxx . . $ integer#) theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.,
791 U" to ", (integercxx . . $ integer#) fsamp, U" Hz.");
792 if (fsamp == theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.)
793 return;
794 /*
795 Now we know, hopefully, that the message is from the button that was clicked,
796 not the one that was unset by the radio box, so we can take action.
797 */
798 theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate. = fsamp;
799 /*
800 Set the system's sampling frequency.
801 On some systems, we cannot do this without closing the audio device,
802 and reopening it with a new sampling frequency.
803 */
804 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
805 // deferred to the start of recording
806 } else {
807 #if defined (_WIN32)
808 // deferred to the start of recording
809 #elif defined (macintosh)
810 //SPBCloseDevice (my refNum);
811 initialize (me);
812 #elif defined (linuxcxx . . $ `<built-in>:480:9`!) && ! defined (NO_AUDIO)
813 close (mycxx . . $ `melder/melder.h:44:9`! fdcxx . . $ structSoundRecorder#fd.);
814 initializecxx . . $ initialize(2c647c0fc59fc937). (me);
815 #endif
816 }
817 } catch (MelderErrorcxx . . $ MelderError#) {
818 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sampling frequency not changed.");
819 }
820 }
821
822 static void gui_drawingarea_cb_exposecxx . . $ gui_drawingarea_cb_expose(5d01455c94325f9). (SoundRecordercxx . . $ SoundRecorder# me, GuiDrawingArea_ExposeEventcxx . . $ GuiDrawingArea_ExposeEvent# event) {
823 if (! mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics.)
824 return; // could be the case in the very beginning
825 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structSoundRecorder#recording.)
826 showMetercxx . . $ showMeter(55c0a735bf1829b7). (me, & mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1 + mycxx . . $ `melder/melder.h:44:9`! firstSamplecxx . . $ structSoundRecorder#firstSample. * mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels.], mycxx . . $ `melder/melder.h:44:9`! lastSamplecxx . . $ structSoundRecorder#lastSample. - mycxx . . $ `melder/melder.h:44:9`! firstSamplecxx . . $ structSoundRecorder#firstSample.);
827 else
828 showMetercxx . . $ showMeter(55c0a735bf1829b7). (me, nullptr, 0);
829 }
830
831 static void gui_drawingarea_cb_resizecxx . . $ gui_drawingarea_cb_resize(9bf8ca6f9c0360d4). (SoundRecordercxx . . $ SoundRecorder# me, GuiDrawingArea_ResizeEventcxx . . $ GuiDrawingArea_ResizeEvent# event) {
832 if (! mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics.)
833 return; // could be the case in the very beginning
834 Graphics_setWsViewportcxx . . $ Graphics_setWsViewport(4ffe5bb10b2fb6bd). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, event -> widthcxx . . $ structGuiDrawingArea_ResizeEvent#width., 0, event -> heightcxx . . $ structGuiDrawingArea_ResizeEvent#height.);
835 Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, event -> widthcxx . . $ structGuiDrawingArea_ResizeEvent#width., 0, event -> heightcxx . . $ structGuiDrawingArea_ResizeEvent#height.);
836 Graphics_setViewportcxx . . $ Graphics_setViewport(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, event -> widthcxx . . $ structGuiDrawingArea_ResizeEvent#width., 0, event -> heightcxx . . $ structGuiDrawingArea_ResizeEvent#height.);
837 Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
838 }
839
840 void structSoundRecordercxx . . $ structSoundRecorder# :: v_createChildrencxx . . $ structSoundRecorder#v_createChildren(49f6e7a06ebc5aa8). ()
841 {
842 /*
843 Channels.
844 */
845 #if 0
846 integer y = Machine_getMenuBarBottom () + 20;
847 GuiLabel_createShown (our windowForm, 10, 160, y, y + Gui_LABEL_HEIGHT, U"Channels:", 0);
848
849 GuiRadioGroup_begin ();
850 y += Gui_RADIOBUTTON_HEIGHT + Gui_RADIOBUTTON_SPACING;
851 our monoButton = GuiRadioButton_createShown (our windowForm, 20, 170, y, y + Gui_RADIOBUTTON_HEIGHT,
852 U"Mono", nullptr, nullptr, 0);
853 y += Gui_RADIOBUTTON_HEIGHT + Gui_RADIOBUTTON_SPACING;
854 our stereoButton = GuiRadioButton_createShown (our windowForm, 20, 170, y, y + Gui_RADIOBUTTON_HEIGHT,
855 U"Stereo", nullptr, nullptr, 0);
856 GuiRadioGroup_end ();
857 #endif
858
859 /*
860 Input source.
861 */
862 //y = Machine_getMenuBarBottom () + 140;
863 integercxx . . $ integer# y = Machine_getMenuBarBottomcxx . . $ Machine_getMenuBarBottom(b126dc7c1de90089). () + 20;
864 #if defined (_WIN32)
865 GuiLabel_createShown (our windowForm, 10, 320, y, y + Gui_LABEL_HEIGHT, U"(use Windows mixer", 0);
866 y += Gui_LABEL_HEIGHT + 10;
867 GuiLabel_createShown (our windowForm, 10, 320, y, y + Gui_LABEL_HEIGHT, U" without meters)", 0);
868 #else
869 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 10, 320, y, y + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, U"Input source:", 0);
870 GuiRadioGroup_begincxx . . $ GuiRadioGroup_begin(49f6e7a06ebc5aa8). ();
871 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IDEVICE_MAXcxx . . $ `foned/SoundRecorder.h:59:9`!; i ++) {
872 if (ourcxx . . $ `melder/melder.h:42:9`! devicescxx . . $ structSoundRecorder#devices. [i]. canDocxx . . $ SoundRecorder_Device#canDo.) {
873 y += Gui_RADIOBUTTON_HEIGHTcxx . . $ `sys/Gui.h:98:9`! + Gui_RADIOBUTTON_SPACINGcxx . . $ `sys/Gui.h:99:9`!;
874 ourcxx . . $ `melder/melder.h:42:9`! devicescxx . . $ structSoundRecorder#devices. [i]. buttoncxx . . $ SoundRecorder_Device#button. = GuiRadioButton_createShowncxx . . $ GuiRadioButton_createShown(6b1e2d4d89108d7e). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 20, 320, y, y + Gui_RADIOBUTTON_HEIGHTcxx . . $ `sys/Gui.h:98:9`!,
875 ourcxx . . $ `melder/melder.h:42:9`! devicescxx . . $ structSoundRecorder#devices. [i]. fullNamecxx . . $ SoundRecorder_Device#fullName., gui_radiobutton_cb_inputcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
876 }
877 }
878 GuiRadioGroup_endcxx . . $ GuiRadioGroup_end(49f6e7a06ebc5aa8). ();
879 #endif
880
881 /*
882 Meter box.
883 */
884 y = Machine_getMenuBarBottomcxx . . $ Machine_getMenuBarBottom(b126dc7c1de90089). () + 20;
885 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 320, -170, y, y + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, U"Meter", GuiLabel_CENTREcxx . . $ `sys/Gui.h:676:9`!);
886 y += Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!;
887 ourcxx . . $ `melder/melder.h:42:9`! metercxx . . $ structSoundRecorder#meter. = GuiDrawingArea_createShowncxx . . $ GuiDrawingArea_createShown(5a210e61ba6a237d). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 320, -170, y, -150,
888 gui_drawingarea_cb_exposecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).,
889 nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., gui_drawingarea_cb_resizecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this, GuiDrawingArea_BORDERcxx . . $ `sys/Gui.h:622:9`!
890 );
891
892 /*
893 Sampling frequency.
894 */
895 y = Machine_getMenuBarBottomcxx . . $ Machine_getMenuBarBottom(b126dc7c1de90089). () + 20;
896 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., -160, -10, y, y + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, U"Sampling frequency:", 0);
897 GuiRadioGroup_begincxx . . $ GuiRadioGroup_begin(49f6e7a06ebc5aa8). ();
898 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IFSAMP_MAXcxx . . $ `foned/SoundRecorder.h:75:9`!; i ++) {
899 if (ourcxx . . $ `melder/melder.h:42:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. canDocxx . . $ SoundRecorder_Fsamp#canDo.) {
900 double fsamp = ourcxx . . $ `melder/melder.h:42:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp.;
901 y += Gui_RADIOBUTTON_HEIGHTcxx . . $ `sys/Gui.h:98:9`! + Gui_RADIOBUTTON_SPACINGcxx . . $ `sys/Gui.h:99:9`!;
902 ourcxx . . $ `melder/melder.h:42:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. buttoncxx . . $ SoundRecorder_Fsamp#button. = GuiRadioButton_createShowncxx . . $ GuiRadioButton_createShown(6b1e2d4d89108d7e). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm.,
903 -150, -10, y, y + Gui_RADIOBUTTON_HEIGHTcxx . . $ `sys/Gui.h:98:9`!,
904 Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (fsamp == Melder_roundDowncxx . . $ Melder_roundDown(447c67c6676f75c3). (fsamp) ? Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). ((integercxx . . $ integer#) fsamp) : Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (fsamp, 5), U" Hz"),
905 gui_radiobutton_cb_fsampcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, fsamp == theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate. ? GuiRadioButton_SETcxx . . $ `sys/Gui.h:1006:9`! : 0
906 );
907 }
908 }
909 GuiRadioGroup_endcxx . . $ GuiRadioGroup_end(49f6e7a06ebc5aa8). ();
910
911 ourcxx . . $ `melder/melder.h:42:9`! progressScalecxx . . $ structSoundRecorder#progressScale. = GuiScale_createShowncxx . . $ GuiScale_createShown(daad5ee70c84b419). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm.,
912 10, -10, -130, -90,
913 0, 1000, 0, 0);
914
915 y = 60;
916 ourcxx . . $ `melder/melder.h:42:9`! recordButtoncxx . . $ structSoundRecorder#recordButton. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 20, 90, -y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, -y,
917 U"Record", gui_button_cb_recordcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
918 ourcxx . . $ `melder/melder.h:42:9`! stopButtoncxx . . $ structSoundRecorder#stopButton. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 100, 170, -y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, -y,
919 U"Stop", gui_button_cb_stopcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
920 if (inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
921 ourcxx . . $ `melder/melder.h:42:9`! playButtoncxx . . $ structSoundRecorder#playButton. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 180, 250, -y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, -y,
922 U"Play", gui_button_cb_playcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
923 } else {
924 #if defined (_WIN32) || defined (macintosh)
925 our playButton = GuiButton_createShown (our windowForm, 180, 250, -y - Gui_PUSHBUTTON_HEIGHT, -y,
926 U"Play", gui_button_cb_play, this, 0);
927 #endif
928 }
929
930 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., -200, -130, -y - 2 - Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`!, -y - 2, U"Name:", GuiLabel_RIGHTcxx . . $ `sys/Gui.h:677:9`!);
931 ourcxx . . $ `melder/melder.h:42:9`! soundNamecxx . . $ structSoundRecorder#soundName. = GuiText_createShowncxx . . $ GuiText_createShown(8bcb1f2be7fc31ee). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., -120, -20, -y - 2 - Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`!, -y - 2, 0);
932 GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (ourcxx . . $ `melder/melder.h:42:9`! soundNamecxx . . $ structSoundRecorder#soundName., U"untitled");
933
934 y = 20;
935 ourcxx . . $ `melder/melder.h:42:9`! cancelButtoncxx . . $ structSoundRecorder#cancelButton. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., -350, -280, -y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, -y,
936 U"Close", gui_button_cb_cancelcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
937 ourcxx . . $ `melder/melder.h:42:9`! applyButtoncxx . . $ structSoundRecorder#applyButton. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., -270, -170, -y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, -y,
938 U"Save to list", gui_button_cb_applycxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, GuiButton_DEFAULTcxx . . $ `sys/Gui.h:467:9`!);
939 ourcxx . . $ `melder/melder.h:42:9`! okButtoncxx . . $ structSoundRecorder#okButton. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., -160, -20, -y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, -y,
940 U"Save to list & Close", gui_button_cb_okcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
941 }
942
943 static void writeAudioFilecxx . . $ writeAudioFile(fae792b0a2614d9f). (SoundRecordercxx . . $ SoundRecorder# me, MelderFilecxx . . $ MelderFile# file, int audioFileType) {
944 try {
945 MelderFile_writeAudioFilecxx . . $ MelderFile_writeAudioFile(fd83def75f2cb3f1). (file, audioFileType, mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer..asArgumentToFunctionThatExpectsZeroBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsZeroBasedArray(5a2a78a048fb49a8).(),
946 Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (theControlPanelcxx . . $ theControlPanel.. sampleRatecxx . . $ $anonymous_type_e7a3ad901293445f_1#sampleRate.), mycxx . . $ `melder/melder.h:44:9`! nsampcxx . . $ structSoundRecorder#nsamp., mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels., 16);
947 } catch (MelderErrorcxx . . $ MelderError#) {
948 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Audio file not written.");
949 }
950 }
951
952 static void menu_cb_writeWavcxx . . $ menu_cb_writeWav(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
953 EDITOR_FORM_SAVEcxx . . $ `sys/EditorM.h:489:9`! (U"Save as WAV file", nullptr)
954 autostring32cxx . . $ autostring32# name = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! soundNamecxx . . $ structSoundRecorder#soundName.);
955 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (defaultName,300, name.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U".wav");
956 EDITOR_DO_SAVEcxx . . $ `sys/EditorM.h:493:9`!
957 writeAudioFilecxx . . $ writeAudioFile(fae792b0a2614d9f). (me, file, Melder_WAVcxx . . $ `melder/melder_audiofiles.h:26:9`!);
958 EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`!
959 }
960
961 static void menu_cb_writeAifccxx . . $ menu_cb_writeAifc(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
962 EDITOR_FORM_SAVEcxx . . $ `sys/EditorM.h:489:9`! (U"Save as AIFC file", nullptr)
963 autostring32cxx . . $ autostring32# name = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! soundNamecxx . . $ structSoundRecorder#soundName.);
964 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (defaultName,300, name.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U".aifc");
965 EDITOR_DO_SAVEcxx . . $ `sys/EditorM.h:493:9`!
966 writeAudioFilecxx . . $ writeAudioFile(fae792b0a2614d9f). (me, file, Melder_AIFCcxx . . $ `melder/melder_audiofiles.h:25:9`!);
967 EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`!
968 }
969
970 static void menu_cb_writeNextSuncxx . . $ menu_cb_writeNextSun(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
971 EDITOR_FORM_SAVEcxx . . $ `sys/EditorM.h:489:9`! (U"Save as NeXT/Sun file", nullptr)
972 autostring32cxx . . $ autostring32# name = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! soundNamecxx . . $ structSoundRecorder#soundName.);
973 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (defaultName,300, name.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U".au");
974 EDITOR_DO_SAVEcxx . . $ `sys/EditorM.h:493:9`!
975 writeAudioFilecxx . . $ writeAudioFile(fae792b0a2614d9f). (me, file, Melder_NEXT_SUNcxx . . $ `melder/melder_audiofiles.h:27:9`!);
976 EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`!
977 }
978
979 static void menu_cb_writeNistcxx . . $ menu_cb_writeNist(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
980 EDITOR_FORM_SAVEcxx . . $ `sys/EditorM.h:489:9`! (U"Save as NIST file", nullptr)
981 autostring32cxx . . $ autostring32# name = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! soundNamecxx . . $ structSoundRecorder#soundName.);
982 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (defaultName,300, name.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U".nist");
983 EDITOR_DO_SAVEcxx . . $ `sys/EditorM.h:493:9`!
984 writeAudioFilecxx . . $ writeAudioFile(fae792b0a2614d9f). (me, file, Melder_NISTcxx . . $ `melder/melder_audiofiles.h:28:9`!);
985 EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`!
986 }
987
988 static void updateMenuscxx . . $ updateMenus(2c647c0fc59fc937). (SoundRecordercxx . . $ SoundRecorder# me) {
989 GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! meterIntensityButtoncxx . . $ structSoundRecorder#meterIntensityButton.,
990 mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_whichcxx . . $ structSoundRecorder#instancePref_meter_which(c9ba0948ac0163b5).() == kSoundRecorder_meter::INTENSITY);
991 GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! meterCentreOfGravityVersusIntensityButtoncxx . . $ structSoundRecorder#meterCentreOfGravityVersusIntensityButton.,
992 mycxx . . $ `melder/melder.h:44:9`! instancePref_meter_whichcxx . . $ structSoundRecorder#instancePref_meter_which(c9ba0948ac0163b5).() == kSoundRecorder_meter::CENTRE_OF_GRAVITY_VERSUS_INTENSITY);
993 }
994
995 static void menu_cb_intensitycxx . . $ menu_cb_intensity(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
996 mycxx . . $ `melder/melder.h:44:9`! setInstancePref_meter_whichcxx . . $ structSoundRecorder#setInstancePref_meter_which(eea26161fe6fdc21). (kSoundRecorder_meter::INTENSITY);
997 updateMenuscxx . . $ updateMenus(2c647c0fc59fc937). (me);
998 }
999 static void menu_cb_centreOfGravityVersusIntensitycxx . . $ menu_cb_centreOfGravityVersusIntensity(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
1000 mycxx . . $ `melder/melder.h:44:9`! setInstancePref_meter_whichcxx . . $ structSoundRecorder#setInstancePref_meter_which(eea26161fe6fdc21). (kSoundRecorder_meter::CENTRE_OF_GRAVITY_VERSUS_INTENSITY);
1001 updateMenuscxx . . $ updateMenus(2c647c0fc59fc937). (me);
1002 }
1003
1004 static void menu_cb_SoundRecorder_helpcxx . . $ menu_cb_SoundRecorder_help(1b7cc360bdfad1a4). (SoundRecordercxx . . $ SoundRecorder#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"SoundRecorder"); }
1005
1006 void structSoundRecordercxx . . $ structSoundRecorder# :: v_createMenuscxx . . $ structSoundRecorder#v_createMenus(49f6e7a06ebc5aa8). () {
1007 SoundRecorder_Parentcxx . . $ SoundRecorder_Parent# :: v_createMenuscxx . . $ structEditor#v_createMenus(49f6e7a06ebc5aa8). ();
1008 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save as WAV file...", 0, menu_cb_writeWavcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1009 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save as AIFC file...", 0, menu_cb_writeAifccxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1010 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save as NeXT/Sun file...", 0, menu_cb_writeNextSuncxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1011 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save as NIST file...", 0, menu_cb_writeNistcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1012 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"-- write --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).);
1013 Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (this, U"Meter", 0);
1014 ourcxx . . $ `melder/melder.h:42:9`! meterIntensityButtoncxx . . $ structSoundRecorder#meterIntensityButton. =
1015 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Meter", U"Intensity", GuiMenu_RADIO_FIRSTcxx . . $ `sys/Gui.h:857:9`!, menu_cb_intensitycxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1016 ourcxx . . $ `melder/melder.h:42:9`! meterCentreOfGravityVersusIntensityButtoncxx . . $ structSoundRecorder#meterCentreOfGravityVersusIntensityButton. =
1017 Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Meter", U"Centre of gravity ~ intensity", GuiMenu_RADIO_NEXTcxx . . $ `sys/Gui.h:858:9`!, menu_cb_centreOfGravityVersusIntensitycxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1018 }
1019
1020 void structSoundRecordercxx . . $ structSoundRecorder# :: v_createMenuItems_helpcxx . . $ structSoundRecorder#v_createMenuItems_help(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu) {
1021 SoundRecorder_Parentcxx . . $ SoundRecorder_Parent# :: v_createMenuItems_helpcxx . . $ structDataGui#v_createMenuItems_help(6ea9c8c6ea2f58a9). (menu);
1022 EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"SoundRecorder help", '?', menu_cb_SoundRecorder_helpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
1023 }
1024
1025 autoSoundRecordercxx . . $ autoSoundRecorder# SoundRecorder_createcxx . . $ SoundRecorder_create(7cf06c42999cac48). (int numberOfChannels) {
1026 try {
1027 autoSoundRecordercxx . . $ autoSoundRecorder# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (SoundRecorder);
1028 mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio. =
1029 #if defined (_WIN32)
1030 MelderAudio_getInputSoundSystem () == kMelder_inputSoundSystem::MME_VIA_PORTAUDIO;
1031 #elif defined (macintosh)
1032 MelderAudio_getInputSoundSystem () == kMelder_inputSoundSystem::COREAUDIO_VIA_PORTAUDIO;
1033 #elif defined (raspberrypi)
1034 MelderAudio_getInputSoundSystem () == kMelder_inputSoundSystem::JACK_VIA_PORTAUDIO;
1035 #else
1036 MelderAudio_getInputSoundSystemcxx . . $ MelderAudio_getInputSoundSystem(b002a9b809d5560e). () == kMelder_inputSoundSystemcxx . . $ kMelder_inputSoundSystem#::ALSA_OR_JACK_VIA_PORTAUDIOcxx . . $ kMelder_inputSoundSystem#ALSA_OR_JACK_VIA_PORTAUDIO.;
1037 #endif
1038
1039 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
1040 } else {
1041 #if defined (_WIN32)
1042 UINT numberOfDevices = waveInGetNumDevs ();
1043 if (numberOfDevices == 0)
1044 Melder_throw (U"No sound input devices available.");
1045 WAVEINCAPS caps;
1046 MMRESULT err = waveInGetDevCaps (WAVE_MAPPER, & caps, sizeof (WAVEINCAPS));
1047 if (numberOfChannels == 2 && caps. wChannels < 2)
1048 Melder_throw (U"Your computer does not support stereo sound input.");
1049 /* BUG: should we ask whether 16 bit is supported? */
1050 for (UINT i = 0; i < numberOfDevices; i ++) {
1051 waveInGetDevCaps (i, & caps, sizeof (WAVEINCAPS));
1052 /*Melder_casual (U"Name of device ", i, U": ", Melder_peek16to32 (aps. szPname));*/
1053 }
1054 #elif defined (macintosh)
1055 SInt32 soundFeatures;
1056 if (Gestalt (gestaltSoundAttr, & soundFeatures) ||
1057 ! (soundFeatures & (1 << gestaltSoundIOMgrPresent)) ||
1058 ! (soundFeatures & (1 << gestaltBuiltInSoundInput)) ||
1059 ! (soundFeatures & (1 << gestaltHasSoundInputDevice)))
1060 Melder_throw (U"Your computer does not support sound input.");
1061 if (! (soundFeatures & (1 << gestalt16BitSoundIO)) || // hardware
1062 ! (soundFeatures & (1 << gestaltStereoInput)) || // hardware
1063 ! (soundFeatures & (1 << gestalt16BitAudioSupport))) // software
1064 Melder_throw (U"Your computer does not support stereo sound input.");
1065 #endif
1066 }
1067 mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structSoundRecorder#numberOfChannels. = numberOfChannels;
1068 if (sizeof (short) != 2)
1069 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Long shorts!!!!!");
1070 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
1071 mycxx . . $ `melder/melder.h:44:9`! synchronouscxx . . $ structSoundRecorder#synchronous. = false;
1072 } else {
1073 #if defined (macintosh) || defined (_WIN32)
1074 my synchronous = false;
1075 #else
1076 mycxx . . $ `melder/melder.h:44:9`! synchronouscxx . . $ structSoundRecorder#synchronous. = true;
1077 #endif
1078 }
1079 /*
1080 Allocate the maximum buffer.
1081 */
1082 Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & preferencescxx . . $ preferences..bufferSizeInMegabytescxx . . $ $anonymous_type_e7a3ad901293445f_0#bufferSizeInMegabytes., 1000_integercxx . . $ `operator""_integer`(85240eb457c3721a).);
1083 if (NUMisEmptycxx . . $ NUMisEmpty(3c471b8d64252e9b). (mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer..getcxx . . $ autovector#get(e8d1da7fe68a6585).())) {
1084 integercxx . . $ integer# nmax_bytes_pref = preferencescxx . . $ preferences..bufferSizeInMegabytescxx . . $ $anonymous_type_e7a3ad901293445f_0#bufferSizeInMegabytes. * 1000000;
1085 integercxx . . $ integer# nmax_bytes = ( mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio. ? nmax_bytes_pref :
1086 #if defined (_WIN32)
1087 66150000 ); // the maximum physical buffer on Windows XP; shorter than in Windows 98, alas.
1088 #else
1089 nmax_bytes_pref );
1090 #endif
1091 mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax. = nmax_bytes / (sizeof (short) * numberOfChannels);
1092 for (;;) {
1093 try {
1094 mycxx . . $ `melder/melder.h:44:9`! recordBuffercxx . . $ structSoundRecorder#recordBuffer. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <short> (mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax. * numberOfChannels);
1095 break; // success
1096 } catch (MelderErrorcxx . . $ MelderError#) {
1097 if (mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax. < 100000) {
1098 throw; // failure, with error message
1099 } else {
1100 Melder_clearErrorcxx . . $ Melder_clearError(49f6e7a06ebc5aa8). ();
1101 mycxx . . $ `melder/melder.h:44:9`! nmaxcxx . . $ structSoundRecorder#nmax. /= 2; // retry with less application memory
1102 }
1103 }
1104 }
1105 }
1106
1107 /*
1108 Count the number of input devices and sources.
1109 */
1110 if (mycxx . . $ `melder/melder.h:44:9`! inputUsesPortAudiocxx . . $ structSoundRecorder#inputUsesPortAudio.) {
1111 if (! MelderAudio_hasBeenInitializedcxx . . $ MelderAudio_hasBeenInitialized.) {
1112 PaError err = Pa_Initialize ();
1113 if (Melder_debugcxx . . $ Melder_debug. == 20)
1114 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"init ", Melder_peek8to32_u (Pa_GetErrorText (err)));
1115 MelderAudio_hasBeenInitializedcxx . . $ MelderAudio_hasBeenInitialized. = true;
1116 if (Melder_debugcxx . . $ Melder_debug. == 20) {
1117 PaHostApiIndex hostApiCount = Pa_GetHostApiCount ();
1118 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"host API count ", hostApiCount);
1119 for (PaHostApiIndex iHostApi = 0; iHostApi < hostApiCount; iHostApi ++) {
1120 const PaHostApiInfo *hostApiInfo = Pa_GetHostApiInfo (iHostApi);
1121 PaHostApiTypeId type = hostApiInfo -> type;
1122 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"host API ", iHostApi, U": ", type, U", \"", Melder_peek8to32_u (hostApiInfo -> name), U"\" ", hostApiInfo -> deviceCount);
1123 }
1124 PaHostApiIndex defaultHostApi = Pa_GetDefaultHostApi ();
1125 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"default host API ", defaultHostApi);
1126 PaDeviceIndex deviceCount = Pa_GetDeviceCount ();
1127 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"device count ", deviceCount);
1128 }
1129 }
1130 PaDeviceIndex deviceCount = Pa_GetDeviceCount ();
1131 for (PaDeviceIndex idevice = 0; idevice < deviceCount; idevice ++) {
1132 const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo (idevice);
1133 if (Melder_debugcxx . . $ Melder_debug. == 20)
1134 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (
1135 U"Device \"", Melder_peek8to32_u (deviceInfo -> name),
1136 U"\", input ", deviceInfo -> maxInputChannels,
1137 U", output ", deviceInfo -> maxOutputChannels,
1138 U", sample rate ", deviceInfo -> defaultSampleRate
1139 );
1140 if (deviceInfo -> maxInputChannels > 0 && mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices. < SoundRecorder_IDEVICE_MAXcxx . . $ `foned/SoundRecorder.h:59:9`!) {
1141 mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [++ mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices.]. canDocxx . . $ SoundRecorder_Device#canDo. = true;
1142 #if defined (macintosh) || defined (_WIN32) // only one host API
1143 str32ncpy (my devices [my numberOfInputDevices]. fullName, Melder_peek8to32_u (deviceInfo -> name), SoundRecorder_Device :: maximumLengthOfFullName);
1144 #else
1145 const PaHostApiIndex hostApiIndex = deviceInfo -> hostApi;
1146 const PaHostApiInfo * const hostApiInfo = Pa_GetHostApiInfo (hostApiIndex);
1147 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (hostApiInfo);
1148 const conststring8cxx . . $ conststring8# shortHostApiName8 = ( strstr (hostApiInfo -> name, "JACK") == hostApiInfo -> name ? "JACK" : hostApiInfo -> name );
1149 str32ncpycxx . . $ str32ncpy(a0fb29e7f5bbd1dc). (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices.]. fullNamecxx . . $ SoundRecorder_Device#fullName.,
1150 Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"(", Melder_peek8to32_u (shortHostApiName8), U":) ", Melder_peek8to32_u (deviceInfo -> name)),
1151 SoundRecorder_Devicecxx . . $ SoundRecorder_Device# :: maximumLengthOfFullNamecxx . . $ SoundRecorder_Device#maximumLengthOfFullName.
1152 );
1153 #endif
1154 mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices.]. fullNamecxx . . $ SoundRecorder_Device#fullName. [SoundRecorder_Devicecxx . . $ SoundRecorder_Device# :: maximumLengthOfFullNamecxx . . $ SoundRecorder_Device#maximumLengthOfFullName.] = U'\0';
1155 mycxx . . $ `melder/melder.h:44:9`! deviceInfoscxx . . $ structSoundRecorder#deviceInfos. [mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices.] = deviceInfo;
1156 mycxx . . $ `melder/melder.h:44:9`! deviceIndicescxx . . $ structSoundRecorder#deviceIndices. [mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices.] = idevice;
1157 }
1158 }
1159 if (mycxx . . $ `melder/melder.h:44:9`! numberOfInputDevicescxx . . $ structSoundRecorder#numberOfInputDevices. == 0)
1160 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No input devices available.");
1161 } else {
1162 #if defined (macintosh)
1163 #elif defined (_WIN32)
1164 // No device info: use Windows mixer.
1165 #else
1166 mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [1]. canDocxx . . $ SoundRecorder_Device#canDo. = true;
1167 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [1]. fullNamecxx . . $ SoundRecorder_Device#fullName., U"Microphone");
1168 mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [2]. canDocxx . . $ SoundRecorder_Device#canDo. = true;
1169 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! devicescxx . . $ structSoundRecorder#devices. [2]. fullNamecxx . . $ SoundRecorder_Device#fullName., U"Line");
1170 #endif
1171 }
1172
1173 /*
1174 Sampling frequency constants.
1175 */
1176 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_8000cxx . . $ `foned/SoundRecorder.h:61:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 8000.0;
1177 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_9800cxx . . $ `foned/SoundRecorder.h:62:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 9800.0;
1178 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_11025cxx . . $ `foned/SoundRecorder.h:63:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 11025.0;
1179 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_12000cxx . . $ `foned/SoundRecorder.h:64:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 12000.0;
1180 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_16000cxx . . $ `foned/SoundRecorder.h:65:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 16000.0;
1181 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_22050cxx . . $ `foned/SoundRecorder.h:66:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 22050.0;
1182 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_22254cxx . . $ `foned/SoundRecorder.h:67:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 22254.54545;
1183 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_24000cxx . . $ `foned/SoundRecorder.h:68:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 24000.0;
1184 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_32000cxx . . $ `foned/SoundRecorder.h:69:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 32000.0;
1185 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_44100cxx . . $ `foned/SoundRecorder.h:70:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 44100.0;
1186 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_48000cxx . . $ `foned/SoundRecorder.h:71:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 48000.0;
1187 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_64000cxx . . $ `foned/SoundRecorder.h:72:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 64000.0;
1188 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_96000cxx . . $ `foned/SoundRecorder.h:73:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 96000.0;
1189 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_192000cxx . . $ `foned/SoundRecorder.h:74:9`!]. fsampcxx . . $ SoundRecorder_Fsamp#fsamp. = 192000.0;
1190
1191 /*
1192 The default set of possible sampling frequencies, to be modified in the initialize () procedure.
1193 */
1194 for (integercxx . . $ integer# i = 1; i <= SoundRecorder_IFSAMP_MAXcxx . . $ `foned/SoundRecorder.h:75:9`!; i ++)
1195 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [i]. canDocxx . . $ SoundRecorder_Fsamp#canDo. = true; // optimistic: can do all, except two:
1196 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_9800cxx . . $ `foned/SoundRecorder.h:62:9`!]. canDocxx . . $ SoundRecorder_Fsamp#canDo. = false; // sgi only
1197 mycxx . . $ `melder/melder.h:44:9`! fsampscxx . . $ structSoundRecorder#fsamps. [SoundRecorder_IFSAMP_22254cxx . . $ `foned/SoundRecorder.h:67:9`!]. canDocxx . . $ SoundRecorder_Fsamp#canDo. = false; // old Mac only
1198
1199 /*
1200 Initialize system-dependent structures.
1201 On all systems: stereo 16-bit linear encoding.
1202 Some systems take initial values from the system control panel
1203 (automatically in the workProc), other systems from theControlPanel.
1204 */
1205 initializecxx . . $ initialize(2c647c0fc59fc937). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
1206
1207 autoMelderStringcxx . . $ autoMelderString# titlecxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
1208 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& title, U"SoundRecorder (", ( numberOfChannels == 1 ? U"mono" : U"stereo" ), U")");
1209 Editor_initcxx . . $ Editor_init(13f379e38ac41ed6). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 100, 100, 800, 600, title.stringcxx . . $ MelderString#string., nullptr);
1210 mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structSoundRecorder#graphics. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Graphics_create_xmdrawingareacxx . . $ Graphics_create_xmdrawingarea(51b1c75797a7dddf). (mycxx . . $ `melder/melder.h:44:9`! metercxx . . $ structSoundRecorder#meter.);
1211 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! graphics);
1212
1213 struct structGuiDrawingArea_ResizeEventcxx . . $ structGuiDrawingArea_ResizeEvent# event { mycxx . . $ `melder/melder.h:44:9`! metercxx . . $ structSoundRecorder#meter., 0 };
1214 event. widthcxx . . $ structGuiDrawingArea_ResizeEvent#width. = GuiControl_getWidthcxx . . $ GuiControl_getWidth(1227891e76fac374). (mycxx . . $ `melder/melder.h:44:9`! metercxx . . $ structSoundRecorder#meter.);
1215 event. heightcxx . . $ structGuiDrawingArea_ResizeEvent#height. = GuiControl_getHeightcxx . . $ GuiControl_getHeight(1227891e76fac374). (mycxx . . $ `melder/melder.h:44:9`! metercxx . . $ structSoundRecorder#meter.);
1216 gui_drawingarea_cb_resizecxx . . $ gui_drawingarea_cb_resize(9bf8ca6f9c0360d4). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), & event);
1217
1218 #if cocoacxx . . $ `sys/Gui.h:35:10`!
1219 CFRunLoopTimerContext context = { 0, me.get(), nullptr, nullptr, nullptr };
1220 my d_cocoaTimer = CFRunLoopTimerCreate (nullptr, CFAbsoluteTimeGetCurrent () + 0.02,
1221 0.02, 0, 0, workProc, & context);
1222 CFRunLoopAddTimer (CFRunLoopGetCurrent (), my d_cocoaTimer, kCFRunLoopCommonModes);
1223 #elif gtkcxx . . $ `sys/Gui.h:33:10`!
1224 g_idle_add (workProccxx . . $ workProc(dedf1e9b1c614a07)., me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
1225 #elif motif
1226 my workProcId = XtAddWorkProc (workProc, me.get());
1227 #endif
1228 updateMenuscxx . . $ updateMenus(2c647c0fc59fc937). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
1229 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
1230 } catch (MelderErrorcxx . . $ MelderError#) {
1231 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"SoundRecorder not created.");
1232 }
1233 }
1234
1235 /* End of file SoundRecorder.cpp */