speaker-calibration 2.2.160 → 2.2.162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/.eslintignore +71 -71
  2. package/.eslintrc.json +40 -40
  3. package/.github/workflows/update-phrases.yml +37 -0
  4. package/.prettierignore +69 -69
  5. package/.prettierrc +14 -14
  6. package/LICENSE +20 -20
  7. package/README.md +133 -133
  8. package/__mocks__/fileMock.js +1 -1
  9. package/__mocks__/styleMock.js +1 -1
  10. package/babel.config.js +3 -3
  11. package/coverage/clover.xml +71 -71
  12. package/coverage/coverage-final.json +224 -224
  13. package/coverage/lcov-report/PythonServerInterface.js.html +265 -265
  14. package/coverage/lcov-report/base.css +354 -354
  15. package/coverage/lcov-report/block-navigation.js +82 -82
  16. package/coverage/lcov-report/index.html +123 -123
  17. package/coverage/lcov-report/prettify.css +101 -101
  18. package/coverage/lcov-report/prettify.js +937 -937
  19. package/coverage/lcov-report/sorter.js +189 -189
  20. package/coverage/lcov-report/src/index.html +121 -121
  21. package/coverage/lcov-report/src/server/PythonServerInterface.js.html +268 -268
  22. package/coverage/lcov-report/src/server/index.html +123 -123
  23. package/coverage/lcov-report/src/tasks/audioCalibrator.js.html +499 -499
  24. package/coverage/lcov-report/src/tasks/audioRecorder.js.html +412 -412
  25. package/coverage/lcov-report/src/tasks/index.html +143 -143
  26. package/coverage/lcov-report/src/tasks/volume/index.html +123 -123
  27. package/coverage/lcov-report/src/tasks/volume/volume.js.html +409 -409
  28. package/coverage/lcov-report/src/utils.js.html +172 -172
  29. package/coverage/lcov.info +91 -91
  30. package/dist/example/credentials.json.gpg +0 -0
  31. package/dist/example/fetch-languages-sheets.js +77 -77
  32. package/dist/example/i18n.js +23984 -35693
  33. package/dist/example/index.html +47 -47
  34. package/dist/example/listener.html +62 -62
  35. package/dist/example/listener.js +132 -132
  36. package/dist/example/server.js +51 -51
  37. package/dist/example/speaker.html +145 -145
  38. package/dist/example/speakerUI.js +273 -273
  39. package/dist/example/styles.css +96 -92
  40. package/dist/main.js +17 -17
  41. package/dist/mlsGen.js +6814 -6814
  42. package/dist/mlsGen.wasm +0 -0
  43. package/dist/package-lock.json +1018 -1018
  44. package/dist/package.json +18 -18
  45. package/doc/AudioCalibrator.html +417 -417
  46. package/doc/AudioPeer.html +251 -251
  47. package/doc/AudioRecorder.html +195 -195
  48. package/doc/ImpulseResponse.html +215 -215
  49. package/doc/Listener.html +308 -308
  50. package/doc/MlsGenInterface.html +226 -226
  51. package/doc/MyEventEmitter.html +274 -274
  52. package/doc/PythonServerAPI.html +109 -109
  53. package/doc/Speaker.html +276 -276
  54. package/doc/Takes%20a%20target%20element%20where%20html%20elements%20will%20be%20appended..html +128 -128
  55. package/doc/Takes%20the%20url%20of%20the%20current%20site%0Aand%20a%20target%20element%20where%20html%20elements%20will%20be%20appended..html +138 -138
  56. package/doc/Takes%20the%20url%20of%20the%20current%20site%20and%20a%20target%20element%20where%20html%20elements%20will%20be%20appended..html +137 -137
  57. package/doc/Volume.html +88 -88
  58. package/doc/audioCalibrator.js.html +179 -179
  59. package/doc/audioPeer.js.html +175 -175
  60. package/doc/audioRecorder.js.html +163 -163
  61. package/doc/creates%20a%20new%20AudioRecorder%20instance.%20%0ASets%20up%20the%20audio%20context%20and%20file%20reader..html +114 -114
  62. package/doc/fonts/OpenSans-Bold-webfont.svg +1829 -1829
  63. package/doc/fonts/OpenSans-BoldItalic-webfont.svg +1829 -1829
  64. package/doc/fonts/OpenSans-Italic-webfont.svg +1829 -1829
  65. package/doc/fonts/OpenSans-Light-webfont.svg +1830 -1830
  66. package/doc/fonts/OpenSans-LightItalic-webfont.svg +1834 -1834
  67. package/doc/fonts/OpenSans-Regular-webfont.svg +1830 -1830
  68. package/doc/global.html +308 -308
  69. package/doc/index.html +58 -58
  70. package/doc/listener.js.html +170 -170
  71. package/doc/mlsGen_mlsGenInterface.js.html +117 -117
  72. package/doc/myEventEmitter.js.html +124 -124
  73. package/doc/peer-connection_audioPeer.js.html +188 -188
  74. package/doc/peer-connection_listener.js.html +311 -311
  75. package/doc/peer-connection_speaker.js.html +381 -381
  76. package/doc/scripts/linenumber.js +25 -25
  77. package/doc/scripts/prettify/Apache-License-2.0.txt +202 -202
  78. package/doc/scripts/prettify/lang-css.js +24 -24
  79. package/doc/scripts/prettify/prettify.js +640 -640
  80. package/doc/server_PythonServerAPI.js.html +160 -160
  81. package/doc/speaker.js.html +248 -248
  82. package/doc/styles/jsdoc-default.css +371 -371
  83. package/doc/styles/prettify-jsdoc.css +111 -111
  84. package/doc/styles/prettify-tomorrow.css +163 -163
  85. package/doc/tasks_audioCalibrator.js.html +207 -207
  86. package/doc/tasks_audioRecorder.js.html +190 -190
  87. package/doc/tasks_impulse-response_impulseResponse.js.html +442 -442
  88. package/doc/tasks_impulse-response_mlsGen_mlsGenInterface.js.html +175 -175
  89. package/doc/tasks_volume_volume.js.html +185 -185
  90. package/doc/utils.js.html +105 -105
  91. package/jest.config.js +173 -173
  92. package/makefile +74 -0
  93. package/netlify.toml +26 -26
  94. package/package.json +71 -69
  95. package/src/config/firebase.js +26 -26
  96. package/src/index.html +21 -21
  97. package/src/main.js +23 -23
  98. package/src/myEventEmitter.js +83 -83
  99. package/src/peer-connection/audioPeer.js +178 -151
  100. package/src/peer-connection/listener.js +338 -338
  101. package/src/peer-connection/peerErrors.js +25 -25
  102. package/src/peer-connection/speaker.js +574 -550
  103. package/src/server/PythonServerAPI.js +796 -796
  104. package/src/tasks/audioCalibrator.js +323 -323
  105. package/src/tasks/audioRecorder.js +315 -315
  106. package/src/tasks/combination/combination.js +2901 -2901
  107. package/src/tasks/combination/mlsGen/mlsGen.cpp +98 -98
  108. package/src/tasks/combination/mlsGen/mlsGen.hpp +303 -303
  109. package/src/tasks/combination/mlsGen/mlsGenInterface.js +131 -131
  110. package/src/tasks/combination/mlsGen/mlsGenTest.cpp +180 -180
  111. package/src/tasks/impulse-response/impulseResponse.js +610 -610
  112. package/src/tasks/impulse-response/mlsGen/mlsGen.cpp +98 -98
  113. package/src/tasks/impulse-response/mlsGen/mlsGen.hpp +303 -303
  114. package/src/tasks/impulse-response/mlsGen/mlsGenInterface.js +131 -131
  115. package/src/tasks/impulse-response/mlsGen/mlsGenTest.cpp +180 -180
  116. package/src/tasks/volume/volume.cpp +2 -2
  117. package/src/tasks/volume/volume.hpp +22 -22
  118. package/src/tasks/volume/volume.js +279 -279
  119. package/src/utils.js +135 -135
  120. package/webpack.config.js +37 -37
  121. package/.gitignore +0 -81
@@ -1,550 +1,574 @@
1
- import QRCode from 'qrcode';
2
- import AudioPeer from './audioPeer';
3
- import {sleep} from '../utils';
4
- import {
5
- UnsupportedDeviceError,
6
- MissingSpeakerIdError,
7
- CalibrationTimedOutError,
8
- } from './peerErrors';
9
-
10
- import {phrases} from '../../dist/example/i18n';
11
-
12
- /**
13
- * @class Handles the speaker's side of the connection. Responsible for initiating the connection,
14
- * rendering the QRCode, and answering the call.
15
- * @augments AudioPeer
16
- */
17
- class Speaker extends AudioPeer {
18
- /**
19
- * Takes the url of the current site and a target element where html elements will be appended.
20
- *
21
- * @param params - See type definition for initParameters.
22
- * @param Calibrator - An instance of the AudioCalibrator class, should not use AudioCalibrator directly, instead use an extended class available in /tasks/.
23
- * @param CalibratorInstance
24
- * @example
25
- */
26
- constructor(params, CalibratorInstance) {
27
- super(params);
28
- this.language = params?.language ?? 'en-US';
29
- this.siteUrl += '/listener?';
30
- this.ac = CalibratorInstance;
31
- this.result = null;
32
- this.debug = params?.debug ?? false;
33
- this.isSmartPhone = params?.isSmartPhone ?? false;
34
- this.calibrateSoundHz = params?.calibrateSoundHz ?? 48000;
35
- this.calibrateSoundSamplingDesiredBits = params?.calibrateSoundSamplingDesiredBits ?? 24;
36
- this.instructionDisplayId = params?.instructionDisplayId ?? '';
37
- this.soundSubtitleId = params?.soundSubtitleId ?? '';
38
- this.timeToCalibrateDisplay = params?.timeToCalibrateId ?? '';
39
- this.soundMessageId = params?.soundMessageId ?? '';
40
- this.titleDisplayId = params?.titleDisplayId ?? '';
41
- this.timeToCalibrate = params?.timeToCalibrate ?? 10;
42
-
43
- /* Set up callbacks that handle any events related to our peer object. */
44
- this.peer.on('open', this.#onPeerOpen);
45
- this.peer.on('connection', this.#onPeerConnection);
46
- this.peer.on('close', this.onPeerClose);
47
- this.peer.on('disconnected', this.#onPeerDisconnected);
48
- this.peer.on('error', this.#onPeerError);
49
- }
50
- /**
51
- * Async factory method that creates the Speaker object, and returns a promise that resolves to the result of the calibration.
52
- *
53
- * @param params - The parameters to be passed to the peer object.
54
- * @param Calibrator - The class that defines the calibration process.
55
- * @param CalibratorInstance
56
- * @param timeOut - The amount of time to wait before timing out the connection (in milliseconds).
57
- * @public
58
- * @example
59
- */
60
- static startCalibration = async (params, CalibratorInstance, timeOut = 180000) => {
61
- window.speaker = new Speaker(params, CalibratorInstance);
62
- const {speaker} = window;
63
-
64
- // wrap the calibration process in a promise so we can await it
65
- return new Promise((resolve, reject) => {
66
- // when a call is received
67
- speaker.peer.on('call', async call => {
68
- // Answer the call (one way)
69
-
70
- call.answer();
71
- speaker.#removeUIElems();
72
- speaker.#showSpinner();
73
- speaker.ac.createLocalAudio(document.getElementById(speaker.targetElement));
74
- // when we start receiving audio
75
- call.on('stream', async stream => {
76
- window.localStream = stream;
77
- window.localAudio.srcObject = stream;
78
- window.localAudio.autoplay = false;
79
-
80
- // if the sinkSamplingRate is not set sleep
81
- while (!speaker.ac.sampleRatesSet()) {
82
- console.log('SinkSamplingRate is undefined, sleeping');
83
- await sleep(1);
84
- }
85
-
86
- if (params.displayUpdate) {
87
- params.displayUpdate.style.display = '';
88
- }
89
-
90
- // resolve when we have a result
91
- console.log(params.calibrateSoundIRSec);
92
- console.log(params);
93
- speaker.result = await speaker.ac.startCalibration(
94
- stream,
95
- params.gainValues,
96
- params.ICalib,
97
- params.knownIR,
98
- params.microphoneName,
99
- params.calibrateSoundCheck,
100
- params.isSmartPhone,
101
- params.calibrateSoundBurstDb,
102
- params.calibrateSoundBurstFilteredExtraDb,
103
- params.calibrateSoundBurstLevelReTBool,
104
- params.calibrateSoundBurstUses1000HzGainBool,
105
- params.calibrateSoundBurstRepeats,
106
- params.calibrateSoundBurstSec,
107
- params.calibrateSoundBurstsWarmup,
108
- params.calibrateSoundHz,
109
- params.calibrateSoundIRSec,
110
- params.calibrateSoundIIRSec,
111
- params.calibrateSoundIIRPhase,
112
- params.calibrateSound1000HzPreSec,
113
- params.calibrateSound1000HzSec,
114
- params.calibrateSound1000HzPostSec,
115
- params.calibrateSoundBackgroundSecs,
116
- params.calibrateSoundSmoothOctaves,
117
- params.calibrateSoundPowerBinDesiredSec,
118
- params.calibrateSoundPowerDbSDToleratedDb,
119
- params.micManufacturer,
120
- params.micSerialNumber,
121
- params.micModelNumber,
122
- params.micModelName,
123
- params.calibrateMicrophonesBool,
124
- params.authorEmails,
125
- params.webAudioDeviceNames,
126
- params.IDsToSaveInSoundProfileLibrary,
127
- params.restartButton,
128
- params.reminder,
129
- params.calibrateSoundLimit
130
- );
131
- speaker.#removeUIElems();
132
- resolve(speaker.result);
133
- });
134
- // if we do not receive a result within the timeout, reject
135
- setTimeout(() => {
136
- reject(
137
- new CalibrationTimedOutError(
138
- `Calibration failed to produce a result after ${
139
- timeOut / 1000
140
- } seconds. Please try again.`
141
- )
142
- );
143
- }, timeOut);
144
- });
145
- });
146
- };
147
-
148
- static testIIR = async (params, CalibratorInstance, IIR, timeOut = 180000) => {
149
- window.speaker = new Speaker(params, CalibratorInstance);
150
- const {speaker} = window;
151
-
152
- // wrap the calibration process in a promise so we can await it
153
- return new Promise((resolve, reject) => {
154
- // when a call is received
155
- speaker.peer.on('call', async call => {
156
- // Answer the call (one way)
157
- call.answer();
158
- speaker.#removeUIElems();
159
- speaker.#showSpinner();
160
- speaker.ac.createLocalAudio(document.getElementById(speaker.targetElement));
161
- // when we start receiving audio
162
- call.on('stream', async stream => {
163
- window.localStream = stream;
164
- window.localAudio.srcObject = stream;
165
- window.localAudio.autoplay = false;
166
-
167
- // if the sinkSamplingRate is not set sleep
168
- while (!speaker.ac.sampleRatesSet()) {
169
- console.log('SinkSamplingRate is undefined, sleeping');
170
- await sleep(1);
171
- }
172
- // resolve when we have a result
173
- speaker.result = await speaker.ac.playMLSwithIIR(stream, IIR);
174
- speaker.#removeUIElems();
175
- resolve(speaker.result);
176
- });
177
- // if we do not receive a result within the timeout, reject
178
- setTimeout(() => {
179
- reject(
180
- new CalibrationTimedOutError(
181
- `Calibration failed to produce a result after ${
182
- timeOut / 1000
183
- } seconds. Please try again.`
184
- )
185
- );
186
- }, timeOut);
187
- });
188
- });
189
- };
190
-
191
- /**
192
- * Called after the peer conncection has been opened.
193
- * Generates a QR code for the connection and displays it.
194
- *
195
- * @private
196
- * @example
197
- */
198
- #showQRCode = () => {
199
- // Get query string, the URL parameters to specify a Listener
200
- const queryStringParameters = {
201
- speakerPeerId: this.peer.id,
202
- isSmartPhone: this.isSmartPhone,
203
- calibrateSoundHz: this.calibrateSoundHz,
204
- calibrateSoundSamplingDesiredBits: this.calibrateSoundSamplingDesiredBits,
205
- lang: this.language,
206
- };
207
- const queryString = this.queryStringFromObject(queryStringParameters);
208
- const uri = this.siteUrl + queryString;
209
- if (this.isSmartPhone) {
210
- // Display QR code for the participant to scan
211
- const qrCanvas = document.createElement('canvas');
212
- qrCanvas.setAttribute('id', 'qrCanvas');
213
- console.log(uri);
214
- QRCode.toCanvas(qrCanvas, uri, error => {
215
- if (error) console.error(error);
216
- });
217
- const qrImage = new Image(400, 400);
218
- qrImage.setAttribute('id', 'compatibilityCheckQRImage');
219
- qrImage.style.zIndex = Infinity;
220
- qrImage.style.width = 400;
221
- qrImage.style.height = 400;
222
- qrImage.style.aspectRatio = 1;
223
- qrImage.src = qrCanvas.toDataURL();
224
- qrImage.style.maxHeight = '150px';
225
- qrImage.style.maxWidth = '150px';
226
- document.getElementById(this.targetElement).appendChild(qrImage);
227
- } else {
228
- // show the link to the user
229
- // If specified HTML Id is available, show QR code there
230
- if (document.getElementById(this.targetElement)) {
231
- // const linkTag = document.createElement('a');
232
- // linkTag.setAttribute('href', uri);
233
- // linkTag.innerHTML = 'Click here to start the calibration';
234
- // linkTag.target = '_blank';
235
- // document.getElementById(this.targetElement).appendChild(linkTag);
236
- // document.getElementById(this.targetElement).appendChild(qrCanvas);
237
-
238
- const proceedButton = document.createElement('button');
239
- proceedButton.setAttribute('id', 'calibrationProceedButton');
240
- proceedButton.setAttribute('class', 'btn btn-success');
241
- proceedButton.innerHTML = 'Proceed';
242
- proceedButton.onclick = () => {
243
- // open the link in a new tab
244
- window.open(uri, '_blank');
245
- // remove the button
246
- document.getElementById('calibrationProceedButton').remove();
247
- };
248
- document.getElementById(this.targetElement).appendChild(proceedButton);
249
- }
250
- }
251
- // or just print it to console
252
- console.log('TEST: Peer reachable at: ', uri);
253
- };
254
-
255
- #showSpinner = () => {
256
- const spinner = document.createElement('div');
257
- spinner.className = 'spinner-border ml-auto';
258
- spinner.role = 'status';
259
- spinner.ariaHidden = 'true';
260
- document.getElementById(this.targetElement).appendChild(spinner);
261
-
262
- // clear instructionDisplay
263
- const soundMessage = document.getElementById(this.soundMessageId);
264
- soundMessage.innerHTML = '';
265
- soundMessage.style.display = 'none';
266
- const instructionDisplay = document.getElementById(this.instructionDisplayId);
267
- const background = document.getElementById('background'); // todo: get background id from params
268
- const subtitle = document.getElementById(this.soundSubtitleId);
269
- if (subtitle) {
270
- subtitle.innerHTML = '';
271
- }
272
- if (instructionDisplay) {
273
- instructionDisplay.innerHTML = '';
274
- instructionDisplay.style.whiteSpace = 'nowrap';
275
- instructionDisplay.style.fontWeight = 'bold';
276
- instructionDisplay.style.width = 'fit-content';
277
- instructionDisplay.innerHTML = phrases.RC_soundRecording[this.language];
278
- let fontSize = 100;
279
- instructionDisplay.style.fontSize = fontSize + 'px';
280
- while (instructionDisplay.scrollWidth > background.scrollWidth * 0.9 && fontSize > 10) {
281
- fontSize--;
282
- instructionDisplay.style.fontSize = fontSize + 'px';
283
- }
284
- // const p = document.createElement('p');
285
- // // font size
286
- // p.style.fontSize = '1.1rem';
287
- // p.style.fontWeight = 'normal';
288
- // p.style.paddingTop = '20px';
289
- // const timeToCalibrateText = phrases.RC_howLongToCalibrate['en-US'];
290
- // p.innerHTML = timeToCalibrateText.replace('111', this.timeToCalibrate);
291
- // instructionDisplay.appendChild(p);
292
- }
293
-
294
- const timeToCalibrateDisplay = document.getElementById(this.timeToCalibrateDisplay);
295
- if (timeToCalibrateDisplay) {
296
- const timeToCalibrateText = phrases.RC_howLongToCalibrate[this.language];
297
- timeToCalibrateDisplay.innerHTML = timeToCalibrateText.replace('111', this.timeToCalibrate);
298
- timeToCalibrateDisplay.style.fontWeight = 'normal';
299
- timeToCalibrateDisplay.style.fontSize = '1rem';
300
- // timeToCalibrateDisplay.style.paddingTop = '20px';
301
- }
302
-
303
- // Update title - titleDisplayId
304
- const titleDisplay = document.getElementById(this.titleDisplayId);
305
- if (titleDisplay) {
306
- // replace 5 with 6
307
- titleDisplay.innerHTML = this.isSmartPhone
308
- ? titleDisplay.innerHTML.replace('2', '3')
309
- : titleDisplay.innerHTML.replace('4', '5');
310
- }
311
- };
312
-
313
- #removeUIElems = () => {
314
- const parent = document.getElementById(this.targetElement);
315
- while (parent.firstChild) {
316
- parent.firstChild.remove();
317
- }
318
- };
319
-
320
- /**
321
- * Called when the peer connection is opened.
322
- * Saves the peer id and calls the QR code generator.
323
- *
324
- * @param peerId - The peer id of the peer connection.
325
- * @param id
326
- * @private
327
- * @example
328
- */
329
- #onPeerOpen = id => {
330
- // Workaround for peer.reconnect deleting previous id
331
- if (id === null) {
332
- console.error('Received null id from peer open');
333
- this.peer.id = this.lastPeerId;
334
- } else {
335
- this.lastPeerId = this.peer.id;
336
- }
337
-
338
- if (id !== this.peer.id) {
339
- console.warn('DEBUG Check you assumption that id === this.peer.id');
340
- }
341
-
342
- this.#showQRCode();
343
- };
344
-
345
- /**
346
- * Called when the peer connection is established.
347
- * Enforces a single connection.
348
- *
349
- * @param connection - The connection object.
350
- * @private
351
- * @example
352
- */
353
- #onPeerConnection = connection => {
354
- // Allow only a single connection
355
- if (this.conn && this.conn.open) {
356
- connection.on('open', () => {
357
- connection.send('Already connected to another client');
358
- setTimeout(() => {
359
- connection.close();
360
- }, 500);
361
- });
362
- return;
363
- }
364
-
365
- this.conn = connection;
366
- console.log('Connected to: ', this.conn.peer);
367
- this.#ready();
368
- };
369
-
370
- /**
371
- * Called when the peer connection is closed.
372
- *
373
- * @private
374
- * @example
375
- */
376
- onPeerClose = () => {
377
- this.conn = null;
378
- console.log('Connection destroyed');
379
- };
380
-
381
- static closeConnection = () => {
382
- this.conn = null;
383
- console.log('Connection destroyed');
384
- };
385
-
386
- /**
387
- * Called when the peer connection is disconnected.
388
- * Attempts to reconnect.
389
- *
390
- * @private
391
- * @example
392
- */
393
- #onPeerDisconnected = () => {
394
- console.log('Connection lost. Please reconnect');
395
-
396
- // Workaround for peer.reconnect deleting previous id
397
- this.peer.id = this.lastPeerId;
398
- // eslint-disable-next-line no-underscore-dangle
399
- this.peer._lastServerId = this.lastPeerId;
400
- this.peer.reconnect();
401
- };
402
-
403
- /**
404
- * Called when the peer connection encounters an error.
405
- *
406
- * @param error
407
- * @private
408
- * @example
409
- */
410
- #onPeerError = error => {
411
- // TODO: check if this function is needed or not
412
- console.error(error);
413
- };
414
-
415
- /**
416
- * Called when data is received from the peer connection.
417
- *
418
- * @param data
419
- * @private
420
- * @example
421
- */
422
- #onIncomingData = data => {
423
- // enforce object type
424
- if (
425
- !Object.prototype.hasOwnProperty.call(data, 'name') ||
426
- !Object.prototype.hasOwnProperty.call(data, 'payload')
427
- ) {
428
- console.error('Received malformed data: ', data);
429
- return;
430
- }
431
-
432
- switch (data.name) {
433
- case 'samplingRate':
434
- this.ac.setSamplingRates(data.payload);
435
- break;
436
- case 'sampleSize':
437
- this.ac.setSampleSize(data.payload);
438
- break;
439
- case 'deviceType':
440
- this.ac.setDeviceType(data.payload);
441
- break;
442
- case 'deviceName':
443
- this.ac.setDeviceName(data.payload);
444
- break;
445
- case 'flags':
446
- //this.ac.setDeviceName(data.payload);
447
- console.log("FLAGS");
448
- console.log(data.payload);
449
- this.ac.setFlags(data.payload);
450
- break;
451
- case 'deviceInfo':
452
- this.ac.setDeviceInfo(data.payload);
453
- console.log('Received device info from listener: ', data.payload);
454
- break;
455
- case UnsupportedDeviceError.name:
456
- case MissingSpeakerIdError.name:
457
- throw data.payload;
458
- break;
459
- default:
460
- break;
461
- }
462
- };
463
-
464
- /**
465
- * Called when the peer connection is #ready.
466
- *
467
- * @private
468
- * @example
469
- */
470
- #ready = () => {
471
- // Perform callback with data
472
- this.conn.on('data', this.#onIncomingData);
473
- this.conn.on('close', () => {
474
- console.log('Connection reset<br>Awaiting connection...');
475
- this.conn = null;
476
- });
477
- };
478
-
479
- /** .
480
- * .
481
- * .
482
- * Debug method for downloading the recorded audio
483
- *
484
- * @public
485
- * @example
486
- */
487
- downloadData = () => {
488
- this.ac.downloadData();
489
- };
490
-
491
- repeatCalibration = async (params, stream, CalibratorInstance) => {
492
- this.ac = CalibratorInstance;
493
- this.#removeUIElems();
494
- this.#showSpinner();
495
-
496
- console.log("This is a repeat");
497
- // wrap the calibration process in a promise so we can await it
498
- return new Promise(async (resolve, reject) => {
499
- const result = await this.ac.startCalibration(
500
- stream,
501
- params.gainValues,
502
- params.ICalib,
503
- params.knownIR,
504
- params.microphoneName,
505
- params.calibrateSoundCheck,
506
- params.isSmartPhone,
507
- params.calibrateSoundBurstDb,
508
- params.calibrateSoundBurstFilteredExtraDb,
509
- params.calibrateSoundBurstLevelReTBool,
510
- params.calibrateSoundBurstUses1000HzGainBool,
511
- params.calibrateSoundBurstRepeats,
512
- params.calibrateSoundBurstSec,
513
- params.calibrateSoundBurstsWarmup,
514
- params.calibrateSoundHz,
515
- params.calibrateSoundIRSec,
516
- params.calibrateSoundIIRSec,
517
- params.params.calibrateSoundIIRPhase,
518
- params.calibrateSound1000HzPreSec,
519
- params.calibrateSound1000HzSec,
520
- params.calibrateSound1000HzPostSec,
521
- params.calibrateSoundBackgroundSecs,
522
- params.calibrateSoundSmoothOctaves,
523
- params.calibrateSoundPowerBinDesiredSec,
524
- params.calibrateSoundPowerDbSDToleratedDb,
525
- params.micManufacturer,
526
- params.micSerialNumber,
527
- params.micModelNumber,
528
- params.micModelName,
529
- params.calibrateMicrophonesBool,
530
- params.authorEmails,
531
- params.webAudioDeviceNames,
532
- params.IDsToSaveInSoundProfileLibrary,
533
- params.restartButton,
534
- params.reminder,
535
- params.calibrateSoundLimit
536
- );
537
- this.#removeUIElems();
538
- resolve(result);
539
- });
540
- };
541
- }
542
-
543
- /*
544
- Referenced links:
545
- https://stackoverflow.com/questions/28016664/when-you-pass-this-as-an-argument/28016676#28016676
546
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
547
- https://stackoverflow.com/questions/879152/how-do-i-make-javascript-beep [3]
548
- */
549
-
550
- export default Speaker;
1
+ import QRCode from 'qrcode';
2
+ import AudioPeer from './audioPeer';
3
+ import {sleep} from '../utils';
4
+ import {
5
+ UnsupportedDeviceError,
6
+ MissingSpeakerIdError,
7
+ CalibrationTimedOutError,
8
+ } from './peerErrors';
9
+
10
+ import {phrases} from '../../dist/example/i18n';
11
+
12
+ /**
13
+ * @class Handles the speaker's side of the connection. Responsible for initiating the connection,
14
+ * rendering the QRCode, and answering the call.
15
+ * @augments AudioPeer
16
+ */
17
+ class Speaker extends AudioPeer {
18
+ /**
19
+ * Takes the url of the current site and a target element where html elements will be appended.
20
+ *
21
+ * @param params - See type definition for initParameters.
22
+ * @param Calibrator - An instance of the AudioCalibrator class, should not use AudioCalibrator directly, instead use an extended class available in /tasks/.
23
+ * @param CalibratorInstance
24
+ * @example
25
+ */
26
+ constructor(params, CalibratorInstance) {
27
+ super(params);
28
+ this.language = params?.language ?? 'en-US';
29
+ this.siteUrl += '/listener?';
30
+ this.ac = CalibratorInstance;
31
+ this.result = null;
32
+ this.debug = params?.debug ?? false;
33
+ this.isSmartPhone = params?.isSmartPhone ?? false;
34
+ this.calibrateSoundHz = params?.calibrateSoundHz ?? 48000;
35
+ this.calibrateSoundSamplingDesiredBits = params?.calibrateSoundSamplingDesiredBits ?? 24;
36
+ this.instructionDisplayId = params?.instructionDisplayId ?? '';
37
+ this.soundSubtitleId = params?.soundSubtitleId ?? '';
38
+ this.timeToCalibrateDisplay = params?.timeToCalibrateId ?? '';
39
+ this.soundMessageId = params?.soundMessageId ?? '';
40
+ this.titleDisplayId = params?.titleDisplayId ?? '';
41
+ this.timeToCalibrate = params?.timeToCalibrate ?? 10;
42
+ this.isParticipant = params?.isParticipant ?? false;
43
+ this.isLoudspeakerCalibration = params?.isLoudspeakerCalibration ?? false;
44
+
45
+ /* Set up callbacks that handle any events related to our peer object. */
46
+ this.peer.on('open', this.#onPeerOpen);
47
+ this.peer.on('connection', this.#onPeerConnection);
48
+ this.peer.on('close', this.onPeerClose);
49
+ this.peer.on('disconnected', this.#onPeerDisconnected);
50
+ this.peer.on('error', this.#onPeerError);
51
+ }
52
+ /**
53
+ * Async factory method that creates the Speaker object, and returns a promise that resolves to the result of the calibration.
54
+ *
55
+ * @param params - The parameters to be passed to the peer object.
56
+ * @param Calibrator - The class that defines the calibration process.
57
+ * @param CalibratorInstance
58
+ * @param timeOut - The amount of time to wait before timing out the connection (in milliseconds).
59
+ * @public
60
+ * @example
61
+ */
62
+ static startCalibration = async (params, CalibratorInstance, timeOut = 180000) => {
63
+ window.speaker = new Speaker(params, CalibratorInstance);
64
+ const {speaker} = window;
65
+
66
+ // wrap the calibration process in a promise so we can await it
67
+ return new Promise((resolve, reject) => {
68
+ // when a call is received
69
+ speaker.peer.on('call', async call => {
70
+ // Answer the call (one way)
71
+
72
+ call.answer();
73
+ speaker.#removeUIElems();
74
+ speaker.#showSpinner();
75
+ speaker.ac.createLocalAudio(document.getElementById(speaker.targetElement));
76
+ // when we start receiving audio
77
+ call.on('stream', async stream => {
78
+ window.localStream = stream;
79
+ window.localAudio.srcObject = stream;
80
+ window.localAudio.autoplay = false;
81
+
82
+ // if the sinkSamplingRate is not set sleep
83
+ while (!speaker.ac.sampleRatesSet()) {
84
+ console.log('SinkSamplingRate is undefined, sleeping');
85
+ await sleep(1);
86
+ }
87
+
88
+ if (params.displayUpdate) {
89
+ params.displayUpdate.style.display = '';
90
+ }
91
+
92
+ // resolve when we have a result
93
+ console.log(params.calibrateSoundIRSec);
94
+ console.log(params);
95
+ speaker.result = await speaker.ac.startCalibration(
96
+ stream,
97
+ params.gainValues,
98
+ params.ICalib,
99
+ params.knownIR,
100
+ params.microphoneName,
101
+ params.calibrateSoundCheck,
102
+ params.isSmartPhone,
103
+ params.calibrateSoundBurstDb,
104
+ params.calibrateSoundBurstFilteredExtraDb,
105
+ params.calibrateSoundBurstLevelReTBool,
106
+ params.calibrateSoundBurstUses1000HzGainBool,
107
+ params.calibrateSoundBurstRepeats,
108
+ params.calibrateSoundBurstSec,
109
+ params.calibrateSoundBurstsWarmup,
110
+ params.calibrateSoundHz,
111
+ params.calibrateSoundIRSec,
112
+ params.calibrateSoundIIRSec,
113
+ params.calibrateSoundIIRPhase,
114
+ params.calibrateSound1000HzPreSec,
115
+ params.calibrateSound1000HzSec,
116
+ params.calibrateSound1000HzPostSec,
117
+ params.calibrateSoundBackgroundSecs,
118
+ params.calibrateSoundSmoothOctaves,
119
+ params.calibrateSoundPowerBinDesiredSec,
120
+ params.calibrateSoundPowerDbSDToleratedDb,
121
+ params.micManufacturer,
122
+ params.micSerialNumber,
123
+ params.micModelNumber,
124
+ params.micModelName,
125
+ params.calibrateMicrophonesBool,
126
+ params.authorEmails,
127
+ params.webAudioDeviceNames,
128
+ params.IDsToSaveInSoundProfileLibrary,
129
+ params.restartButton,
130
+ params.reminder,
131
+ params.calibrateSoundLimit
132
+ );
133
+ speaker.#removeUIElems();
134
+ resolve(speaker.result);
135
+ });
136
+ // if we do not receive a result within the timeout, reject
137
+ setTimeout(() => {
138
+ reject(
139
+ new CalibrationTimedOutError(
140
+ `Calibration failed to produce a result after ${
141
+ timeOut / 1000
142
+ } seconds. Please try again.`
143
+ )
144
+ );
145
+ }, timeOut);
146
+ });
147
+ });
148
+ };
149
+
150
+ static testIIR = async (params, CalibratorInstance, IIR, timeOut = 180000) => {
151
+ window.speaker = new Speaker(params, CalibratorInstance);
152
+ const {speaker} = window;
153
+
154
+ // wrap the calibration process in a promise so we can await it
155
+ return new Promise((resolve, reject) => {
156
+ // when a call is received
157
+ speaker.peer.on('call', async call => {
158
+ // Answer the call (one way)
159
+ call.answer();
160
+ speaker.#removeUIElems();
161
+ speaker.#showSpinner();
162
+ speaker.ac.createLocalAudio(document.getElementById(speaker.targetElement));
163
+ // when we start receiving audio
164
+ call.on('stream', async stream => {
165
+ window.localStream = stream;
166
+ window.localAudio.srcObject = stream;
167
+ window.localAudio.autoplay = false;
168
+
169
+ // if the sinkSamplingRate is not set sleep
170
+ while (!speaker.ac.sampleRatesSet()) {
171
+ console.log('SinkSamplingRate is undefined, sleeping');
172
+ await sleep(1);
173
+ }
174
+ // resolve when we have a result
175
+ speaker.result = await speaker.ac.playMLSwithIIR(stream, IIR);
176
+ speaker.#removeUIElems();
177
+ resolve(speaker.result);
178
+ });
179
+ // if we do not receive a result within the timeout, reject
180
+ setTimeout(() => {
181
+ reject(
182
+ new CalibrationTimedOutError(
183
+ `Calibration failed to produce a result after ${
184
+ timeOut / 1000
185
+ } seconds. Please try again.`
186
+ )
187
+ );
188
+ }, timeOut);
189
+ });
190
+ });
191
+ };
192
+
193
+ /**
194
+ * Called after the peer conncection has been opened.
195
+ * Generates a QR code for the connection and displays it.
196
+ *
197
+ * @private
198
+ * @example
199
+ */
200
+ #showQRCode = () => {
201
+ // Get query string, the URL parameters to specify a Listener
202
+ const queryStringParameters = {
203
+ speakerPeerId: this.peer.id,
204
+ isSmartPhone: this.isSmartPhone,
205
+ calibrateSoundHz: this.calibrateSoundHz,
206
+ calibrateSoundSamplingDesiredBits: this.calibrateSoundSamplingDesiredBits,
207
+ lang: this.language,
208
+ };
209
+ const queryString = this.queryStringFromObject(queryStringParameters);
210
+ const uri = this.siteUrl + queryString;
211
+ if (this.isSmartPhone) {
212
+ // Display QR code for the participant to scan
213
+ const qrCanvas = document.createElement('canvas');
214
+ qrCanvas.setAttribute('id', 'qrCanvas');
215
+ console.log(uri);
216
+ QRCode.toCanvas(qrCanvas, uri, error => {
217
+ if (error) console.error(error);
218
+ });
219
+ const qrImage = new Image(400, 400);
220
+ qrImage.setAttribute('id', 'compatibilityCheckQRImage');
221
+ qrImage.style.zIndex = Infinity;
222
+ qrImage.style.width = 400;
223
+ qrImage.style.height = 400;
224
+ qrImage.style.aspectRatio = 1;
225
+ qrImage.src = qrCanvas.toDataURL();
226
+ qrImage.style.maxHeight = '150px';
227
+ qrImage.style.maxWidth = '150px';
228
+ document.getElementById(this.targetElement).appendChild(qrImage);
229
+ } else {
230
+ // show the link to the user
231
+ // If specified HTML Id is available, show QR code there
232
+ if (document.getElementById(this.targetElement)) {
233
+ // const linkTag = document.createElement('a');
234
+ // linkTag.setAttribute('href', uri);
235
+ // linkTag.innerHTML = 'Click here to start the calibration';
236
+ // linkTag.target = '_blank';
237
+ // document.getElementById(this.targetElement).appendChild(linkTag);
238
+ // document.getElementById(this.targetElement).appendChild(qrCanvas);
239
+
240
+ const proceedButton = document.createElement('button');
241
+ proceedButton.setAttribute('id', 'calibrationProceedButton');
242
+ proceedButton.setAttribute('class', 'btn btn-success');
243
+ proceedButton.innerHTML = 'Proceed';
244
+ proceedButton.onclick = () => {
245
+ // open the link in a new tab
246
+ window.open(uri, '_blank');
247
+ // remove the button
248
+ document.getElementById('calibrationProceedButton').remove();
249
+ };
250
+ document.getElementById(this.targetElement).appendChild(proceedButton);
251
+ }
252
+ }
253
+ // or just print it to console
254
+ console.log('TEST: Peer reachable at: ', uri);
255
+ };
256
+
257
+ #showSpinner = () => {
258
+ const spinner = document.createElement('div');
259
+ spinner.className = 'spinner-border ml-auto';
260
+ spinner.role = 'status';
261
+ spinner.ariaHidden = 'true';
262
+ document.getElementById(this.targetElement).appendChild(spinner);
263
+
264
+ // clear instructionDisplay
265
+ const soundMessage = document.getElementById(this.soundMessageId);
266
+ soundMessage.innerHTML = '';
267
+ soundMessage.style.display = 'none';
268
+ const instructionDisplay = document.getElementById(this.instructionDisplayId);
269
+ const background = document.getElementById('background'); // todo: get background id from params
270
+ const subtitle = document.getElementById(this.soundSubtitleId);
271
+ if (subtitle) {
272
+ subtitle.innerHTML = '';
273
+ }
274
+ if (instructionDisplay) {
275
+ instructionDisplay.innerHTML = '';
276
+ instructionDisplay.style.whiteSpace = 'nowrap';
277
+ instructionDisplay.style.fontWeight = 'bold';
278
+ instructionDisplay.style.width = 'fit-content';
279
+ instructionDisplay.innerHTML = phrases.RC_soundRecording[this.language];
280
+ let fontSize = 100;
281
+ instructionDisplay.style.fontSize = fontSize + 'px';
282
+ while (instructionDisplay.scrollWidth > background.scrollWidth * 0.9 && fontSize > 10) {
283
+ fontSize--;
284
+ instructionDisplay.style.fontSize = fontSize + 'px';
285
+ }
286
+ // const p = document.createElement('p');
287
+ // // font size
288
+ // p.style.fontSize = '1.1rem';
289
+ // p.style.fontWeight = 'normal';
290
+ // p.style.paddingTop = '20px';
291
+ // const timeToCalibrateText = phrases.RC_howLongToCalibrate['en-US'];
292
+ // p.innerHTML = timeToCalibrateText.replace('111', this.timeToCalibrate);
293
+ // instructionDisplay.appendChild(p);
294
+ }
295
+
296
+ const timeToCalibrateDisplay = document.getElementById(this.timeToCalibrateDisplay);
297
+ if (timeToCalibrateDisplay) {
298
+ const timeToCalibrateText = phrases.RC_howLongToCalibrate[this.language];
299
+ timeToCalibrateDisplay.innerHTML = timeToCalibrateText.replace('111', this.timeToCalibrate);
300
+ timeToCalibrateDisplay.style.fontWeight = 'normal';
301
+ timeToCalibrateDisplay.style.fontSize = '1rem';
302
+ // timeToCalibrateDisplay.style.paddingTop = '20px';
303
+ }
304
+
305
+ // Update title - titleDisplayId
306
+ const titleDisplay = document.getElementById(this.titleDisplayId);
307
+ if (titleDisplay) {
308
+ // if (this.isParticipant) {
309
+ // titleDisplay.innerHTML = titleDisplay.innerHTML.replace('3', '4');
310
+ // } else if (this.isSmartPhone) {
311
+ // if (this.isLoudspeakerCalibration) {
312
+ // titleDisplay.innerHTML = titleDisplay.innerHTML.replace('6', '7');
313
+ // } else {
314
+ // titleDisplay.innerHTML = titleDisplay.innerHTML.replace('5', '6');
315
+ // }
316
+ // } else {
317
+ // titleDisplay.innerHTML = titleDisplay.innerHTML.replace('5', '6');
318
+ // }
319
+ if (this.isLoudspeakerCalibration) {
320
+ if (this.isParticipant) {
321
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('3', '4');
322
+ } else if (this.isSmartPhone) {
323
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('6', '7');
324
+ } else {
325
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('5', '6');
326
+ }
327
+ } else {
328
+ if (this.isSmartPhone) {
329
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('5', '6');
330
+ } else {
331
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('4', '5');
332
+ }
333
+ }
334
+ }
335
+ };
336
+
337
+ #removeUIElems = () => {
338
+ const parent = document.getElementById(this.targetElement);
339
+ while (parent.firstChild) {
340
+ parent.firstChild.remove();
341
+ }
342
+ };
343
+
344
+ /**
345
+ * Called when the peer connection is opened.
346
+ * Saves the peer id and calls the QR code generator.
347
+ *
348
+ * @param peerId - The peer id of the peer connection.
349
+ * @param id
350
+ * @private
351
+ * @example
352
+ */
353
+ #onPeerOpen = id => {
354
+ // Workaround for peer.reconnect deleting previous id
355
+ if (id === null) {
356
+ console.error('Received null id from peer open');
357
+ this.peer.id = this.lastPeerId;
358
+ } else {
359
+ this.lastPeerId = this.peer.id;
360
+ }
361
+
362
+ if (id !== this.peer.id) {
363
+ console.warn('DEBUG Check you assumption that id === this.peer.id');
364
+ }
365
+
366
+ this.#showQRCode();
367
+ };
368
+
369
+ /**
370
+ * Called when the peer connection is established.
371
+ * Enforces a single connection.
372
+ *
373
+ * @param connection - The connection object.
374
+ * @private
375
+ * @example
376
+ */
377
+ #onPeerConnection = connection => {
378
+ // Allow only a single connection
379
+ if (this.conn && this.conn.open) {
380
+ connection.on('open', () => {
381
+ connection.send('Already connected to another client');
382
+ setTimeout(() => {
383
+ connection.close();
384
+ }, 500);
385
+ });
386
+ return;
387
+ }
388
+
389
+ this.conn = connection;
390
+ console.log('Connected to: ', this.conn.peer);
391
+ this.#ready();
392
+ };
393
+
394
+ /**
395
+ * Called when the peer connection is closed.
396
+ *
397
+ * @private
398
+ * @example
399
+ */
400
+ onPeerClose = () => {
401
+ this.conn = null;
402
+ console.log('Connection destroyed');
403
+ };
404
+
405
+ static closeConnection = () => {
406
+ this.conn = null;
407
+ console.log('Connection destroyed');
408
+ };
409
+
410
+ /**
411
+ * Called when the peer connection is disconnected.
412
+ * Attempts to reconnect.
413
+ *
414
+ * @private
415
+ * @example
416
+ */
417
+ #onPeerDisconnected = () => {
418
+ console.log('Connection lost. Please reconnect');
419
+
420
+ // Workaround for peer.reconnect deleting previous id
421
+ this.peer.id = this.lastPeerId;
422
+ // eslint-disable-next-line no-underscore-dangle
423
+ this.peer._lastServerId = this.lastPeerId;
424
+ this.peer.reconnect();
425
+ };
426
+
427
+ /**
428
+ * Called when the peer connection encounters an error.
429
+ *
430
+ * @param error
431
+ * @private
432
+ * @example
433
+ */
434
+ #onPeerError = error => {
435
+ // TODO: check if this function is needed or not
436
+ console.error(error);
437
+ };
438
+
439
+ /**
440
+ * Called when data is received from the peer connection.
441
+ *
442
+ * @param data
443
+ * @private
444
+ * @example
445
+ */
446
+ #onIncomingData = data => {
447
+ // enforce object type
448
+ if (
449
+ !Object.prototype.hasOwnProperty.call(data, 'name') ||
450
+ !Object.prototype.hasOwnProperty.call(data, 'payload')
451
+ ) {
452
+ console.error('Received malformed data: ', data);
453
+ return;
454
+ }
455
+
456
+ switch (data.name) {
457
+ case 'samplingRate':
458
+ this.ac.setSamplingRates(data.payload);
459
+ break;
460
+ case 'sampleSize':
461
+ this.ac.setSampleSize(data.payload);
462
+ break;
463
+ case 'deviceType':
464
+ this.ac.setDeviceType(data.payload);
465
+ break;
466
+ case 'deviceName':
467
+ this.ac.setDeviceName(data.payload);
468
+ break;
469
+ case 'flags':
470
+ //this.ac.setDeviceName(data.payload);
471
+ console.log('FLAGS');
472
+ console.log(data.payload);
473
+ this.ac.setFlags(data.payload);
474
+ break;
475
+ case 'deviceInfo':
476
+ this.ac.setDeviceInfo(data.payload);
477
+ console.log('Received device info from listener: ', data.payload);
478
+ break;
479
+ case UnsupportedDeviceError.name:
480
+ case MissingSpeakerIdError.name:
481
+ throw data.payload;
482
+ break;
483
+ default:
484
+ break;
485
+ }
486
+ };
487
+
488
+ /**
489
+ * Called when the peer connection is #ready.
490
+ *
491
+ * @private
492
+ * @example
493
+ */
494
+ #ready = () => {
495
+ // Perform callback with data
496
+ this.conn.on('data', this.#onIncomingData);
497
+ this.conn.on('close', () => {
498
+ console.log('Connection reset<br>Awaiting connection...');
499
+ this.conn = null;
500
+ });
501
+ };
502
+
503
+ /** .
504
+ * .
505
+ * .
506
+ * Debug method for downloading the recorded audio
507
+ *
508
+ * @public
509
+ * @example
510
+ */
511
+ downloadData = () => {
512
+ this.ac.downloadData();
513
+ };
514
+
515
+ repeatCalibration = async (params, stream, CalibratorInstance) => {
516
+ this.ac = CalibratorInstance;
517
+ this.#removeUIElems();
518
+ this.#showSpinner();
519
+
520
+ console.log('This is a repeat');
521
+ // wrap the calibration process in a promise so we can await it
522
+ return new Promise(async (resolve, reject) => {
523
+ const result = await this.ac.startCalibration(
524
+ stream,
525
+ params.gainValues,
526
+ params.ICalib,
527
+ params.knownIR,
528
+ params.microphoneName,
529
+ params.calibrateSoundCheck,
530
+ params.isSmartPhone,
531
+ params.calibrateSoundBurstDb,
532
+ params.calibrateSoundBurstFilteredExtraDb,
533
+ params.calibrateSoundBurstLevelReTBool,
534
+ params.calibrateSoundBurstUses1000HzGainBool,
535
+ params.calibrateSoundBurstRepeats,
536
+ params.calibrateSoundBurstSec,
537
+ params.calibrateSoundBurstsWarmup,
538
+ params.calibrateSoundHz,
539
+ params.calibrateSoundIRSec,
540
+ params.calibrateSoundIIRSec,
541
+ params.params.calibrateSoundIIRPhase,
542
+ params.calibrateSound1000HzPreSec,
543
+ params.calibrateSound1000HzSec,
544
+ params.calibrateSound1000HzPostSec,
545
+ params.calibrateSoundBackgroundSecs,
546
+ params.calibrateSoundSmoothOctaves,
547
+ params.calibrateSoundPowerBinDesiredSec,
548
+ params.calibrateSoundPowerDbSDToleratedDb,
549
+ params.micManufacturer,
550
+ params.micSerialNumber,
551
+ params.micModelNumber,
552
+ params.micModelName,
553
+ params.calibrateMicrophonesBool,
554
+ params.authorEmails,
555
+ params.webAudioDeviceNames,
556
+ params.IDsToSaveInSoundProfileLibrary,
557
+ params.restartButton,
558
+ params.reminder,
559
+ params.calibrateSoundLimit
560
+ );
561
+ this.#removeUIElems();
562
+ resolve(result);
563
+ });
564
+ };
565
+ }
566
+
567
+ /*
568
+ Referenced links:
569
+ https://stackoverflow.com/questions/28016664/when-you-pass-this-as-an-argument/28016676#28016676
570
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
571
+ https://stackoverflow.com/questions/879152/how-do-i-make-javascript-beep [3]
572
+ */
573
+
574
+ export default Speaker;