speaker-calibration 2.2.240 → 2.2.242

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.240",
3
+ "version": "2.2.242",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -320,7 +320,7 @@ class Combination extends AudioCalibrator {
320
320
  .replace('111', this.sourceSamplingRate)
321
321
  .replace('222', this.sinkSamplingRate)
322
322
  .replace('333', this.calibrateSoundSamplingDesiredBits);
323
- const reportParameters = `${samplingParamText}`;
323
+ const reportParameters = `${samplingParamText} ↓${this._calibrateSoundBurstDownsample}:1`;
324
324
  if (this.flags) {
325
325
  flags = `<br> autoGainControl: ${this.flags.autoGainControl}, echoCancellation: ${this.flags.echoCancellation}, noiseSuppression: ${this.flags.noiseSuppression}`;
326
326
  }
@@ -397,12 +397,12 @@ class Combination extends AudioCalibrator {
397
397
  this.emit('update', {message: this.status});
398
398
  const filteredComputedIRs_slice = filteredComputedIRs.slice(0, this.numCaptures);
399
399
  // for each element in filteredComputedIRs_slice, downsample it
400
- const payload_downsampled = filteredComputedIRs_slice.map(ir =>
401
- this.downsampleSignal(ir, this._calibrateSoundBurstDownsample)
402
- );
400
+ // const payload_downsampled = filteredComputedIRs_slice.map(ir =>
401
+ // this.downsampleSignal(ir, this._calibrateSoundBurstDownsample)
402
+ // );
403
403
  return await this.pyServerAPI
404
404
  .getSystemInverseImpulseResponseWithRetry({
405
- payload: payload_downsampled,
405
+ payload: filteredComputedIRs_slice,
406
406
  mls,
407
407
  lowHz,
408
408
  highHz,
@@ -471,9 +471,9 @@ class Combination extends AudioCalibrator {
471
471
  const fMLS = this.sourceSamplingRate / this._calibrateSoundBurstDownsample;
472
472
  const filteredComputedIRs_slice = filteredComputedIRs.slice(0, this.numCaptures);
473
473
  // for each element in filteredComputedIRs_slice, downsample it
474
- const payload_downsampled = filteredComputedIRs_slice.map(ir =>
475
- this.downsampleSignal(ir, this._calibrateSoundBurstDownsample)
476
- );
474
+ // const payload_downsampled = filteredComputedIRs_slice.map(ir =>
475
+ // this.downsampleSignal(ir, this._calibrateSoundBurstDownsample)
476
+ // );
477
477
  let componentIRGains = this.componentIR['Gain'];
478
478
  const componentIRFreqs = this.componentIR['Freq'];
479
479
  //normalize the component IR gains
@@ -503,7 +503,7 @@ class Combination extends AudioCalibrator {
503
503
 
504
504
  return this.pyServerAPI
505
505
  .getComponentInverseImpulseResponseWithRetry({
506
- payload: payload_downsampled,
506
+ payload: filteredComputedIRs_slice,
507
507
  mls,
508
508
  lowHz,
509
509
  highHz,
@@ -710,7 +710,7 @@ class Combination extends AudioCalibrator {
710
710
  binDesiredSec: this._calibrateSoundPowerBinDesiredSec,
711
711
  burstSec: this.desired_time_per_mls,
712
712
  repeats: this.numMLSPerCapture - this.num_mls_to_skip,
713
- warmUp: this.num_mls_to_skip,
713
+ warmUp: this._calibrateSoundBurstPreSec,
714
714
  downsample: this._calibrateSoundBurstDownsample,
715
715
  })
716
716
  .then(async result => {
@@ -757,7 +757,7 @@ class Combination extends AudioCalibrator {
757
757
  `(${pre.toFixed(1)} + ${repeats}×${burst.toFixed(1)} + ${post.toFixed(
758
758
  1
759
759
  )} s) of MLS ver.` +
760
- ` ${this.icapture}. SD = ${result['sd']} > ${this._calibrateSoundBurstMaxSD_dB}`
760
+ ` ${this.icapture}. SD = ${result['sd']} <= ${this._calibrateSoundBurstMaxSD_dB}`
761
761
  );
762
762
  } else {
763
763
  console.log(
@@ -857,22 +857,30 @@ class Combination extends AudioCalibrator {
857
857
  message: this.status,
858
858
  });
859
859
  let time_to_wait = 0;
860
- const fMLS = this.sourceSamplingRate / this._calibrateSoundBurstDownsample;
861
860
  if (this.mode === 'unfiltered') {
862
861
  //unfiltered
863
- time_to_wait = (this.#mls[0].length / fMLS) * this.numMLSPerCapture;
864
- time_to_wait = time_to_wait + this._calibrateSoundBurstPostSec;
862
+ //should be: pre + (burst * repeats) + post
863
+ // time_to_wait = (this.#mls[0].length / this.sourceSamplingRate) * this.numMLSPerCapture;
864
+ // time_to_wait = time_to_wait + this._calibrateSoundBurstPostSec;
865
+ time_to_wait =
866
+ this._calibrateSoundBurstPreSec +
867
+ this._calibrateSoundBurstSec * this._calibrateSoundBurstRepeats +
868
+ this._calibrateSoundBurstPostSec;
865
869
  } else if (this.mode === 'filtered') {
866
870
  //filtered
867
871
  // time_to_wait =
868
872
  // (this.#currentConvolution.length / this.sourceSamplingRate) *
869
873
  // (this.numMLSPerCapture / (this.num_mls_to_skip + this.numMLSPerCapture));
870
- time_to_wait = (this.#currentConvolution.length / fMLS) * this.numMLSPerCapture;
871
- time_to_wait = time_to_wait + this._calibrateSoundBurstPostSec;
874
+ // time_to_wait =
875
+ // (this.#currentConvolution.length / this.sourceSamplingRate) * this.numMLSPerCapture;
876
+ // time_to_wait = time_to_wait + this._calibrateSoundBurstPostSec;
877
+ time_to_wait =
878
+ this._calibrateSoundBurstPreSec +
879
+ this._calibrateSoundBurstSec * this._calibrateSoundBurstRepeats +
880
+ this._calibrateSoundBurstPostSec;
872
881
  } else {
873
882
  throw new Error('Mode broke in awaitDesiredMLSLength');
874
883
  }
875
-
876
884
  await sleep(time_to_wait);
877
885
  };
878
886
 
@@ -908,15 +916,15 @@ class Combination extends AudioCalibrator {
908
916
  });
909
917
  let number_of_bursts_to_skip = 0;
910
918
  let time_to_sleep = 0;
911
- const fMLS = this.sourceSamplingRate / this._calibrateSoundBurstDownsample;
912
919
  if (this.mode === 'unfiltered') {
913
- time_to_sleep = (this.#mls[0].length / fMLS) * number_of_bursts_to_skip;
920
+ time_to_sleep = (this.#mls[0].length / this.sourceSamplingRate) * number_of_bursts_to_skip;
914
921
  } else if (this.mode === 'filtered') {
915
922
  console.log(this.#currentConvolution.length);
916
923
  // time_to_sleep =
917
924
  // (this.#currentConvolution.length / this.sourceSamplingRate) *
918
925
  // (number_of_bursts_to_skip / (number_of_bursts_to_skip + this.numMLSPerCapture));
919
- time_to_sleep = (this.#currentConvolution.length / fMLS) * number_of_bursts_to_skip;
926
+ time_to_sleep =
927
+ (this.#currentConvolution.length / this.sourceSamplingRate) * number_of_bursts_to_skip;
920
928
  } else {
921
929
  throw new Error('Mode broke in awaitSignalOnset');
922
930
  }
@@ -1289,8 +1297,8 @@ class Combination extends AudioCalibrator {
1289
1297
  if (this.isCalibrating) return null;
1290
1298
  let component_iir_psd = await this.pyServerAPI
1291
1299
  .getPSDWithRetry({
1292
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
1293
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
1300
+ unconv_rec,
1301
+ conv_rec,
1294
1302
  sampleRate: fMLS,
1295
1303
  downsample: this._calibrateSoundBurstDownsample,
1296
1304
  })
@@ -1311,8 +1319,8 @@ class Combination extends AudioCalibrator {
1311
1319
  if (this.isCalibrating) return null;
1312
1320
  let system_iir_psd = await this.pyServerAPI
1313
1321
  .getPSDWithRetry({
1314
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
1315
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
1322
+ unconv_rec,
1323
+ conv_rec,
1316
1324
  sampleRate: fMLS,
1317
1325
  downsample: this._calibrateSoundBurstDownsample,
1318
1326
  })
@@ -1352,7 +1360,7 @@ class Combination extends AudioCalibrator {
1352
1360
  if (this.isCalibrating) return null;
1353
1361
  let system_filtered_mls_psd = await this.pyServerAPI
1354
1362
  .getMLSPSDWithRetry({
1355
- mls: this.downsampleSignal(this.systemConvolution, this._calibrateSoundBurstDownsample),
1363
+ mls: this.systemConvolution,
1356
1364
  sampleRate: fMLS,
1357
1365
  downsample: this._calibrateSoundBurstDownsample,
1358
1366
  })
@@ -1370,10 +1378,7 @@ class Combination extends AudioCalibrator {
1370
1378
 
1371
1379
  let system_no_bandpass_filtered_mls_psd = await this.pyServerAPI
1372
1380
  .getMLSPSDWithRetry({
1373
- mls: this.downsampleSignal(
1374
- this.systemConvolutionNoBandpass,
1375
- this._calibrateSoundBurstDownsample
1376
- ),
1381
+ mls: this.systemConvolutionNoBandpass,
1377
1382
  sampleRate: fMLS,
1378
1383
  downsample: this._calibrateSoundBurstDownsample,
1379
1384
  })
@@ -1393,7 +1398,7 @@ class Combination extends AudioCalibrator {
1393
1398
  if (this.isCalibrating) return null;
1394
1399
  let component_filtered_mls_psd = await this.pyServerAPI
1395
1400
  .getMLSPSDWithRetry({
1396
- mls: this.downsampleSignal(this.componentConvolution, this._calibrateSoundBurstDownsample),
1401
+ mls: this.componentConvolution,
1397
1402
  sampleRate: fMLS,
1398
1403
  downsample: this._calibrateSoundBurstDownsample,
1399
1404
  })
@@ -1411,10 +1416,7 @@ class Combination extends AudioCalibrator {
1411
1416
 
1412
1417
  let component_no_bandpass_filtered_mls_psd = await this.pyServerAPI
1413
1418
  .getMLSPSDWithRetry({
1414
- mls: this.downsampleSignal(
1415
- this.componentConvolutionNoBandpass,
1416
- this._calibrateSoundBurstDownsample
1417
- ),
1419
+ mls: this.componentConvolutionNoBandpass,
1418
1420
  sampleRate: fMLS,
1419
1421
  downsample: this._calibrateSoundBurstDownsample,
1420
1422
  })
@@ -1684,8 +1686,8 @@ class Combination extends AudioCalibrator {
1684
1686
 
1685
1687
  let component_iir_psd = await this.pyServerAPI
1686
1688
  .getPSDWithRetry({
1687
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
1688
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
1689
+ unconv_rec: this.componentInvertedImpulseResponseNoBandpass,
1690
+ conv_rec: this.componentInvertedImpulseResponse,
1689
1691
  sampleRate: fMLS,
1690
1692
  downsample: this._calibrateSoundBurstDownsample,
1691
1693
  })
@@ -1706,8 +1708,8 @@ class Combination extends AudioCalibrator {
1706
1708
  if (this.isCalibrating) return null;
1707
1709
  let system_iir_psd = await this.pyServerAPI
1708
1710
  .getPSDWithRetry({
1709
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
1710
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
1711
+ unconv_rec: this.systemInvertedImpulseResponseNoBandpass,
1712
+ conv_rec: this.systemInvertedImpulseResponse,
1711
1713
  sampleRate: fMLS,
1712
1714
  downsample: this._calibrateSoundBurstDownsample,
1713
1715
  })
@@ -1750,10 +1752,7 @@ class Combination extends AudioCalibrator {
1750
1752
  if (this.isCalibrating) return null;
1751
1753
  let filtered_mls_psd = await this.pyServerAPI
1752
1754
  .getMLSPSDWithRetry({
1753
- mls: this.downsampleSignal(
1754
- this.componentConvolution,
1755
- this._calibrateSoundBurstDownsample
1756
- ),
1755
+ mls: this.componentConvolution,
1757
1756
  sampleRate: fMLS,
1758
1757
  downsample: this._calibrateSoundBurstDownsample,
1759
1758
  })
@@ -1771,10 +1770,7 @@ class Combination extends AudioCalibrator {
1771
1770
 
1772
1771
  let filtered_no_bandpass_mls_psd = await this.pyServerAPI
1773
1772
  .getMLSPSDWithRetry({
1774
- mls: this.downsampleSignal(
1775
- this.componentConvolutionNoBandpass,
1776
- this._calibrateSoundBurstDownsample
1777
- ),
1773
+ mls: this.componentConvolutionNoBandpass,
1778
1774
  sampleRate: fMLS,
1779
1775
  downsample: this._calibrateSoundBurstDownsample,
1780
1776
  })
@@ -1907,8 +1903,8 @@ class Combination extends AudioCalibrator {
1907
1903
  if (this.isCalibrating) return null;
1908
1904
  let component_iir_psd = await this.pyServerAPI
1909
1905
  .getPSDWithRetry({
1910
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
1911
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
1906
+ unconv_rec: this.componentInvertedImpulseResponseNoBandpass,
1907
+ conv_rec: this.componentInvertedImpulseResponse,
1912
1908
  sampleRate: fMLS,
1913
1909
  downsample: this._calibrateSoundBurstDownsample,
1914
1910
  })
@@ -1929,8 +1925,8 @@ class Combination extends AudioCalibrator {
1929
1925
  if (this.isCalibrating) return null;
1930
1926
  let system_iir_psd = await this.pyServerAPI
1931
1927
  .getPSDWithRetry({
1932
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
1933
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
1928
+ unconv_rec: this.systemInvertedImpulseResponseNoBandpass,
1929
+ conv_rec: this.systemInvertedImpulseResponse,
1934
1930
  sampleRate: fMLS,
1935
1931
  downsample: this._calibrateSoundBurstDownsample,
1936
1932
  })
@@ -1973,7 +1969,7 @@ class Combination extends AudioCalibrator {
1973
1969
  if (this.isCalibrating) return null;
1974
1970
  let filtered_mls_psd = await this.pyServerAPI
1975
1971
  .getMLSPSDWithRetry({
1976
- mls: this.downsampleSignal(this.systemConvolution, this._calibrateSoundBurstDownsample),
1972
+ mls: this.systemConvolution,
1977
1973
  sampleRate: fMLS,
1978
1974
  downsample: this._calibrateSoundBurstDownsample,
1979
1975
  })
@@ -1991,10 +1987,7 @@ class Combination extends AudioCalibrator {
1991
1987
 
1992
1988
  let filtered_no_bandpass_mls_psd = await this.pyServerAPI
1993
1989
  .getMLSPSDWithRetry({
1994
- mls: this.downsampleSignal(
1995
- this.systemConvolutionNoBandpass,
1996
- this._calibrateSoundBurstDownsample
1997
- ),
1990
+ mls: this.systemConvolutionNoBandpass,
1998
1991
  sampleRate: fMLS,
1999
1992
  downsample: this._calibrateSoundBurstDownsample,
2000
1993
  })
@@ -2233,8 +2226,8 @@ class Combination extends AudioCalibrator {
2233
2226
  if (this.isCalibrating) return null;
2234
2227
  let component_iir_psd = await this.pyServerAPI
2235
2228
  .getPSDWithRetry({
2236
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
2237
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
2229
+ unconv_rec: this.componentInvertedImpulseResponseNoBandpass,
2230
+ conv_rec: this.componentInvertedImpulseResponse,
2238
2231
  sampleRate: fMLS,
2239
2232
  downsample: this._calibrateSoundBurstDownsample,
2240
2233
  })
@@ -2254,8 +2247,8 @@ class Combination extends AudioCalibrator {
2254
2247
  if (this.isCalibrating) return null;
2255
2248
  let system_iir_psd = await this.pyServerAPI
2256
2249
  .getPSDWithRetry({
2257
- unconv_rec: this.downsampleSignal(unconv_rec, this._calibrateSoundBurstDownsample),
2258
- conv_rec: this.downsampleSignal(conv_rec, this._calibrateSoundBurstDownsample),
2250
+ unconv_rec: this.systemInvertedImpulseResponseNoBandpass,
2251
+ conv_rec: this.systemInvertedImpulseResponse,
2259
2252
  sampleRate: fMLS,
2260
2253
  downsample: this._calibrateSoundBurstDownsample,
2261
2254
  })
@@ -2425,7 +2418,7 @@ class Combination extends AudioCalibrator {
2425
2418
  const gainNode = audioContext.createGain();
2426
2419
  const taperGainNode = audioContext.createGain();
2427
2420
  const offsetGainNode = audioContext.createGain();
2428
- const totalDuration = this.CALIBRATION_TONE_DURATION * 1.2;
2421
+ const totalDuration = this.CALIBRATION_TONE_DURATION;
2429
2422
 
2430
2423
  oscilator.frequency.value = this.#CALIBRATION_TONE_FREQUENCY;
2431
2424
  oscilator.type = this.#CALIBRATION_TONE_TYPE;
@@ -2508,7 +2501,7 @@ class Combination extends AudioCalibrator {
2508
2501
  message: this.status,
2509
2502
  });
2510
2503
  }
2511
- const totalDuration = this.CALIBRATION_TONE_DURATION * 1.2;
2504
+ const totalDuration = this.CALIBRATION_TONE_DURATION;
2512
2505
  console.log('this.calibrationNodes', this.calibrationNodes);
2513
2506
  this.calibrationNodes[0].start(0);
2514
2507
  this.calibrationNodes[0].stop(totalDuration);
@@ -2559,7 +2552,7 @@ class Combination extends AudioCalibrator {
2559
2552
  getPower(rec.slice(0, this.calibrateSound1000HzPreSec * this.sourceSamplingRate)).toFixed(1)
2560
2553
  );
2561
2554
  console.log(
2562
- 'pre period power: ',
2555
+ 'sec period power: ',
2563
2556
  getPower(
2564
2557
  rec.slice(
2565
2558
  this.calibrateSound1000HzPreSec * this.sourceSamplingRate,
@@ -2568,7 +2561,7 @@ class Combination extends AudioCalibrator {
2568
2561
  ).toFixed(1)
2569
2562
  );
2570
2563
  console.log(
2571
- 'pre period power: ',
2564
+ 'post period power: ',
2572
2565
  getPower(
2573
2566
  rec.slice(
2574
2567
  (this.calibrateSound1000HzPreSec + this.calibrateSound1000HzSec) * this.sourceSamplingRate
@@ -2963,7 +2956,7 @@ class Combination extends AudioCalibrator {
2963
2956
  binDesiredSec: this._calibrateSoundPowerBinDesiredSec,
2964
2957
  burstSec: this.desired_time_per_mls,
2965
2958
  repeats: this.numMLSPerCapture - this.num_mls_to_skip,
2966
- warmUp: this.num_mls_to_skip,
2959
+ warmUp: this._calibrateSoundBurstPreSec,
2967
2960
  downsample: this._calibrateSoundBurstDownsample,
2968
2961
  })
2969
2962
  .then(result => {