speaker-calibration 2.2.189 → 2.2.190

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.189",
3
+ "version": "2.2.190",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -174,7 +174,8 @@ class Speaker extends AudioPeer {
174
174
  params.calibrateSoundBurstUses1000HzGainBool,
175
175
  params.calibrateSoundBurstRepeats,
176
176
  params.calibrateSoundBurstSec,
177
- params.calibrateSoundBurstsWarmup,
177
+ params._calibrateSoundburstPreSec,
178
+ params._calibrateSoundburstPostSec,
178
179
  params.calibrateSoundHz,
179
180
  params.calibrateSoundIRSec,
180
181
  params.calibrateSoundIIRSec,
@@ -676,7 +677,8 @@ class Speaker extends AudioPeer {
676
677
  params.calibrateSoundBurstUses1000HzGainBool,
677
678
  params.calibrateSoundBurstRepeats,
678
679
  params.calibrateSoundBurstSec,
679
- params.calibrateSoundBurstsWarmup,
680
+ params._calibrateSoundburstPreSec,
681
+ params._calibrateSoundburstPostSec,
680
682
  params.calibrateSoundHz,
681
683
  params.calibrateSoundIRSec,
682
684
  params.calibrateSoundIIRSec,
@@ -753,17 +753,26 @@ class PythonServerAPI {
753
753
  sampleRate,
754
754
  binDesiredSec,
755
755
  burstSec,
756
- repeats
756
+ repeats,
757
+ warmUp
757
758
  }) => {
758
759
  const task = 'all-hz-check';
759
760
  let res = null;
760
761
 
762
+ console.log({payload,
763
+ sampleRate,
764
+ binDesiredSec,
765
+ burstSec,
766
+ repeats,
767
+ warmUp});
768
+
761
769
  const data = JSON.stringify({
762
770
  payload,
763
771
  sampleRate,
764
772
  binDesiredSec,
765
773
  burstSec,
766
- repeats
774
+ repeats,
775
+ warmUp
767
776
  });
768
777
 
769
778
  await axios({
@@ -362,7 +362,6 @@ class Combination extends AudioCalibrator {
362
362
  const lowHz = this.#lowHz; //gain of 1 below cutoff, need gain of 0
363
363
  const highHz = this.#highHz; //check error for anything other than 10 kHz
364
364
  const iirLength = this.iirLength;
365
- const num_periods = this.numMLSPerCapture + this.num_mls_to_skip;
366
365
  this.stepNum += 1;
367
366
  console.log('send impulse responses to server: ' + this.stepNum);
368
367
  this.status =
@@ -375,7 +374,6 @@ class Combination extends AudioCalibrator {
375
374
  lowHz,
376
375
  highHz,
377
376
  iirLength,
378
- num_periods,
379
377
  sampleRate: this.sourceSamplingRate || 96000,
380
378
  mlsAmplitude: Math.pow(10, this.power_dB / 20),
381
379
  calibrateSoundBurstFilteredExtraDb: this._calibrateSoundBurstFilteredExtraDb,
@@ -452,7 +450,6 @@ class Combination extends AudioCalibrator {
452
450
  const lowHz = this.#lowHz;
453
451
  const iirLength = this.iirLength;
454
452
  const irLength = this.irLength;
455
- const num_periods = this.numMLSPerCapture + this.num_mls_to_skip;
456
453
  const highHz = this.#highHz;
457
454
  this.stepNum += 1;
458
455
  console.log('send impulse responses to server: ' + this.stepNum);
@@ -591,23 +588,24 @@ class Combination extends AudioCalibrator {
591
588
  sampleRate: this.sourceSamplingRate || 96000,
592
589
  binDesiredSec: this._calibrateSoundPowerBinDesiredSec,
593
590
  burstSec: this.desired_time_per_mls,
594
- repeats: this.numMLSPerCapture,
591
+ repeats: this.numMLSPerCapture - this.num_mls_to_skip,
592
+ warmUp: this.num_mls_to_skip
595
593
  })
596
594
  .then(async result => {
597
595
  if (result) {
598
596
  if (result['sd'] > this._calibrateSoundBurstMaxSD_dB &
599
- this.numSuccesfulCaptures == 0) {
597
+ this.numSuccessfulCaptured == 0) {
600
598
  console.log('SD: ' + result['sd'] + ', greater than _calibrateSoundBurstMaxSD_dB: ' + this._calibrateSoundBurstMaxSD_dB);
601
599
  this.recordingChecks['unfiltered'].push(result);
602
600
  this.clearLastUnfilteredRecordedSignals();
603
- this.numSuccesfulCaptures +=1;
601
+ this.numSuccessfulCaptured +=1;
604
602
  } else {
605
603
  if (result['sd'] < this._calibrateSoundBurstMaxSD_dB) {
606
604
  console.log('SD: ' + result['sd'] + ', less than _calibrateSoundBurstMaxSD_dB: ' + this._calibrateSoundBurstMaxSD_dB);
607
605
  } else {
608
606
  console.log('SD: ' + result['sd'] + ', greater than _calibrateSoundBurstMaxSD_dB: ' + this._calibrateSoundBurstMaxSD_dB);
609
607
  }
610
- if (this.numSuccesfulCaptures == 1) {
608
+ if (this.numSuccessfulCaptured == 1) {
611
609
  console.log('pop last unfiltered mls volume check');
612
610
  this.recordingChecks['unfiltered'].pop();
613
611
  }
@@ -625,12 +623,17 @@ class Combination extends AudioCalibrator {
625
623
  // console.log("dimention:", xfft.shape);
626
624
  // let end = new Date().getTime() / 1000;
627
625
  // console.log("Time taken:", end - start, "seconds");
626
+ const usedPeriodStart = this.num_mls_to_skip * this.sourceSamplingRate;
627
+ const usedPeriodEnd = this.numMLSPerCapture * this.sourceSamplingRate;
628
+ const payload_skipped_warmUp = payload.slice(usedPeriodStart, usedPeriodEnd);
629
+ console.log(payload.length);
630
+ console.log(payload_skipped_warmUp.length);
628
631
  await this.pyServerAPI
629
632
  .getAutocorrelation({
630
633
  sampleRate: this.sourceSamplingRate || 96000,
631
634
  payload,
632
635
  mls,
633
- numPeriods: this.numMLSPerCapture,
636
+ numPeriods: this.numMLSPerCapture - this.num_mls_to_skip ,
634
637
  })
635
638
  .then(async res => {
636
639
  this.autocorrelations.push(res['autocorrelation']);
@@ -644,7 +647,7 @@ class Combination extends AudioCalibrator {
644
647
  mls,
645
648
  sampleRate: this.sourceSamplingRate || 96000,
646
649
  numPeriods: this.numMLSPerCapture,
647
- sig: payload,
650
+ sig: payload_skipped_warmUp,
648
651
  fs2: this.fs2,
649
652
  L_new_n: this.L_new_n,
650
653
  dL_n: this.dL_n,
@@ -671,7 +674,6 @@ class Combination extends AudioCalibrator {
671
674
  });
672
675
  }
673
676
  console.log('number of unfiltered recording checks:' + this.recordingChecks['unfiltered'].length);
674
- console.log('number of attemp: ' + this.numSuccesfulCaptures);
675
677
  }
676
678
  })
677
679
  .catch(err => {
@@ -701,7 +703,7 @@ class Combination extends AudioCalibrator {
701
703
  if (this.mode === 'unfiltered') {
702
704
  //unfiltered
703
705
  time_to_wait = (this.#mls[0].length / this.sourceSamplingRate) * this.numMLSPerCapture;
704
- time_to_wait = time_to_wait * 1.1;
706
+ time_to_wait = time_to_wait + this._calibrateSoundburstPostSec;
705
707
  } else if (this.mode === 'filtered') {
706
708
  //filtered
707
709
  // time_to_wait =
@@ -709,7 +711,7 @@ class Combination extends AudioCalibrator {
709
711
  // (this.numMLSPerCapture / (this.num_mls_to_skip + this.numMLSPerCapture));
710
712
  time_to_wait =
711
713
  (this.#currentConvolution.length / this.sourceSamplingRate) * this.numMLSPerCapture;
712
- time_to_wait = time_to_wait * 1.1;
714
+ time_to_wait = time_to_wait + this._calibrateSoundburstPostSec;
713
715
  } else {
714
716
  throw new Error('Mode broke in awaitDesiredMLSLength');
715
717
  }
@@ -747,7 +749,7 @@ class Combination extends AudioCalibrator {
747
749
  this.emit('update', {
748
750
  message: this.status,
749
751
  });
750
- let number_of_bursts_to_skip = this.num_mls_to_skip;
752
+ let number_of_bursts_to_skip = 0;
751
753
  let time_to_sleep = 0;
752
754
  if (this.mode === 'unfiltered') {
753
755
  time_to_sleep = (this.#mls[0].length / this.sourceSamplingRate) * number_of_bursts_to_skip;
@@ -972,7 +974,7 @@ class Combination extends AudioCalibrator {
972
974
 
973
975
  let return_component_conv_rec = component_conv_recs[component_conv_recs.length - 1];
974
976
  this.clearAllFilteredRecordedSignals();
975
- // await this.checkPowerVariation(return_component_conv_rec);
977
+
976
978
  this.numSuccessfulCaptured = 0;
977
979
  this.#currentConvolution = this.systemConvolution;
978
980
  this.filteredMLSRange.system.Min = findMinValue(this.#currentConvolution);
@@ -2641,7 +2643,8 @@ class Combination extends AudioCalibrator {
2641
2643
  sampleRate: this.sourceSamplingRate || 96000,
2642
2644
  binDesiredSec: this._calibrateSoundPowerBinDesiredSec,
2643
2645
  burstSec: this.desired_time_per_mls,
2644
- repeats: this.numMLSPerCapture,
2646
+ repeats: this.numMLSPerCapture - this.num_mls_to_skip ,
2647
+ warmUp: this.num_mls_to_skip
2645
2648
  })
2646
2649
  .then(result => {
2647
2650
  if (result) {
@@ -2707,13 +2710,14 @@ class Combination extends AudioCalibrator {
2707
2710
  _calibrateSoundBurstUses1000HzGainBool = false,
2708
2711
  _calibrateSoundBurstRepeats = 3,
2709
2712
  _calibrateSoundBurstSec = 1,
2710
- _calibrateSoundBurstsWarmup = 1,
2713
+ _calibrateSoundBurstPreSec = 1,
2714
+ _calibrateSoundburstPostSec = 1,
2711
2715
  _calibrateSoundHz = 48000,
2712
2716
  _calibrateSoundIRSec = 0.2,
2713
2717
  _calibrateSoundIIRSec = 0.2,
2714
2718
  _calibrateSoundIIRPhase = 'linear',
2715
- calibrateSound1000HzPreSec = 3.5,
2716
- calibrateSound1000HzSec = 1.0,
2719
+ calibrateSound1000HzPreSec = 0.5,
2720
+ calibrateSound1000HzSec = 0.5,
2717
2721
  calibrateSound1000HzPostSec = 0.5,
2718
2722
  _calibrateSoundBackgroundSecs = 0,
2719
2723
  _calibrateSoundSmoothOctaves = 0.33,
@@ -2754,9 +2758,10 @@ class Combination extends AudioCalibrator {
2754
2758
  this.iirLength = Math.floor(_calibrateSoundIIRSec * this.sourceSamplingRate);
2755
2759
  this.irLength = Math.floor(_calibrateSoundIRSec * this.sourceSamplingRate);
2756
2760
  this.calibrateSoundIIRPhase = _calibrateSoundIIRPhase;
2757
- this.numMLSPerCapture = _calibrateSoundBurstRepeats + 1;
2761
+ this.num_mls_to_skip = Math.ceil(_calibrateSoundBurstPreSec / _calibrateSoundBurstSec);
2762
+ this._calibrateSoundburstPostSec = _calibrateSoundburstPostSec;
2763
+ this.numMLSPerCapture = _calibrateSoundBurstRepeats + this.num_mls_to_skip;
2758
2764
  this.desired_time_per_mls = _calibrateSoundBurstSec;
2759
- this.num_mls_to_skip = _calibrateSoundBurstsWarmup;
2760
2765
  this.desired_sampling_rate = _calibrateSoundHz;
2761
2766
  this._calibrateSoundBackgroundSecs = _calibrateSoundBackgroundSecs;
2762
2767
  this._calibrateSoundSmoothOctaves = _calibrateSoundSmoothOctaves;