speaker-calibration 2.2.3 → 2.2.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speaker-calibration",
3
- "version": "2.2.3",
3
+ "version": "2.2.6",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -9,6 +9,7 @@ import {
9
9
 
10
10
  import database from '../config/firebase';
11
11
  import {ref, set, get, child} from 'firebase/database';
12
+ import {phrases} from '../../dist/example/i18n';
12
13
 
13
14
  /**
14
15
  * @class Handles the speaker's side of the connection. Responsible for initiating the connection,
@@ -31,6 +32,9 @@ class Speaker extends AudioPeer {
31
32
  this.result = null;
32
33
  this.debug = params?.debug ?? false;
33
34
  this.isSmartPhone = params?.isSmartPhone ?? false;
35
+ this.instructionDisplayId = params?.instructionDisplayId ?? '';
36
+ this.titleDisplayId = params?.titleDisplayId ?? '';
37
+ this.timeToCalibrate = params?.timeToCalibrate ?? 10;
34
38
 
35
39
  /* Set up callbacks that handle any events related to our peer object. */
36
40
  this.peer.on('open', this.#onPeerOpen);
@@ -215,6 +219,40 @@ class Speaker extends AudioPeer {
215
219
  spinner.role = 'status';
216
220
  spinner.ariaHidden = 'true';
217
221
  document.getElementById(this.targetElement).appendChild(spinner);
222
+
223
+ // clear instructionDisplay
224
+ const instructionDisplay = document.getElementById(this.instructionDisplayId);
225
+ const background = document.getElementById('background'); // todo: get background id from params
226
+ if (instructionDisplay) {
227
+ instructionDisplay.innerHTML = '';
228
+ instructionDisplay.style.whiteSpace = 'nowrap';
229
+ instructionDisplay.style.fontWeight = 'bold';
230
+ instructionDisplay.style.width = 'fit-content';
231
+ instructionDisplay.innerHTML = phrases.RC_soundRecording['en-US'];
232
+ let fontSize = 100;
233
+ instructionDisplay.style.fontSize = fontSize + 'px';
234
+ while (instructionDisplay.scrollWidth > background.scrollWidth * 0.9 && fontSize > 10) {
235
+ fontSize--;
236
+ instructionDisplay.style.fontSize = fontSize + 'px';
237
+ }
238
+ const p = document.createElement('p');
239
+ // font size
240
+ p.style.fontSize = '1.1rem';
241
+ p.style.fontWeight = 'normal';
242
+ p.style.paddingTop = '20px';
243
+ const timeToCalibrateText = phrases.RC_howLongToCalibrate['en-US'];
244
+ p.innerHTML = timeToCalibrateText.replace('111', this.timeToCalibrate);
245
+ instructionDisplay.appendChild(p);
246
+ }
247
+
248
+ // Update title - titleDisplayId
249
+ const titleDisplay = document.getElementById(this.titleDisplayId);
250
+ if (titleDisplay) {
251
+ // replace 2 with 3
252
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('2', '3');
253
+ // replace 1 with 3
254
+ titleDisplay.innerHTML = titleDisplay.innerHTML.replace('1', '3');
255
+ }
218
256
  };
219
257
 
220
258
  #removeUIElems = () => {
@@ -342,7 +342,9 @@ class Combination extends AudioCalibrator {
342
342
  this.stepNum += 1;
343
343
  console.log('await desired length ' + this.stepNum);
344
344
  this.status =
345
- `All Hz Calibration: sampling the calibration signal...`.toString() + this.generateTemplate();
345
+ `All Hz Calibration: sampling the calibration signal...`.toString() +
346
+ `\n iteration Count: ${this.stepNum}` +
347
+ this.generateTemplate();
346
348
  this.emit('update', {
347
349
  message: this.status,
348
350
  });
@@ -356,7 +358,10 @@ class Combination extends AudioCalibrator {
356
358
  this.stepNum += 1;
357
359
  console.log('await desired length ' + this.stepNum);
358
360
  this.status =
359
- `All Hz Calibration: sampling the calibration signal...`.toString() + this.generateTemplate();
361
+ `All Hz Calibration: sampling the calibration signal...`.toString() +
362
+ `\n iteration Count: ${this.stepNum}`;
363
+ +this.generateTemplate();
364
+
360
365
  this.emit('update', {
361
366
  message: this.status,
362
367
  });