speaker-calibration 2.2.39 → 2.2.41
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/dist/main.js +2 -2
- package/package.json +1 -1
- package/src/peer-connection/speaker.js +17 -7
- package/src/tasks/combination/combination.js +341 -343
|
@@ -104,7 +104,6 @@ class Combination extends AudioCalibrator {
|
|
|
104
104
|
calibrateSound1000HzSec = 1.0;
|
|
105
105
|
calibrateSound1000HzPostSec = 0.5;
|
|
106
106
|
|
|
107
|
-
|
|
108
107
|
/** @private */
|
|
109
108
|
outDBSPL = null;
|
|
110
109
|
THD = null;
|
|
@@ -312,31 +311,31 @@ class Combination extends AudioCalibrator {
|
|
|
312
311
|
sendBackgroundRecording = () => {
|
|
313
312
|
const allSignals = this.getAllBackgroundRecordings();
|
|
314
313
|
const numSignals = allSignals.length;
|
|
315
|
-
const background_rec_whole = allSignals[numSignals-1];
|
|
316
|
-
const fraction = .5/(this._calibrateSoundBackgroundSecs + .5);
|
|
314
|
+
const background_rec_whole = allSignals[numSignals - 1];
|
|
315
|
+
const fraction = 0.5 / (this._calibrateSoundBackgroundSecs + 0.5);
|
|
317
316
|
// Calculate the starting index for slicing the array
|
|
318
317
|
const startIndex = Math.round(fraction * background_rec_whole.length);
|
|
319
318
|
// Slice the array from the calculated start index to the end of the array
|
|
320
319
|
const background_rec = background_rec_whole.slice(startIndex);
|
|
321
320
|
console.log('Sending background recording to server for processing');
|
|
322
321
|
this.pyServerAPI
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
322
|
+
.getBackgroundNoisePSDWithRetry({
|
|
323
|
+
background_rec,
|
|
324
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
325
|
+
})
|
|
326
|
+
.then(res => {
|
|
327
|
+
if (this.numSuccessfulBackgroundCaptured < 1) {
|
|
328
|
+
this.numSuccessfulBackgroundCaptured += 1;
|
|
329
|
+
//storing all background data in background_psd object
|
|
330
|
+
this.background_noise['x_background'] = res['x_background'];
|
|
331
|
+
this.background_noise['y_background'] = res['y_background'];
|
|
332
|
+
this.background_noise['recording'] = background_rec;
|
|
333
|
+
}
|
|
334
|
+
})
|
|
335
|
+
.catch(err => {
|
|
336
|
+
console.error(err);
|
|
337
|
+
});
|
|
338
|
+
};
|
|
340
339
|
|
|
341
340
|
/** .
|
|
342
341
|
* .
|
|
@@ -434,12 +433,13 @@ class Combination extends AudioCalibrator {
|
|
|
434
433
|
* @example
|
|
435
434
|
*/
|
|
436
435
|
#awaitBackgroundNoiseRecording = async () => {
|
|
437
|
-
console.log(
|
|
438
|
-
|
|
436
|
+
console.log(
|
|
437
|
+
'Waiting ' + this._calibrateSoundBackgroundSecs + ' second(s) to record background noise'
|
|
438
|
+
);
|
|
439
|
+
let time_to_wait = this._calibrateSoundBackgroundSecs + 0.5;
|
|
439
440
|
await sleep(time_to_wait);
|
|
440
441
|
};
|
|
441
442
|
|
|
442
|
-
|
|
443
443
|
/** .
|
|
444
444
|
* .
|
|
445
445
|
* .
|
|
@@ -657,7 +657,7 @@ class Combination extends AudioCalibrator {
|
|
|
657
657
|
);
|
|
658
658
|
};
|
|
659
659
|
|
|
660
|
-
bothSoundCheck = async
|
|
660
|
+
bothSoundCheck = async stream => {
|
|
661
661
|
let iir_ir_and_plots;
|
|
662
662
|
this.#currentConvolution = this.componentConvolution;
|
|
663
663
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
@@ -673,7 +673,7 @@ class Combination extends AudioCalibrator {
|
|
|
673
673
|
this.sourceAudioContext.close();
|
|
674
674
|
let recs = this.getAllUnfilteredRecordedSignals();
|
|
675
675
|
let unconv_rec = recs[0];
|
|
676
|
-
let return_unconv_rec= unconv_rec;
|
|
676
|
+
let return_unconv_rec = unconv_rec;
|
|
677
677
|
let conv_rec = component_conv_recs[0];
|
|
678
678
|
|
|
679
679
|
//psd of component
|
|
@@ -681,52 +681,52 @@ class Combination extends AudioCalibrator {
|
|
|
681
681
|
let knownFreq = this.oldComponentIR.Freq;
|
|
682
682
|
let sampleRate = this.sourceSamplingRate || 96000;
|
|
683
683
|
let component_unconv_rec_psd = await this.pyServerAPI
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
684
|
+
.getSubtractedPSDWithRetry(unconv_rec, knownGain, knownFreq, sampleRate)
|
|
685
|
+
.then(res => {
|
|
686
|
+
this.incrementStatusBar();
|
|
687
|
+
this.status =
|
|
688
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
689
|
+
this.generateTemplate().toString();
|
|
690
|
+
this.emit('update', {message: this.status});
|
|
691
|
+
return res;
|
|
692
|
+
})
|
|
693
|
+
.catch(err => {
|
|
694
|
+
console.error(err);
|
|
695
|
+
});
|
|
696
696
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
697
|
+
let component_conv_rec_psd = await this.pyServerAPI
|
|
698
|
+
.getSubtractedPSDWithRetry(conv_rec, knownGain, knownFreq, sampleRate)
|
|
699
|
+
.then(res => {
|
|
700
|
+
this.incrementStatusBar();
|
|
701
|
+
this.status =
|
|
702
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
703
|
+
this.generateTemplate().toString();
|
|
704
|
+
this.emit('update', {message: this.status});
|
|
705
|
+
return res;
|
|
706
|
+
})
|
|
707
|
+
.catch(err => {
|
|
708
|
+
console.error(err);
|
|
709
|
+
});
|
|
710
710
|
|
|
711
711
|
conv_rec = system_conv_recs[0];
|
|
712
712
|
//psd of system
|
|
713
713
|
let system_recs_psd = await this.pyServerAPI
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
714
|
+
.getPSDWithRetry({
|
|
715
|
+
unconv_rec,
|
|
716
|
+
conv_rec,
|
|
717
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
718
|
+
})
|
|
719
|
+
.then(res => {
|
|
720
|
+
this.incrementStatusBar();
|
|
721
|
+
this.status =
|
|
722
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
723
|
+
this.generateTemplate().toString();
|
|
724
|
+
this.emit('update', {message: this.status});
|
|
725
|
+
return res;
|
|
726
|
+
})
|
|
727
|
+
.catch(err => {
|
|
728
|
+
console.error(err);
|
|
729
|
+
});
|
|
730
730
|
|
|
731
731
|
//iir w/ and without bandpass psd. done
|
|
732
732
|
unconv_rec = this.componentInvertedImpulseResponseNoBandpass;
|
|
@@ -751,81 +751,80 @@ class Combination extends AudioCalibrator {
|
|
|
751
751
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
752
752
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
753
753
|
let system_iir_psd = await this.pyServerAPI
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
754
|
+
.getPSDWithRetry({
|
|
755
|
+
unconv_rec,
|
|
756
|
+
conv_rec,
|
|
757
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
758
|
+
})
|
|
759
|
+
.then(res => {
|
|
760
|
+
this.incrementStatusBar();
|
|
761
|
+
this.status =
|
|
762
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
763
|
+
this.generateTemplate().toString();
|
|
764
|
+
this.emit('update', {message: this.status});
|
|
765
|
+
return res;
|
|
766
|
+
})
|
|
767
|
+
.catch(err => {
|
|
768
|
+
console.error(err);
|
|
769
|
+
});
|
|
770
770
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
771
|
+
iir_ir_and_plots = {
|
|
772
|
+
filtered_recording: {
|
|
773
|
+
component: return_component_conv_rec,
|
|
774
|
+
system: return_system_conv_rec,
|
|
775
|
+
},
|
|
776
|
+
unfiltered_recording: this.getAllUnfilteredRecordedSignals()[0],
|
|
777
|
+
system: {
|
|
778
|
+
iir: this.systemInvertedImpulseResponse,
|
|
779
|
+
ir: this.systemIR,
|
|
780
|
+
iir_psd: {
|
|
781
|
+
y: system_iir_psd['y_conv'],
|
|
782
|
+
x: system_iir_psd['x_conv'],
|
|
783
|
+
y_no_bandpass: system_iir_psd['y_unconv'],
|
|
784
|
+
x_no_bandpass: system_iir_psd['x_unconv'],
|
|
785
|
+
},
|
|
786
|
+
convolution: this.systemConvolution,
|
|
787
|
+
psd: {
|
|
788
|
+
unconv: {
|
|
789
|
+
x: system_recs_psd['x_unconv'],
|
|
790
|
+
y: system_recs_psd['y_unconv'],
|
|
775
791
|
},
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
ir: this.systemIR,
|
|
780
|
-
iir_psd: {
|
|
781
|
-
y: system_iir_psd['y_conv'],
|
|
782
|
-
x: system_iir_psd['x_conv'],
|
|
783
|
-
y_no_bandpass: system_iir_psd['y_unconv'],
|
|
784
|
-
x_no_bandpass: system_iir_psd['x_unconv']
|
|
785
|
-
},
|
|
786
|
-
convolution: this.systemConvolution,
|
|
787
|
-
psd: {
|
|
788
|
-
unconv: {
|
|
789
|
-
x: system_recs_psd['x_unconv'],
|
|
790
|
-
y: system_recs_psd['y_unconv']
|
|
791
|
-
},
|
|
792
|
-
conv: {
|
|
793
|
-
x: system_recs_psd['x_unconv'],
|
|
794
|
-
y: system_recs_psd['y_unconv']
|
|
795
|
-
}
|
|
796
|
-
}
|
|
792
|
+
conv: {
|
|
793
|
+
x: system_recs_psd['x_conv'],
|
|
794
|
+
y: system_recs_psd['y_conv'],
|
|
797
795
|
},
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
x: component_conv_rec_psd['x'],
|
|
815
|
-
y: component_conv_rec_psd['y']
|
|
816
|
-
}
|
|
817
|
-
}
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
component: {
|
|
799
|
+
iir: this.componentInvertedImpulseResponse,
|
|
800
|
+
ir: this.componentIR,
|
|
801
|
+
iir_psd: {
|
|
802
|
+
y: component_iir_psd['y_conv'],
|
|
803
|
+
x: component_iir_psd['x_conv'],
|
|
804
|
+
y_no_bandpass: component_iir_psd['y_unconv'],
|
|
805
|
+
x_no_bandpass: component_iir_psd['x_unconv'],
|
|
806
|
+
},
|
|
807
|
+
convolution: this.componentConvolution,
|
|
808
|
+
psd: {
|
|
809
|
+
unconv: {
|
|
810
|
+
x: component_unconv_rec_psd['x'],
|
|
811
|
+
y: component_unconv_rec_psd['y'],
|
|
818
812
|
},
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
813
|
+
conv: {
|
|
814
|
+
x: component_conv_rec_psd['x'],
|
|
815
|
+
y: component_conv_rec_psd['y'],
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
},
|
|
819
|
+
mls: this.#mls,
|
|
820
|
+
autocorrelations: this.autocorrelations,
|
|
821
|
+
impulseResponses: [],
|
|
822
|
+
};
|
|
825
823
|
|
|
826
|
-
|
|
824
|
+
return iir_ir_and_plots;
|
|
825
|
+
};
|
|
827
826
|
|
|
828
|
-
singleSoundCheck = async
|
|
827
|
+
singleSoundCheck = async stream => {
|
|
829
828
|
let iir_ir_and_plots;
|
|
830
829
|
if (this._calibrateSoundCheck != 'system') {
|
|
831
830
|
this.#currentConvolution = this.componentConvolution;
|
|
@@ -837,9 +836,7 @@ class Combination extends AudioCalibrator {
|
|
|
837
836
|
this.sourceAudioContext.close();
|
|
838
837
|
let conv_recs = this.getAllFilteredRecordedSignals();
|
|
839
838
|
let recs = this.getAllUnfilteredRecordedSignals();
|
|
840
|
-
console.log(
|
|
841
|
-
'Obtaining unfiltered recording from #allHzUnfilteredRecordings to calculate PSD'
|
|
842
|
-
);
|
|
839
|
+
console.log('Obtaining unfiltered recording from #allHzUnfilteredRecordings to calculate PSD');
|
|
843
840
|
console.log('Obtaining filtered recording from #allHzFilteredRecordings to calculate PSD');
|
|
844
841
|
let unconv_rec = recs[0];
|
|
845
842
|
let return_unconv_rec = unconv_rec;
|
|
@@ -898,73 +895,73 @@ class Combination extends AudioCalibrator {
|
|
|
898
895
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
899
896
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
900
897
|
let system_iir_psd = await this.pyServerAPI
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
898
|
+
.getPSDWithRetry({
|
|
899
|
+
unconv_rec,
|
|
900
|
+
conv_rec,
|
|
901
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
902
|
+
})
|
|
903
|
+
.then(res => {
|
|
904
|
+
this.incrementStatusBar();
|
|
905
|
+
this.status =
|
|
906
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
907
|
+
this.generateTemplate().toString();
|
|
908
|
+
this.emit('update', {message: this.status});
|
|
909
|
+
return res;
|
|
910
|
+
})
|
|
911
|
+
.catch(err => {
|
|
912
|
+
console.error(err);
|
|
913
|
+
});
|
|
917
914
|
|
|
918
915
|
iir_ir_and_plots = {
|
|
919
916
|
unfiltered_recording: return_unconv_rec,
|
|
920
917
|
filtered_recording: return_conv_rec,
|
|
921
918
|
system: {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
919
|
+
iir: this.systemInvertedImpulseResponse,
|
|
920
|
+
ir: this.systemIR,
|
|
921
|
+
iir_psd: {
|
|
922
|
+
y: system_iir_psd['y_conv'],
|
|
923
|
+
x: system_iir_psd['y_conv'],
|
|
924
|
+
y_no_bandpass: system_iir_psd['y_unconv'],
|
|
925
|
+
x_no_bandpass: system_iir_psd['x_unconv'],
|
|
926
|
+
},
|
|
927
|
+
filtered_recording: [],
|
|
928
|
+
convolution: this.systemConvolution,
|
|
929
|
+
psd: {
|
|
930
|
+
unconv: {
|
|
931
|
+
x: [],
|
|
932
|
+
y: [],
|
|
929
933
|
},
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
y: []
|
|
936
|
-
},
|
|
937
|
-
conv: {
|
|
938
|
-
x: [],
|
|
939
|
-
y: []
|
|
940
|
-
}
|
|
941
|
-
}
|
|
934
|
+
conv: {
|
|
935
|
+
x: [],
|
|
936
|
+
y: [],
|
|
937
|
+
},
|
|
938
|
+
},
|
|
942
939
|
},
|
|
943
940
|
component: {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
941
|
+
iir: this.componentInvertedImpulseResponse,
|
|
942
|
+
ir: this.componentIR,
|
|
943
|
+
iir_psd: {
|
|
944
|
+
y: component_iir_psd['y_conv'],
|
|
945
|
+
x: component_iir_psd['x_conv'],
|
|
946
|
+
y_no_bandpass: component_iir_psd['y_unconv'],
|
|
947
|
+
x_no_bandpass: component_iir_psd['x_unconv'],
|
|
948
|
+
},
|
|
949
|
+
convolution: this.componentConvolution,
|
|
950
|
+
psd: {
|
|
951
|
+
unconv: {
|
|
952
|
+
x: unconv_results['x'],
|
|
953
|
+
y: unconv_results['y'],
|
|
951
954
|
},
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
},
|
|
958
|
-
conv: {
|
|
959
|
-
x: conv_results['x'],
|
|
960
|
-
y: conv_results['y']
|
|
961
|
-
}
|
|
962
|
-
}
|
|
955
|
+
conv: {
|
|
956
|
+
x: conv_results['x'],
|
|
957
|
+
y: conv_results['y'],
|
|
958
|
+
},
|
|
959
|
+
},
|
|
963
960
|
},
|
|
964
961
|
mls: this.#mls,
|
|
965
962
|
autocorrelations: this.autocorrelations,
|
|
966
|
-
impulseResponses: []
|
|
967
|
-
|
|
963
|
+
impulseResponses: [],
|
|
964
|
+
};
|
|
968
965
|
} else {
|
|
969
966
|
let results = await this.pyServerAPI
|
|
970
967
|
.getPSDWithRetry({
|
|
@@ -1007,78 +1004,78 @@ class Combination extends AudioCalibrator {
|
|
|
1007
1004
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
1008
1005
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
1009
1006
|
let system_iir_psd = await this.pyServerAPI
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1007
|
+
.getPSDWithRetry({
|
|
1008
|
+
unconv_rec,
|
|
1009
|
+
conv_rec,
|
|
1010
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
1011
|
+
})
|
|
1012
|
+
.then(res => {
|
|
1013
|
+
this.incrementStatusBar();
|
|
1014
|
+
this.status =
|
|
1015
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
1016
|
+
this.generateTemplate().toString();
|
|
1017
|
+
this.emit('update', {message: this.status});
|
|
1018
|
+
return res;
|
|
1019
|
+
})
|
|
1020
|
+
.catch(err => {
|
|
1021
|
+
console.error(err);
|
|
1022
|
+
});
|
|
1026
1023
|
|
|
1027
1024
|
iir_ir_and_plots = {
|
|
1028
1025
|
unfiltered_recording: return_unconv_rec,
|
|
1029
1026
|
filtered_recording: return_conv_rec,
|
|
1030
1027
|
system: {
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1028
|
+
iir: this.systemInvertedImpulseResponse,
|
|
1029
|
+
ir: this.systemIR,
|
|
1030
|
+
iir_psd: {
|
|
1031
|
+
y: system_iir_psd['y_conv'],
|
|
1032
|
+
x: system_iir_psd['y_conv'],
|
|
1033
|
+
y_no_bandpass: system_iir_psd['y_unconv'],
|
|
1034
|
+
x_no_bandpass: system_iir_psd['x_unconv'],
|
|
1035
|
+
},
|
|
1036
|
+
filtered_recording: [],
|
|
1037
|
+
convolution: this.systemConvolution,
|
|
1038
|
+
psd: {
|
|
1039
|
+
unconv: {
|
|
1040
|
+
x: results['x_unconv'],
|
|
1041
|
+
y: results['y_unconv'],
|
|
1038
1042
|
},
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
y: results['y_unconv']
|
|
1045
|
-
},
|
|
1046
|
-
conv: {
|
|
1047
|
-
x: results['x_conv'],
|
|
1048
|
-
y: results['y_conv'],
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1043
|
+
conv: {
|
|
1044
|
+
x: results['x_conv'],
|
|
1045
|
+
y: results['y_conv'],
|
|
1046
|
+
},
|
|
1047
|
+
},
|
|
1051
1048
|
},
|
|
1052
1049
|
component: {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1050
|
+
iir: this.componentInvertedImpulseResponse,
|
|
1051
|
+
ir: this.componentIR,
|
|
1052
|
+
iir_psd: {
|
|
1053
|
+
y: component_iir_psd['y_conv'],
|
|
1054
|
+
x: component_iir_psd['x_conv'],
|
|
1055
|
+
y_no_bandpass: component_iir_psd['y_unconv'],
|
|
1056
|
+
x_no_bandpass: component_iir_psd['x_unconv'],
|
|
1057
|
+
},
|
|
1058
|
+
convolution: this.componentConvolution,
|
|
1059
|
+
psd: {
|
|
1060
|
+
unconv: {
|
|
1061
|
+
x: [],
|
|
1062
|
+
y: [],
|
|
1060
1063
|
},
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
},
|
|
1067
|
-
conv: {
|
|
1068
|
-
x: [],
|
|
1069
|
-
y: []
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1064
|
+
conv: {
|
|
1065
|
+
x: [],
|
|
1066
|
+
y: [],
|
|
1067
|
+
},
|
|
1068
|
+
},
|
|
1072
1069
|
},
|
|
1073
1070
|
mls: this.#mls,
|
|
1074
1071
|
autocorrelations: this.autocorrelations,
|
|
1075
|
-
impulseResponses: []
|
|
1076
|
-
|
|
1072
|
+
impulseResponses: [],
|
|
1073
|
+
};
|
|
1077
1074
|
}
|
|
1078
1075
|
await Promise.all(this.impulseResponses).then(res => {
|
|
1079
1076
|
for (let i = 0; i < res.length; i++) {
|
|
1080
1077
|
if (res[i] != undefined) {
|
|
1081
|
-
iir_ir_and_plots['impulseResponses'].push(res[i])
|
|
1078
|
+
iir_ir_and_plots['impulseResponses'].push(res[i]);
|
|
1082
1079
|
}
|
|
1083
1080
|
}
|
|
1084
1081
|
});
|
|
@@ -1104,7 +1101,7 @@ class Combination extends AudioCalibrator {
|
|
|
1104
1101
|
}
|
|
1105
1102
|
|
|
1106
1103
|
return iir_ir_and_plots;
|
|
1107
|
-
}
|
|
1104
|
+
};
|
|
1108
1105
|
|
|
1109
1106
|
/**
|
|
1110
1107
|
* Public method to start the calibration process. Objects intialized from webassembly allocate new memory
|
|
@@ -1134,10 +1131,11 @@ class Combination extends AudioCalibrator {
|
|
|
1134
1131
|
console.error(err);
|
|
1135
1132
|
});
|
|
1136
1133
|
this.numSuccessfulBackgroundCaptured = 0;
|
|
1137
|
-
if (this._calibrateSoundBackgroundSecs > 0){
|
|
1138
|
-
this.mode='background';
|
|
1134
|
+
if (this._calibrateSoundBackgroundSecs > 0) {
|
|
1135
|
+
this.mode = 'background';
|
|
1139
1136
|
this.status =
|
|
1140
|
-
|
|
1137
|
+
`All Hz Calibration: sampling the background noise...`.toString() +
|
|
1138
|
+
this.generateTemplate().toString();
|
|
1141
1139
|
this.emit('update', {message: this.status});
|
|
1142
1140
|
await this.recordBackground(
|
|
1143
1141
|
stream, //stream
|
|
@@ -1146,10 +1144,10 @@ class Combination extends AudioCalibrator {
|
|
|
1146
1144
|
this.sendBackgroundRecording, //send to get PSD
|
|
1147
1145
|
this.mode,
|
|
1148
1146
|
checkRec
|
|
1149
|
-
)
|
|
1147
|
+
);
|
|
1150
1148
|
this.incrementStatusBar();
|
|
1151
1149
|
}
|
|
1152
|
-
this.mode='unfiltered';
|
|
1150
|
+
this.mode = 'unfiltered';
|
|
1153
1151
|
this.numSuccessfulCaptured = 0;
|
|
1154
1152
|
|
|
1155
1153
|
await this.calibrationSteps(
|
|
@@ -1163,7 +1161,7 @@ class Combination extends AudioCalibrator {
|
|
|
1163
1161
|
this.mode,
|
|
1164
1162
|
checkRec
|
|
1165
1163
|
),
|
|
1166
|
-
|
|
1164
|
+
this.#stopCalibrationAudio();
|
|
1167
1165
|
checkRec = false;
|
|
1168
1166
|
|
|
1169
1167
|
// at this stage we've captured all the required signals,
|
|
@@ -1177,106 +1175,106 @@ class Combination extends AudioCalibrator {
|
|
|
1177
1175
|
let iir_ir_and_plots;
|
|
1178
1176
|
if (this._calibrateSoundCheck != 'none') {
|
|
1179
1177
|
//do single check
|
|
1180
|
-
if (this._calibrateSoundCheck == 'goal' || this._calibrateSoundCheck == 'system'){
|
|
1178
|
+
if (this._calibrateSoundCheck == 'goal' || this._calibrateSoundCheck == 'system') {
|
|
1181
1179
|
iir_ir_and_plots = await this.singleSoundCheck(stream);
|
|
1182
|
-
} else{
|
|
1180
|
+
} else {
|
|
1181
|
+
//both
|
|
1183
1182
|
iir_ir_and_plots = await this.bothSoundCheck(stream);
|
|
1184
1183
|
}
|
|
1185
|
-
|
|
1186
1184
|
} else {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1185
|
+
let unconv_rec = this.componentInvertedImpulseResponseNoBandpass;
|
|
1186
|
+
let conv_rec = this.componentInvertedImpulseResponse;
|
|
1187
|
+
let component_iir_psd = await this.pyServerAPI
|
|
1188
|
+
.getPSDWithRetry({
|
|
1189
|
+
unconv_rec,
|
|
1190
|
+
conv_rec,
|
|
1191
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
1192
|
+
})
|
|
1193
|
+
.then(res => {
|
|
1194
|
+
this.incrementStatusBar();
|
|
1195
|
+
this.status =
|
|
1196
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
1197
|
+
this.generateTemplate().toString();
|
|
1198
|
+
this.emit('update', {message: this.status});
|
|
1199
|
+
return res;
|
|
1200
|
+
})
|
|
1201
|
+
.catch(err => {
|
|
1202
|
+
console.error(err);
|
|
1203
|
+
});
|
|
1204
|
+
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
1205
|
+
conv_rec = this.systemInvertedImpulseResponse;
|
|
1206
|
+
let system_iir_psd = await this.pyServerAPI
|
|
1207
|
+
.getPSDWithRetry({
|
|
1208
|
+
unconv_rec,
|
|
1209
|
+
conv_rec,
|
|
1210
|
+
sampleRate: this.sourceSamplingRate || 96000,
|
|
1211
|
+
})
|
|
1212
|
+
.then(res => {
|
|
1213
|
+
this.incrementStatusBar();
|
|
1214
|
+
this.status =
|
|
1215
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
1216
|
+
this.generateTemplate().toString();
|
|
1217
|
+
this.emit('update', {message: this.status});
|
|
1218
|
+
return res;
|
|
1219
|
+
})
|
|
1220
|
+
.catch(err => {
|
|
1221
|
+
console.error(err);
|
|
1222
|
+
});
|
|
1225
1223
|
|
|
1226
1224
|
iir_ir_and_plots = {
|
|
1227
1225
|
unfiltered_recording: return_unconv_rec,
|
|
1228
1226
|
filtered_recording: return_conv_rec,
|
|
1229
1227
|
system: {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1228
|
+
iir: this.systemInvertedImpulseResponse,
|
|
1229
|
+
ir: this.systemIR,
|
|
1230
|
+
iir_psd: {
|
|
1231
|
+
y: system_iir_psd['y_conv'],
|
|
1232
|
+
x: system_iir_psd['y_conv'],
|
|
1233
|
+
y_no_bandpass: system_iir_psd['y_unconv'],
|
|
1234
|
+
x_no_bandpass: system_iir_psd['x_unconv'],
|
|
1235
|
+
},
|
|
1236
|
+
filtered_recording: [],
|
|
1237
|
+
convolution: this.systemConvolution,
|
|
1238
|
+
psd: {
|
|
1239
|
+
unconv: {
|
|
1240
|
+
x: [],
|
|
1241
|
+
y: [],
|
|
1237
1242
|
},
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
y: []
|
|
1244
|
-
},
|
|
1245
|
-
conv: {
|
|
1246
|
-
x: [],
|
|
1247
|
-
y: [],
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1243
|
+
conv: {
|
|
1244
|
+
x: [],
|
|
1245
|
+
y: [],
|
|
1246
|
+
},
|
|
1247
|
+
},
|
|
1250
1248
|
},
|
|
1251
1249
|
component: {
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1250
|
+
iir: this.componentInvertedImpulseResponse,
|
|
1251
|
+
ir: this.componentIR,
|
|
1252
|
+
iir_psd: {
|
|
1253
|
+
y: component_iir_psd['y_conv'],
|
|
1254
|
+
x: component_iir_psd['x_conv'],
|
|
1255
|
+
y_no_bandpass: component_iir_psd['y_unconv'],
|
|
1256
|
+
x_no_bandpass: component_iir_psd['x_unconv'],
|
|
1257
|
+
},
|
|
1258
|
+
convolution: this.componentConvolution,
|
|
1259
|
+
psd: {
|
|
1260
|
+
unconv: {
|
|
1261
|
+
x: [],
|
|
1262
|
+
y: [],
|
|
1259
1263
|
},
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
},
|
|
1266
|
-
conv: {
|
|
1267
|
-
x: [],
|
|
1268
|
-
y: []
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1264
|
+
conv: {
|
|
1265
|
+
x: [],
|
|
1266
|
+
y: [],
|
|
1267
|
+
},
|
|
1268
|
+
},
|
|
1271
1269
|
},
|
|
1272
1270
|
mls: this.#mls,
|
|
1273
1271
|
autocorrelations: this.autocorrelations,
|
|
1274
|
-
impulseResponses: []
|
|
1275
|
-
|
|
1272
|
+
impulseResponses: [],
|
|
1273
|
+
};
|
|
1276
1274
|
await Promise.all(this.impulseResponses).then(res => {
|
|
1277
1275
|
for (let i = 0; i < res.length; i++) {
|
|
1278
1276
|
if (res[i] != undefined) {
|
|
1279
|
-
iir_ir_and_plots['impulseResponses'].push(res[i])
|
|
1277
|
+
iir_ir_and_plots['impulseResponses'].push(res[i]);
|
|
1280
1278
|
}
|
|
1281
1279
|
}
|
|
1282
1280
|
});
|
|
@@ -1427,14 +1425,14 @@ class Combination extends AudioCalibrator {
|
|
|
1427
1425
|
await sleep(totalDuration);
|
|
1428
1426
|
};
|
|
1429
1427
|
|
|
1430
|
-
#sendToServerForProcessing =
|
|
1428
|
+
#sendToServerForProcessing = lCalib => {
|
|
1431
1429
|
console.log('Sending data to server');
|
|
1432
|
-
let left = this.calibrateSound1000HzPreSec
|
|
1433
|
-
let right = this.calibrateSound1000HzPreSec + this.calibrateSound1000HzSec
|
|
1430
|
+
let left = this.calibrateSound1000HzPreSec;
|
|
1431
|
+
let right = this.calibrateSound1000HzPreSec + this.calibrateSound1000HzSec;
|
|
1434
1432
|
this.pyServerAPI
|
|
1435
1433
|
.getVolumeCalibration({
|
|
1436
1434
|
sampleRate: this.sourceSamplingRate,
|
|
1437
|
-
payload: this.#getTruncatedSignal(left,right),
|
|
1435
|
+
payload: this.#getTruncatedSignal(left, right),
|
|
1438
1436
|
lCalib: lCalib,
|
|
1439
1437
|
})
|
|
1440
1438
|
.then(res => {
|
|
@@ -1672,8 +1670,8 @@ class Combination extends AudioCalibrator {
|
|
|
1672
1670
|
micModelNumber = '',
|
|
1673
1671
|
micModelName = ''
|
|
1674
1672
|
) => {
|
|
1675
|
-
this.CALIBRATION_TONE_DURATION =
|
|
1676
|
-
|
|
1673
|
+
this.CALIBRATION_TONE_DURATION =
|
|
1674
|
+
calibrateSound1000HzPreSec + calibrateSound1000HzSec + calibrateSound1000HzPostSec;
|
|
1677
1675
|
this.calibrateSound1000HzPreSec = calibrateSound1000HzPreSec;
|
|
1678
1676
|
this.calibrateSound1000HzSec = calibrateSound1000HzSec;
|
|
1679
1677
|
this.calibrateSound1000HzPostSec = calibrateSound1000HzPostSec;
|