speaker-calibration 2.2.225 → 2.2.227

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.
@@ -11,24 +11,23 @@ import Peer from 'peerjs';
11
11
  //import {phrases} from '../../dist/example/i18n';
12
12
 
13
13
  /**
14
- * @class Handles the speaker's side of the connection. Responsible for initiating the connection,
15
- * rendering the QRCode, and answering the call.
14
+ * @class Handles the speaker's side of the connection. Responsible for calibration process
15
+ * and communication with the listener.
16
16
  * @augments AudioPeer
17
17
  */
18
18
  class Speaker extends AudioPeer {
19
19
  /**
20
- * Takes the url of the current site and a target element where html elements will be appended.
20
+ * Takes the parameters for calibration and a connection manager instance.
21
21
  *
22
22
  * @param params - See type definition for initParameters.
23
- * @param Calibrator - An instance of the AudioCalibrator class, should not use AudioCalibrator directly, instead use an extended class available in /tasks/.
24
- * @param CalibratorInstance
25
- * @example
23
+ * @param CalibratorInstance - An instance of the AudioCalibrator class
24
+ * @param connectionManager - An instance of the ConnectionManager class
26
25
  */
27
- constructor(params, CalibratorInstance) {
26
+ constructor(params, CalibratorInstance, connectionManager = null) {
28
27
  super(params);
29
28
  this.language = params?.language ?? 'en-US';
30
29
  this.siteUrl += '/listener?';
31
- this.ac = CalibratorInstance;
30
+ // this.ac = CalibratorInstance;
32
31
  this.result = null;
33
32
  this.debug = params?.debug ?? false;
34
33
  this.isSmartPhone = params?.isSmartPhone ?? false;
@@ -47,94 +46,127 @@ class Speaker extends AudioPeer {
47
46
  this.phrases = params?.phrases ?? {};
48
47
  this.permissionStatus = 'pending';
49
48
  this.calibrateSoundHz = params?.calibrateSoundHz ?? 48000;
49
+ this.name = 'SoundCalibration'; // Name used for submodule registration
50
+ this.connectionManager = connectionManager;
50
51
 
51
- /* Set up callbacks that handle any events related to our peer object. */
52
+ // Register with connection manager if provided
53
+ if (this.connectionManager) {
54
+ this.connectionManager.registerSubmodule(this);
55
+ }
52
56
  }
53
57
 
54
58
  uri = '';
55
59
  qrImage;
56
60
  shortURL;
57
61
 
58
- initPeer = async () => {
59
- const id = await this.generateTimeBasedPeerID();
60
- this.peer = new Peer(id, {
61
- secure: true,
62
- host: 'easyeyes-peer-server.herokuapp.com',
63
- port: 443,
64
- config: {
65
- iceServers: [
66
- {
67
- urls: 'turn:global.relay.metered.ca:80',
68
- username: 'de884cfc34189cdf1a5dd616',
69
- credential: 'IcOpouU9/TYBmpHU',
70
- },
71
- {
72
- urls: 'turn:global.relay.metered.ca:80?transport=tcp',
73
- username: 'de884cfc34189cdf1a5dd616',
74
- credential: 'IcOpouU9/TYBmpHU',
75
- },
76
- {
77
- urls: 'turn:global.relay.metered.ca:443',
78
- username: 'de884cfc34189cdf1a5dd616',
79
- credential: 'IcOpouU9/TYBmpHU',
80
- },
81
- {
82
- urls: 'turns:global.relay.metered.ca:443?transport=tcp',
83
- username: 'de884cfc34189cdf1a5dd616',
84
- credential: 'IcOpouU9/TYBmpHU',
85
- },
86
- ],
87
- },
88
- });
89
- this.peer.on('open', this.#onPeerOpen);
90
- this.peer.on('connection', this.#onPeerConnection);
91
- this.peer.on('close', this.onPeerClose);
92
- this.peer.on('disconnected', this.#onPeerDisconnected);
93
- this.peer.on('error', this.#onPeerError);
94
- };
95
- generateTimeBasedPeerID = async () => {
96
- const now = new Date().getTime();
97
- const randomBuffer = new Uint8Array(10);
98
- crypto.getRandomValues(randomBuffer);
99
- const randomPart = Array.from(randomBuffer)
100
- .map(b => b.toString(36))
101
- .join('');
102
- const toHash = `${now}-${randomPart}`;
103
- const encoder = new TextEncoder();
104
- const data = encoder.encode(toHash);
105
- const hash = await crypto.subtle.digest('SHA-256', data);
106
- const hashArray = Array.from(new Uint8Array(hash)); // Convert buffer to byte array
107
- const hashString = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
108
- const shortHash = hashString.substring(0, 12); // Use more of the hash for a longer ID
109
- // return shortHash; // Consider converting this to Base62
110
- return this.encodeBase62(parseInt(shortHash, 16));
111
- };
62
+ // Required method for submodule interface
63
+ onMessage(data, connectionManager) {
64
+ if (!data || (!data.name && !data.type)) {
65
+ console.error('Received malformed data: ', data);
66
+ return;
67
+ }
68
+
69
+ // Convert type to name if needed for backward compatibility
70
+ const messageName = data.payload.name;
71
+ const payload = data.payload.payload;
112
72
 
113
- encodeBase62 = num => {
114
- const base = 36;
115
- const characters = '0123456789abcdefghijklmnopqrstuvwxyz';
116
- let result = '';
117
- while (num > 0) {
118
- result = characters[num % base] + result;
119
- num = Math.floor(num / base);
73
+ switch (messageName) {
74
+ case 'samplingRate':
75
+ console.log('Received sampling rate from listener: ', payload);
76
+ if (!payload) {
77
+ window.speaker.ac.setSamplingRates(window.speaker.calibrateSoundHz);
78
+ } else {
79
+ window.speaker.ac.setSamplingRates(payload);
80
+ }
81
+ break;
82
+ case 'sampleSize':
83
+ window.speaker.ac.setSampleSize(payload);
84
+ break;
85
+ case 'deviceType':
86
+ window.speaker.ac.setDeviceType(payload);
87
+ break;
88
+ case 'deviceName':
89
+ window.speaker.ac.setDeviceName(payload);
90
+ break;
91
+ case 'flags':
92
+ console.log('FLAGS');
93
+ console.log(payload);
94
+ window.speaker.ac.setFlags(payload);
95
+ break;
96
+ case 'deviceInfo':
97
+ window.speaker.ac.setDeviceInfo(payload);
98
+ console.log('Received device info from listener: ', payload);
99
+ break;
100
+ case 'permissionStatus':
101
+ console.log('Received permission status from listener: ', payload);
102
+ if (payload.type === 'error') {
103
+ this.permissionStatus = 'error';
104
+ window.speaker.ac.setPermissionStatus('error');
105
+ } else if (payload.type === 'denied') {
106
+ this.permissionStatus = 'denied';
107
+ window.speaker.ac.setPermissionStatus('denied');
108
+ } else if (payload.type === 'granted') {
109
+ this.permissionStatus = 'granted';
110
+ window.speaker.ac.setPermissionStatus('granted');
111
+ console.log('Permission granted');
112
+ }
113
+ break;
114
+ case UnsupportedDeviceError.name:
115
+ case MissingSpeakerIdError.name:
116
+ throw payload;
117
+ default:
118
+ break;
120
119
  }
121
- return result;
122
- };
120
+ }
121
+
122
+ /**
123
+ * Prepares the parameters to send to the listener
124
+ * @returns {Object} Parameters for the listener
125
+ */
126
+ prepareConnectionParams() {
127
+ const params = {
128
+ type: 'SoundCalibration',
129
+ name: 'SoundCalibration',
130
+ message: 'connectionParams',
131
+ payload: {
132
+ speakerPeerId: this.connectionManager?.getPeerID(),
133
+ sp: this.isSmartPhone,
134
+ hz: this.calibrateSoundHz,
135
+ bits: this.calibrateSoundSamplingDesiredBits,
136
+ lang: this.language,
137
+ deviceId: this.deviceId,
138
+ },
139
+ };
140
+ console.log('prepareConnectionParams', params);
141
+ return params;
142
+ }
123
143
 
124
144
  /**
125
145
  * Async factory method that creates the Speaker object, and returns a promise that resolves to the result of the calibration.
126
146
  *
127
147
  * @param params - The parameters to be passed to the peer object.
128
- * @param Calibrator - The class that defines the calibration process.
129
- * @param CalibratorInstance
148
+ * @param CalibratorInstance - The class that defines the calibration process.
149
+ * @param connectionManager - Instance of the ConnectionManager
130
150
  * @param timeOut - The amount of time to wait before timing out the connection (in milliseconds).
131
151
  * @public
132
- * @example
133
152
  */
134
- static startCalibration = async (params, CalibratorInstance, timeOut = 180000) => {
135
- window.speaker = new Speaker(params, CalibratorInstance);
153
+ static startCalibration = async (
154
+ params,
155
+ CalibratorInstance,
156
+ connectionManager,
157
+ timeOut = 180000
158
+ ) => {
159
+ // Create a speaker instance and register with the connection manager
160
+ window.speaker = new Speaker(params, CalibratorInstance, connectionManager);
136
161
  const {speaker} = window;
137
- await speaker.initPeer();
162
+ speaker.ac = CalibratorInstance;
163
+
164
+ await speaker.connectionManager.waitForPeerConnection();
165
+ await speaker.connectionManager.resolveWhenHandshakeReceived();
166
+
167
+ // Send connection parameters to the listener
168
+ speaker.connectionManager.send(speaker.prepareConnectionParams());
169
+
138
170
  // wrap the calibration process in a promise so we can await it
139
171
  return new Promise((resolve, reject) => {
140
172
  // Add a permission check handler
@@ -146,14 +178,18 @@ class Speaker extends AudioPeer {
146
178
  }
147
179
  }, 100);
148
180
 
149
- // when a call is received
150
- speaker.peer.on('call', async call => {
181
+ console.log('Setting up call handler on the peer');
182
+ // Set up call handler on the peer
183
+ speaker.connectionManager.peer.on('call', async call => {
184
+ console.log('Received call from listener');
151
185
  clearInterval(permissionCheckInterval); // Clear interval when call is received
152
- // Rest of the existing call handling code...
186
+
187
+ // Answer the call
153
188
  call.answer();
154
189
  speaker.#removeUIElems();
155
190
  speaker.#showSpinner();
156
191
  speaker.ac.createLocalAudio(document.getElementById(speaker.targetElement));
192
+
157
193
  // when we start receiving audio
158
194
  call.on('stream', async stream => {
159
195
  window.localStream = stream;
@@ -220,11 +256,15 @@ class Speaker extends AudioPeer {
220
256
  params.language,
221
257
  params.loudspeakerModelName,
222
258
  params.phrases,
223
- params.soundSubtitleId
259
+ params.soundSubtitleId,
260
+ params.calibrateSoundBurstDownsample
224
261
  );
225
262
  speaker.#removeUIElems();
263
+ //remove the call
264
+ speaker.connectionManager.peer.off('call');
226
265
  resolve(speaker.result);
227
266
  });
267
+
228
268
  // if we do not receive a result within the timeout, reject
229
269
  setTimeout(() => {
230
270
  clearInterval(permissionCheckInterval);
@@ -239,17 +279,22 @@ class Speaker extends AudioPeer {
239
279
  );
240
280
  }, timeOut);
241
281
  });
282
+
283
+ console.log('Call handler set up', speaker.connectionManager.peer);
242
284
  });
243
285
  };
244
286
 
245
- static testIIR = async (params, CalibratorInstance, IIR, timeOut = 180000) => {
246
- window.speaker = new Speaker(params, CalibratorInstance);
287
+ static testIIR = async (params, CalibratorInstance, IIR, connectionManager, timeOut = 180000) => {
288
+ window.speaker = new Speaker(params, CalibratorInstance, connectionManager);
247
289
  const {speaker} = window;
248
- speaker.initPeer();
290
+
291
+ // Set QR code parameters
292
+ connectionManager.setQueryParams(speaker.prepareQRParams());
293
+
249
294
  // wrap the calibration process in a promise so we can await it
250
295
  return new Promise((resolve, reject) => {
251
296
  // when a call is received
252
- speaker.peer.on('call', async call => {
297
+ connectionManager.peer.on('call', async call => {
253
298
  // Answer the call (one way)
254
299
  call.answer();
255
300
  speaker.#removeUIElems();
@@ -644,51 +689,54 @@ class Speaker extends AudioPeer {
644
689
  return;
645
690
  }
646
691
 
647
- switch (data.name) {
692
+ const name = data.payload.name;
693
+ const payload = data.payload.payload;
694
+
695
+ switch (name) {
648
696
  case 'samplingRate':
649
- console.log('Received sampling rate from listener: ', data.payload);
650
- if (!data.payload) {
651
- this.ac.setSamplingRates(this.calibrateSoundHz);
697
+ console.log('Received sampling rate from listener: ', payload);
698
+ if (!payload) {
699
+ window.speaker.ac.setSamplingRates(window.speaker.calibrateSoundHz);
652
700
  } else {
653
- this.ac.setSamplingRates(data.payload);
701
+ window.speaker.ac.setSamplingRates(payload);
654
702
  }
655
703
  break;
656
704
  case 'sampleSize':
657
- this.ac.setSampleSize(data.payload);
705
+ window.speaker.ac.setSampleSize(payload);
658
706
  break;
659
707
  case 'deviceType':
660
- this.ac.setDeviceType(data.payload);
708
+ window.speaker.ac.setDeviceType(payload);
661
709
  break;
662
710
  case 'deviceName':
663
- this.ac.setDeviceName(data.payload);
711
+ window.speaker.ac.setDeviceName(payload);
664
712
  break;
665
713
  case 'flags':
666
714
  //this.ac.setDeviceName(data.payload);
667
715
  console.log('FLAGS');
668
- console.log(data.payload);
669
- this.ac.setFlags(data.payload);
716
+ console.log(payload);
717
+ window.speaker.ac.setFlags(payload);
670
718
  break;
671
719
  case 'deviceInfo':
672
- this.ac.setDeviceInfo(data.payload);
673
- console.log('Received device info from listener: ', data.payload);
720
+ window.speaker.ac.setDeviceInfo(payload);
721
+ console.log('Received device info from listener: ', payload);
674
722
  break;
675
723
  case 'permissionStatus':
676
- console.log('Received permission status from listener: ', data.payload);
677
- if (data.payload.type === 'error') {
724
+ console.log('Received permission status from listener: ', payload);
725
+ if (payload.type === 'error') {
678
726
  this.permissionStatus = 'error';
679
- this.ac.setPermissionStatus('error');
680
- } else if (data.payload.type === 'denied') {
727
+ window.speaker.ac.setPermissionStatus('error');
728
+ } else if (payload.type === 'denied') {
681
729
  this.permissionStatus = 'denied';
682
- this.ac.setPermissionStatus('denied');
683
- } else if (data.payload.type === 'granted') {
730
+ window.speaker.ac.setPermissionStatus('denied');
731
+ } else if (payload.type === 'granted') {
684
732
  this.permissionStatus = 'granted';
685
- this.ac.setPermissionStatus('granted');
733
+ window.speaker.ac.setPermissionStatus('granted');
686
734
  console.log('Permission granted');
687
735
  }
688
736
  break;
689
737
  case UnsupportedDeviceError.name:
690
738
  case MissingSpeakerIdError.name:
691
- throw data.payload;
739
+ throw payload;
692
740
  break;
693
741
  default:
694
742
  break;
@@ -722,19 +770,22 @@ class Speaker extends AudioPeer {
722
770
  this.ac.downloadData();
723
771
  };
724
772
 
725
- repeatCalibration = async (params, stream, CalibratorInstance) => {
726
- this.ac = CalibratorInstance;
727
- this.#removeUIElems();
728
- this.#showSpinner();
773
+ static repeatCalibration = async (params, stream, CalibratorInstance) => {
774
+ window.speaker.ac = CalibratorInstance;
775
+ window.speaker.#removeUIElems();
776
+ window.speaker.#showSpinner();
729
777
 
730
778
  console.log('This is a repeat');
731
779
  // wrap the calibration process in a promise so we can await it
732
780
  return new Promise((resolve, reject) => {
733
781
  // Add a permission check handler
734
782
  const permissionCheckInterval = setInterval(() => {
735
- if (this.permissionStatus === 'error' || this.permissionStatus === 'denied') {
783
+ if (
784
+ window.speaker.permissionStatus === 'error' ||
785
+ window.speaker.permissionStatus === 'denied'
786
+ ) {
736
787
  clearInterval(permissionCheckInterval);
737
- this.#removeUIElems();
788
+ window.speaker.#removeUIElems();
738
789
  resolve('permission denied');
739
790
  }
740
791
  }, 100);
@@ -742,7 +793,7 @@ class Speaker extends AudioPeer {
742
793
  // Start calibration process
743
794
  (async () => {
744
795
  try {
745
- const result = await this.ac.startCalibration(
796
+ const result = await window.speaker.ac.startCalibration(
746
797
  stream,
747
798
  params.gainValues,
748
799
  params.ICalib,
@@ -791,10 +842,11 @@ class Speaker extends AudioPeer {
791
842
  params.language,
792
843
  params.loudspeakerModelName,
793
844
  params.phrases,
794
- params.soundSubtitleId
845
+ params.soundSubtitleId,
846
+ params.calibrateSoundBurstDownsample
795
847
  );
796
848
  clearInterval(permissionCheckInterval);
797
- this.#removeUIElems();
849
+ window.speaker.#removeUIElems();
798
850
  resolve(result);
799
851
  } catch (error) {
800
852
  clearInterval(permissionCheckInterval);
@@ -126,7 +126,12 @@ class PythonServerAPI {
126
126
  return res.data[task];
127
127
  };
128
128
 
129
- getMLS = async ({length, amplitude, calibrateSoundBurstMLSVersions}) => {
129
+ getMLS = async ({
130
+ length,
131
+ amplitude,
132
+ calibrateSoundBurstMLSVersions,
133
+ calibrateSoundBurstDownsample,
134
+ }) => {
130
135
  const task = 'mls';
131
136
  let res = null;
132
137
 
@@ -135,6 +140,7 @@ class PythonServerAPI {
135
140
  length: length,
136
141
  amplitude: amplitude,
137
142
  calibrateSoundBurstMLSVersions: calibrateSoundBurstMLSVersions,
143
+ calibrateSoundBurstDownsample: calibrateSoundBurstDownsample,
138
144
  });
139
145
 
140
146
  await axios({
@@ -217,13 +223,23 @@ class PythonServerAPI {
217
223
  // }
218
224
  };
219
225
 
220
- getMLSWithRetry = async ({length, amplitude, calibrateSoundBurstMLSVersions}) => {
226
+ getMLSWithRetry = async ({
227
+ length,
228
+ amplitude,
229
+ calibrateSoundBurstMLSVersions,
230
+ calibrateSoundBurstDownsample,
231
+ }) => {
221
232
  let retryCount = 0;
222
233
  let response = null;
223
234
 
224
235
  while (retryCount < this.MAX_RETRY_COUNT) {
225
236
  try {
226
- response = await this.getMLS({length, amplitude, calibrateSoundBurstMLSVersions});
237
+ response = await this.getMLS({
238
+ length,
239
+ amplitude,
240
+ calibrateSoundBurstMLSVersions,
241
+ calibrateSoundBurstDownsample,
242
+ });
227
243
  // If the request is successful, break out of the loop
228
244
  break;
229
245
  } catch (error) {
@@ -240,7 +256,7 @@ class PythonServerAPI {
240
256
  }
241
257
  };
242
258
 
243
- getPSD = async ({unconv_rec, conv_rec, sampleRate}) => {
259
+ getPSD = async ({unconv_rec, conv_rec, sampleRate, downsample}) => {
244
260
  const task = 'psd';
245
261
  let res = null;
246
262
 
@@ -249,6 +265,7 @@ class PythonServerAPI {
249
265
  unconv_rec,
250
266
  conv_rec,
251
267
  sampleRate,
268
+ downsample,
252
269
  });
253
270
 
254
271
  await axios({
@@ -320,7 +337,7 @@ class PythonServerAPI {
320
337
  }
321
338
  };
322
339
 
323
- getSubtractedPSD = async (rec, knownGains, knownFrequencies, sampleRate) => {
340
+ getSubtractedPSD = async (rec, knownGains, knownFrequencies, sampleRate, downsample) => {
324
341
  const task = 'subtracted-psd';
325
342
  let res = null;
326
343
 
@@ -330,6 +347,7 @@ class PythonServerAPI {
330
347
  knownGains,
331
348
  knownFrequencies,
332
349
  sampleRate,
350
+ downsample,
333
351
  });
334
352
 
335
353
  await axios({
@@ -350,13 +368,19 @@ class PythonServerAPI {
350
368
  return res.data[task];
351
369
  };
352
370
 
353
- getSubtractedPSDWithRetry = async (rec, knownGains, knownFrequencies, sampleRate) => {
371
+ getSubtractedPSDWithRetry = async (rec, knownGains, knownFrequencies, sampleRate, downsample) => {
354
372
  let retryCount = 0;
355
373
  let response = null;
356
374
 
357
375
  while (retryCount < this.MAX_RETRY_COUNT) {
358
376
  try {
359
- response = await this.getSubtractedPSD(rec, knownGains, knownFrequencies, sampleRate);
377
+ response = await this.getSubtractedPSD(
378
+ rec,
379
+ knownGains,
380
+ knownFrequencies,
381
+ sampleRate,
382
+ downsample
383
+ );
360
384
  // If the request is successful, break out of the loop
361
385
  break;
362
386
  } catch (error) {
@@ -373,13 +397,13 @@ class PythonServerAPI {
373
397
  }
374
398
  };
375
399
 
376
- getPSDWithRetry = async ({unconv_rec, conv_rec, sampleRate}) => {
400
+ getPSDWithRetry = async ({unconv_rec, conv_rec, sampleRate, downsample}) => {
377
401
  let retryCount = 0;
378
402
  let response = null;
379
403
 
380
404
  while (retryCount < this.MAX_RETRY_COUNT) {
381
405
  try {
382
- response = await this.getPSD({unconv_rec, conv_rec, sampleRate});
406
+ response = await this.getPSD({unconv_rec, conv_rec, sampleRate, downsample});
383
407
  // If the request is successful, break out of the loop
384
408
  break;
385
409
  } catch (error) {
@@ -411,6 +435,7 @@ class PythonServerAPI {
411
435
  calibrateSoundSmoothMinBandwidthHz,
412
436
  calibrateSoundBurstFilteredExtraDb,
413
437
  calibrateSoundIIRPhase,
438
+ downsample,
414
439
  }) => {
415
440
  const task = 'component-inverse-impulse-response';
416
441
  let res = null;
@@ -431,6 +456,7 @@ class PythonServerAPI {
431
456
  calibrateSoundSmoothMinBandwidthHz,
432
457
  calibrateSoundBurstFilteredExtraDb,
433
458
  calibrateSoundIIRPhase,
459
+ downsample,
434
460
  });
435
461
 
436
462
  await axios({
@@ -461,6 +487,7 @@ class PythonServerAPI {
461
487
  mlsAmplitude,
462
488
  calibrateSoundBurstFilteredExtraDb,
463
489
  calibrateSoundIIRPhase,
490
+ downsample,
464
491
  }) => {
465
492
  const task = 'system-inverse-impulse-response';
466
493
  let res = null;
@@ -476,6 +503,7 @@ class PythonServerAPI {
476
503
  mlsAmplitude,
477
504
  calibrateSoundBurstFilteredExtraDb,
478
505
  calibrateSoundIIRPhase,
506
+ downsample,
479
507
  });
480
508
 
481
509
  await axios({
@@ -497,7 +525,7 @@ class PythonServerAPI {
497
525
  return res.data[task];
498
526
  };
499
527
 
500
- getMLSPSD = async ({mls, sampleRate}) => {
528
+ getMLSPSD = async ({mls, sampleRate, downsample}) => {
501
529
  const task = 'mls-psd';
502
530
  let res = null;
503
531
 
@@ -505,6 +533,7 @@ class PythonServerAPI {
505
533
  task,
506
534
  mls,
507
535
  sampleRate,
536
+ downsample,
508
537
  });
509
538
 
510
539
  await axios({
@@ -526,13 +555,13 @@ class PythonServerAPI {
526
555
  return res.data[task];
527
556
  };
528
557
 
529
- getMLSPSDWithRetry = async ({mls, sampleRate}) => {
558
+ getMLSPSDWithRetry = async ({mls, sampleRate, downsample}) => {
530
559
  let retryCount = 0;
531
560
  let response = null;
532
561
 
533
562
  while (retryCount < this.MAX_RETRY_COUNT) {
534
563
  try {
535
- response = await this.getMLSPSD({mls, sampleRate});
564
+ response = await this.getMLSPSD({mls, sampleRate, downsample});
536
565
  // If the request is successful, break out of the loop
537
566
  break;
538
567
  } catch (error) {
@@ -566,6 +595,7 @@ class PythonServerAPI {
566
595
  calibrateSoundSmoothMinBandwidthHz,
567
596
  calibrateSoundBurstFilteredExtraDb,
568
597
  calibrateSoundIIRPhase,
598
+ downsample,
569
599
  }) => {
570
600
  let retryCount = 0;
571
601
  let response = null;
@@ -587,6 +617,7 @@ class PythonServerAPI {
587
617
  calibrateSoundSmoothMinBandwidthHz,
588
618
  calibrateSoundBurstFilteredExtraDb,
589
619
  calibrateSoundIIRPhase,
620
+ downsample,
590
621
  });
591
622
  // If the request is successful, break out of the loop
592
623
  break;
@@ -616,6 +647,7 @@ class PythonServerAPI {
616
647
  mlsAmplitude,
617
648
  calibrateSoundBurstFilteredExtraDb,
618
649
  calibrateSoundIIRPhase,
650
+ downsample,
619
651
  }) => {
620
652
  let retryCount = 0;
621
653
  let response = null;
@@ -632,6 +664,7 @@ class PythonServerAPI {
632
664
  mlsAmplitude,
633
665
  calibrateSoundBurstFilteredExtraDb,
634
666
  calibrateSoundIIRPhase,
667
+ downsample,
635
668
  });
636
669
  // If the request is successful, break out of the loop
637
670
  break;
@@ -746,7 +779,15 @@ class PythonServerAPI {
746
779
  return res.data[task];
747
780
  };
748
781
 
749
- allHzPowerCheck = async ({payload, sampleRate, binDesiredSec, burstSec, repeats, warmUp}) => {
782
+ allHzPowerCheck = async ({
783
+ payload,
784
+ sampleRate,
785
+ binDesiredSec,
786
+ burstSec,
787
+ repeats,
788
+ warmUp,
789
+ downsample,
790
+ }) => {
750
791
  const task = 'all-hz-check';
751
792
  let res = null;
752
793
 
@@ -759,6 +800,7 @@ class PythonServerAPI {
759
800
  burstSec,
760
801
  repeats,
761
802
  warmUp,
803
+ downsample,
762
804
  });
763
805
 
764
806
  await axios({