speaker-calibration 2.2.167 → 2.2.169

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.167",
3
+ "version": "2.2.169",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -41,6 +41,7 @@ class Speaker extends AudioPeer {
41
41
  this.timeToCalibrate = params?.timeToCalibrate ?? 10;
42
42
  this.isParticipant = params?.isParticipant ?? false;
43
43
  this.isLoudspeakerCalibration = params?.isLoudspeakerCalibration ?? false;
44
+ this.buttonsContainer = params?.buttonsContainer ?? document.createElement('div');
44
45
 
45
46
  /* Set up callbacks that handle any events related to our peer object. */
46
47
  this.peer.on('open', this.#onPeerOpen);
@@ -49,6 +50,9 @@ class Speaker extends AudioPeer {
49
50
  this.peer.on('disconnected', this.#onPeerDisconnected);
50
51
  this.peer.on('error', this.#onPeerError);
51
52
  }
53
+
54
+ uri = '';
55
+ qrImage;
52
56
  /**
53
57
  * Async factory method that creates the Speaker object, and returns a promise that resolves to the result of the calibration.
54
58
  *
@@ -90,7 +94,6 @@ class Speaker extends AudioPeer {
90
94
  }
91
95
 
92
96
  // resolve when we have a result
93
- console.log(params);
94
97
  speaker.result = await speaker.ac.startCalibration(
95
98
  stream,
96
99
  params.gainValues,
@@ -197,6 +200,7 @@ class Speaker extends AudioPeer {
197
200
  * @private
198
201
  * @example
199
202
  */
203
+
200
204
  #showQRCode = () => {
201
205
  // Get query string, the URL parameters to specify a Listener
202
206
  const queryStringParameters = {
@@ -207,15 +211,20 @@ class Speaker extends AudioPeer {
207
211
  lang: this.language,
208
212
  };
209
213
  const queryString = this.queryStringFromObject(queryStringParameters);
210
- const uri = this.siteUrl + queryString;
214
+ this.uri = this.siteUrl + queryString;
211
215
  if (this.isSmartPhone) {
212
216
  // Display QR code for the participant to scan
213
217
  const qrCanvas = document.createElement('canvas');
214
218
  qrCanvas.setAttribute('id', 'qrCanvas');
215
- console.log(uri);
216
- QRCode.toCanvas(qrCanvas, uri, error => {
219
+ QRCode.toCanvas(qrCanvas, this.uri, error => {
217
220
  if (error) console.error(error);
218
221
  });
222
+ const explanation = document.createElement("p");
223
+ explanation.id = "skipQRExplanation";
224
+ explanation.innerHTML = phrases.RC_skipQR_ExplanationWithoutPreferNot[this.language]
225
+ .replace("xxx", `<b>${this.uri}</b>`)
226
+ .replace("XXX", `<b>${this.uri}</b>`);
227
+
219
228
  const qrImage = new Image(400, 400);
220
229
  qrImage.setAttribute('id', 'compatibilityCheckQRImage');
221
230
  qrImage.style.zIndex = Infinity;
@@ -225,7 +234,21 @@ class Speaker extends AudioPeer {
225
234
  qrImage.src = qrCanvas.toDataURL();
226
235
  qrImage.style.maxHeight = '150px';
227
236
  qrImage.style.maxWidth = '150px';
228
- document.getElementById(this.targetElement).appendChild(qrImage);
237
+
238
+ this.qrImage = qrImage;
239
+
240
+ const container = document.createElement("div");
241
+ container.style.display = "flex";
242
+ container.style.justifyContent = "space-between";
243
+ container.style.alignItems = "center";
244
+ container.id = "skipQRContainer";
245
+ container.appendChild(qrImage);
246
+ container.appendChild(explanation);
247
+ const qrContainer = document.createElement("div");
248
+ qrContainer.appendChild(container);
249
+ qrContainer.appendChild(this.buttonsContainer);
250
+
251
+ document.getElementById(this.targetElement).appendChild(qrContainer);
229
252
  } else {
230
253
  // show the link to the user
231
254
  // If specified HTML Id is available, show QR code there
@@ -251,7 +274,7 @@ class Speaker extends AudioPeer {
251
274
  }
252
275
  }
253
276
  // or just print it to console
254
- console.log('TEST: Peer reachable at: ', uri);
277
+ console.log('TEST: Peer reachable at: ', this.uri);
255
278
  };
256
279
 
257
280
  #showSpinner = () => {
@@ -743,6 +743,7 @@ class Combination extends AudioCalibrator {
743
743
  */
744
744
  #afterMLSRecord = async () => {
745
745
  console.log('after record');
746
+ this.addTimeStamp(`After record unfiltered mls version ${this.icapture}`);
746
747
  await this.sendRecordingToServerForProcessing();
747
748
  };
748
749
 
@@ -854,11 +855,11 @@ class Combination extends AudioCalibrator {
854
855
  * @example
855
856
  */
856
857
  #playCalibrationAudio = () => {
857
- this.addTimeStamp('Play unfiltered mls');
858
858
  this.calibrationNodes[0].start(0);
859
859
  this.status = ``;
860
860
  if (this.mode === 'unfiltered') {
861
861
  console.log('play calibration audio ' + this.stepNum);
862
+ this.addTimeStamp(`Play MLS version ${this.icapture}`);
862
863
  this.status =
863
864
  `All Hz Calibration: playing the calibration tone...`.toString() +
864
865
  this.generateTemplate().toString();
@@ -2147,7 +2148,6 @@ class Combination extends AudioCalibrator {
2147
2148
  const audioContext = this.makeNewSourceAudioContext();
2148
2149
  const oscilator = audioContext.createOscillator();
2149
2150
  const gainNode = audioContext.createGain();
2150
- console.log(gainValue);
2151
2151
  const taperGainNode = audioContext.createGain();
2152
2152
  const offsetGainNode = audioContext.createGain();
2153
2153
  const totalDuration = this.CALIBRATION_TONE_DURATION * 1.2;