speaker-calibration 2.1.12 → 2.1.14

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.1.12",
3
+ "version": "2.1.14",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -26,6 +26,12 @@ class ImpulseResponse extends AudioCalibrator {
26
26
  this.#highHz = highHz;
27
27
  }
28
28
 
29
+ /** @private */
30
+ stepNum = 0;
31
+
32
+ /** @private */
33
+ totalSteps = 25;
34
+
29
35
  /** @private */
30
36
  #download;
31
37
 
@@ -81,7 +87,8 @@ class ImpulseResponse extends AudioCalibrator {
81
87
  const mls = this.#mls;
82
88
  const lowHz = this.#lowHz;
83
89
  const highHz = this.#highHz;
84
- this.emit('update', {message: `computing the IIR...`});
90
+ this.stepNum += 1;
91
+ this.emit('update', {message: `Step ${this.stepNum}/${this.totalSteps}: computing the IIR...`});
85
92
  return this.pyServerAPI
86
93
  .getInverseImpulseResponse({
87
94
  payload: computedIRs.slice(0, this.numCaptures),
@@ -91,7 +98,8 @@ class ImpulseResponse extends AudioCalibrator {
91
98
  })
92
99
  .then(res => {
93
100
  console.log(res);
94
- this.emit('update', {message: `done computing the IIR...`});
101
+ this.stepNum += 1;
102
+ this.emit('update', {message: `Step ${this.stepNum}/${this.totalSteps}: done computing the IIR...`});
95
103
  this.invertedImpulseResponse = res["iir"];
96
104
  this.convolution = res["convolution"];
97
105
  })
@@ -115,8 +123,9 @@ class ImpulseResponse extends AudioCalibrator {
115
123
  const mls = this.#mls;
116
124
  const payload =
117
125
  signalCsv && signalCsv.length > 0 ? csvToArray(signalCsv) : allSignals[numSignals - 1];
118
-
119
- this.emit('update', {message: `computing the IR of the last recording...`});
126
+ console.log('sending rec');
127
+ this.stepNum += 1;
128
+ this.emit('update', {message: `Step: ${this.stepNum}/${this.totalSteps}: computing the IR of the last recording...`});
120
129
  this.impulseResponses.push(
121
130
  this.pyServerAPI
122
131
  .getImpulseResponse({
@@ -129,8 +138,9 @@ class ImpulseResponse extends AudioCalibrator {
129
138
  if (this.numSuccessfulCaptured < this.numCaptures) {
130
139
  this.numSuccessfulCaptured += 1;
131
140
  console.log("num succ capt: " + this.numSuccessfulCaptured);
141
+ this.stepNum += 1;
132
142
  this.emit('update', {
133
- message: `${this.numSuccessfulCaptured}/${this.numCaptures} IRs computed...`,
143
+ message: `Step: ${this.stepNum}/${this.totalSteps}: ${this.numSuccessfulCaptured}/${this.numCaptures} IRs computed...`,
134
144
  });
135
145
  }
136
146
  return res;
@@ -150,8 +160,9 @@ class ImpulseResponse extends AudioCalibrator {
150
160
  #awaitDesiredMLSLength = async () => {
151
161
  // seconds per MLS = P / SR
152
162
  // await N * P / SR
163
+ this.stepNum += 1;
153
164
  this.emit('update', {
154
- message: `sampling the calibration signal...`,
165
+ message: `Step ${this.stepNum}/${this.totalSteps}: sampling the calibration signal...`,
155
166
  });
156
167
  await sleep((this.#P / this.sourceSamplingRate) * this.numMLSPerCapture);
157
168
  };
@@ -164,8 +175,9 @@ class ImpulseResponse extends AudioCalibrator {
164
175
  * @example
165
176
  */
166
177
  #awaitSignalOnset = async () => {
178
+ this.stepNum += 1;
167
179
  this.emit('update', {
168
- message: `waiting for the signal to stabalize...`,
180
+ message: `Step ${this.stepNum}/${this.totalSteps}: waiting for the signal to stabilize...`,
169
181
  });
170
182
  await sleep(this.TAPER_SECS);
171
183
  };
@@ -180,6 +192,7 @@ class ImpulseResponse extends AudioCalibrator {
180
192
  if (this.#download) {
181
193
  this.downloadData();
182
194
  }
195
+ console.log('after record');
183
196
  this.sendRecordingToServerForProcessing();
184
197
  };
185
198
 
@@ -189,8 +202,9 @@ class ImpulseResponse extends AudioCalibrator {
189
202
  }
190
203
  if (this.numSuccessfulCaptured < this.numCaptures) {
191
204
  this.numSuccessfulCaptured += 1;
205
+ this.stepNum += 1;
192
206
  this.emit('update', {
193
- message: `${this.numSuccessfulCaptured}/${this.numCaptures} IRs computed...`,
207
+ message: `Step ${this.stepNum}/${this.totalSteps}: ${this.numSuccessfulCaptured} recordings of convolved MLS captured`,
194
208
  });
195
209
  }
196
210
  };
@@ -349,14 +363,15 @@ class ImpulseResponse extends AudioCalibrator {
349
363
  #playCalibrationAudio = () => {
350
364
  this.calibrationNodes[0].start(0);
351
365
  this.#mls = this.calibrationNodes[0].buffer.getChannelData(0);
352
- console.log(this.#mls);
353
- this.emit('update', {message: 'playing the calibration tone...'});
366
+ this.stepNum += 1;
367
+ this.emit('update', {message: `Step: ${this.stepNum}/${this.totalSteps}: playing the calibration tone...`});
354
368
  };
355
369
 
356
370
 
357
371
  #playCalibrationAudioConvolved = () => {
358
372
  this.calibrationNodesConvolved[0].start(0);
359
- this.emit('update',{message: 'playing the convolved calibration tone...'})
373
+ this.stepNum += 1;
374
+ this.emit('update',{message: `Step: ${this.stepNum}/${this.totalSteps}: playing the convolved calibration tone...`})
360
375
  }
361
376
 
362
377
  /** .
@@ -375,7 +390,8 @@ class ImpulseResponse extends AudioCalibrator {
375
390
  this.offsetGainNode.gain.setTargetAtTime(0, this.sourceAudioContext.currentTime, 0.5);
376
391
  this.calibrationNodes[0].stop(0);
377
392
  this.sourceAudioContext.close();
378
- this.emit('update', {message: 'stopping the calibration tone...'});
393
+ this.stepNum += 1;
394
+ this.emit('update', {message: `Step ${this.stepNum}/${this.totalSteps}: stopping the calibration tone...`});
379
395
  };
380
396
 
381
397
  #stopCalibrationAudioConvolved = () => {
@@ -388,7 +404,8 @@ class ImpulseResponse extends AudioCalibrator {
388
404
  //this.calibrationNodesConvolved[0].stop(0);
389
405
  console.log("right before closing volved audio context");
390
406
  this.sourceAudioContextConvolved.close();
391
- this.emit('update', {message: 'stopping the convolved calibration tone...'});
407
+ this.stepNum += 1;
408
+ this.emit('update', {message: `Step ${this.stepNum}/${this.totalSteps}: stopping the convolved calibration tone...`});
392
409
 
393
410
  }
394
411