speaker-calibration 2.2.195 → 2.2.197

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.195",
3
+ "version": "2.2.197",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -128,7 +128,10 @@ class AudioCalibrator extends AudioRecorder {
128
128
  mode,
129
129
  checkRec
130
130
  ) => {
131
- this.numSuccessfulCaptured = 0;
131
+ // if it finished 2 attempts, it move to next iteration so reset numSuccessfulCaptured
132
+ if (this.numSuccessfulCaptured >=2) {
133
+ this.numSuccessfulCaptured = 0;
134
+ }
132
135
 
133
136
  // do something before playing such as using the MLS to fill the buffers
134
137
  console.warn('beforePlay');
@@ -594,14 +594,14 @@ class Combination extends AudioCalibrator {
594
594
  })
595
595
  .then(async result => {
596
596
  if (result) {
597
- if (result['sd'] > this._calibrateSoundBurstMaxSD_dB &
597
+ if (result['sd'] > this._calibrateSoundBurstMaxSD_dB &&
598
598
  this.numSuccessfulCaptured == 0) {
599
599
  console.log('SD: ' + result['sd'] + ', greater than _calibrateSoundBurstMaxSD_dB: ' + this._calibrateSoundBurstMaxSD_dB);
600
600
  this.recordingChecks['unfiltered'].push(result);
601
601
  this.clearLastUnfilteredRecordedSignals();
602
602
  this.numSuccessfulCaptured +=1;
603
603
  } else {
604
- if (result['sd'] < this._calibrateSoundBurstMaxSD_dB) {
604
+ if (result['sd'] <= this._calibrateSoundBurstMaxSD_dB) {
605
605
  console.log('SD: ' + result['sd'] + ', less than _calibrateSoundBurstMaxSD_dB: ' + this._calibrateSoundBurstMaxSD_dB);
606
606
  } else {
607
607
  console.log('SD: ' + result['sd'] + ', greater than _calibrateSoundBurstMaxSD_dB: ' + this._calibrateSoundBurstMaxSD_dB);
@@ -609,13 +609,15 @@ class Combination extends AudioCalibrator {
609
609
  this.status =
610
610
  `Redoing all Hz recording because SD ${result['sd']} dB> ${this._calibrateSoundBurstMaxSD_dB} dB`.toString() +
611
611
  this.generateTemplate().toString();
612
+ this.emit('update', {
613
+ message: this.status,
614
+ });
612
615
  }
613
616
  if (this.numSuccessfulCaptured == 1) {
614
617
  console.log('pop last unfiltered mls volume check');
615
618
  this.recordingChecks['unfiltered'].pop();
616
619
  }
617
620
  this.recordingChecks['unfiltered'].push(result);
618
- await this.pyServerAPI.checkMemory();
619
621
  // let start = new Date().getTime() / 1000;
620
622
  // const payloadT = tf.tensor1d(payload);
621
623
  // payloadT.print();
@@ -628,6 +630,7 @@ class Combination extends AudioCalibrator {
628
630
  // console.log("dimention:", xfft.shape);
629
631
  // let end = new Date().getTime() / 1000;
630
632
  // console.log("Time taken:", end - start, "seconds");
633
+ console.log('start calculate impulse response');
631
634
  const usedPeriodStart = this.num_mls_to_skip * this.sourceSamplingRate;
632
635
  const payload_skipped_warmUp = payload.slice(usedPeriodStart);
633
636
  await this.pyServerAPI
@@ -642,7 +645,6 @@ class Combination extends AudioCalibrator {
642
645
  this.fs2 = res['fs2'];
643
646
  this.L_new_n = res['L_new_n'];
644
647
  this.dL_n = res['dL_n'];
645
- await this.pyServerAPI.checkMemory();
646
648
  this.impulseResponses.push(
647
649
  await this.pyServerAPI
648
650
  .getImpulseResponse({
@@ -655,7 +657,6 @@ class Combination extends AudioCalibrator {
655
657
  dL_n: this.dL_n,
656
658
  })
657
659
  .then(res => {
658
- if (this.numSuccessfulCaptured < this.numCaptures) {
659
660
  this.numSuccessfulCaptured += 2;
660
661
  this.stepNum += 1;
661
662
  console.log('got impulse response ' + this.stepNum);
@@ -667,7 +668,6 @@ class Combination extends AudioCalibrator {
667
668
  message: this.status,
668
669
  });
669
670
  return res['ir'];
670
- }
671
671
  })
672
672
  .catch(err => {
673
673
  console.error(err);
@@ -2256,6 +2256,9 @@ class Combination extends AudioCalibrator {
2256
2256
  this.status =
2257
2257
  `Redoing 1000 Hz recording because SD ${this.recordingChecks['volume'][this.inDB]} dB> ${this.calibrateSound1000HzMaxSD_dB} dB`.toString() +
2258
2258
  this.generateTemplate().toString();
2259
+ this.emit('update', {
2260
+ message: this.status,
2261
+ });
2259
2262
  }
2260
2263
  const totalDuration = this.CALIBRATION_TONE_DURATION * 1.2;
2261
2264
 
@@ -2657,12 +2660,15 @@ class Combination extends AudioCalibrator {
2657
2660
  })
2658
2661
  .then(result => {
2659
2662
  if (result) {
2660
- if (result['sd'] > this._calibrateSoundBurstMaxSD_dB & this.numSuccessfulCaptured == 0) {
2663
+ if (result['sd'] > this._calibrateSoundBurstMaxSD_dB && this.numSuccessfulCaptured == 0) {
2661
2664
  console.log('filtered recording sd too high');
2662
2665
  this.recordingChecks['warnings'].push(`Redo all Hz recording because SD ${result['sd']} dB> ${this._calibrateSoundBurstMaxSD_dB} dB`);
2663
2666
  this.status =
2664
2667
  `Redoing all Hz recording because SD ${result['sd']} dB> ${this._calibrateSoundBurstMaxSD_dB} dB`.toString() +
2665
2668
  this.generateTemplate().toString();
2669
+ this.emit('update', {
2670
+ message: this.status,
2671
+ });
2666
2672
  // numSuccessfulCaptured no longer to count number of successful capture but count attemps
2667
2673
  // is sd below _calibrateSoundBurstMaxSD_dB then count two attemps
2668
2674
  // else count one attemp
@@ -2755,8 +2761,8 @@ class Combination extends AudioCalibrator {
2755
2761
  calibrateSoundLimit,
2756
2762
  _calibrateSoundBurstNormalizeBy1000HzGainBool = false,
2757
2763
  _calibrateSoundBurstScalarDB = 71,
2758
- calibrateSound1000HzMaxSD_dB = 4,
2759
- _calibrateSoundBurstMaxSD_dB = 4
2764
+ calibrateSound1000HzMaxSD_dB = 0.1,
2765
+ _calibrateSoundBurstMaxSD_dB = 0.1
2760
2766
  ) => {
2761
2767
  this.TAPER_SECS = _calibrateSoundTaperSec;
2762
2768
  this.calibrateSoundLimit = calibrateSoundLimit;