speaker-calibration 2.2.68 → 2.2.69
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 +1056 -1056
- package/package.json +1 -1
- package/src/tasks/combination/combination.js +43 -48
package/package.json
CHANGED
|
@@ -229,7 +229,7 @@ class Combination extends AudioCalibrator {
|
|
|
229
229
|
* @example
|
|
230
230
|
*/
|
|
231
231
|
sendSystemImpulseResponsesToServerForProcessing = async () => {
|
|
232
|
-
this.addTimeStamp(
|
|
232
|
+
this.addTimeStamp('Get system iir');
|
|
233
233
|
const computedIRs = await Promise.all(this.impulseResponses);
|
|
234
234
|
const filteredComputedIRs = computedIRs.filter(element => {
|
|
235
235
|
return element != undefined;
|
|
@@ -283,7 +283,7 @@ class Combination extends AudioCalibrator {
|
|
|
283
283
|
* @example
|
|
284
284
|
*/
|
|
285
285
|
sendComponentImpulseResponsesToServerForProcessing = async () => {
|
|
286
|
-
this.addTimeStamp(
|
|
286
|
+
this.addTimeStamp('Get component iir');
|
|
287
287
|
const computedIRs = await Promise.all(this.impulseResponses);
|
|
288
288
|
const filteredComputedIRs = computedIRs.filter(element => {
|
|
289
289
|
return element != undefined;
|
|
@@ -345,7 +345,7 @@ class Combination extends AudioCalibrator {
|
|
|
345
345
|
// Slice the array from the calculated start index to the end of the array
|
|
346
346
|
const background_rec = background_rec_whole.slice(startIndex);
|
|
347
347
|
console.log('Sending background recording to server for processing');
|
|
348
|
-
this.addTimeStamp(
|
|
348
|
+
this.addTimeStamp('Get background PSD');
|
|
349
349
|
this.pyServerAPI
|
|
350
350
|
.getBackgroundNoisePSDWithRetry({
|
|
351
351
|
background_rec,
|
|
@@ -703,7 +703,7 @@ class Combination extends AudioCalibrator {
|
|
|
703
703
|
this.#currentConvolution = this.componentConvolution;
|
|
704
704
|
this.filteredMLSRange.component.Min = findMinValue(this.#currentConvolution);
|
|
705
705
|
this.filteredMLSRange.component.Max = findMaxValue(this.#currentConvolution);
|
|
706
|
-
this.addTimeStamp(
|
|
706
|
+
this.addTimeStamp('Play MLS with component IIR');
|
|
707
707
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
708
708
|
this.#stopCalibrationAudio();
|
|
709
709
|
let component_conv_recs = this.getAllFilteredRecordedSignals();
|
|
@@ -711,7 +711,7 @@ class Combination extends AudioCalibrator {
|
|
|
711
711
|
this.clearAllFilteredRecordedSignals();
|
|
712
712
|
|
|
713
713
|
this.#currentConvolution = this.testConvolution;
|
|
714
|
-
this.addTimeStamp(
|
|
714
|
+
this.addTimeStamp('Play MLS with test IIR');
|
|
715
715
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
716
716
|
this.#stopCalibrationAudio();
|
|
717
717
|
let test_conv_recs = this.getAllFilteredRecordedSignals();
|
|
@@ -721,7 +721,7 @@ class Combination extends AudioCalibrator {
|
|
|
721
721
|
this.#currentConvolution = this.systemConvolution;
|
|
722
722
|
this.filteredMLSRange.system.Min = findMinValue(this.#currentConvolution);
|
|
723
723
|
this.filteredMLSRange.system.Max = findMaxValue(this.#currentConvolution);
|
|
724
|
-
this.addTimeStamp(
|
|
724
|
+
this.addTimeStamp('Play MLS with system IIR');
|
|
725
725
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
726
726
|
this.#stopCalibrationAudio();
|
|
727
727
|
let system_conv_recs = this.getAllFilteredRecordedSignals();
|
|
@@ -739,7 +739,7 @@ class Combination extends AudioCalibrator {
|
|
|
739
739
|
let knownGain = this.oldComponentIR.Gain;
|
|
740
740
|
let knownFreq = this.oldComponentIR.Freq;
|
|
741
741
|
let sampleRate = this.sourceSamplingRate || 96000;
|
|
742
|
-
this.addTimeStamp(
|
|
742
|
+
this.addTimeStamp('Get PSD of mls recording');
|
|
743
743
|
let component_unconv_rec_psd = await this.pyServerAPI
|
|
744
744
|
.getSubtractedPSDWithRetry(unconv_rec, knownGain, knownFreq, sampleRate)
|
|
745
745
|
.then(res => {
|
|
@@ -754,7 +754,7 @@ class Combination extends AudioCalibrator {
|
|
|
754
754
|
console.error(err);
|
|
755
755
|
});
|
|
756
756
|
|
|
757
|
-
this.addTimeStamp(
|
|
757
|
+
this.addTimeStamp('Get PSD of filtered recording (component)');
|
|
758
758
|
let component_conv_rec_psd = await this.pyServerAPI
|
|
759
759
|
.getSubtractedPSDWithRetry(conv_rec, knownGain, knownFreq, sampleRate)
|
|
760
760
|
.then(res => {
|
|
@@ -768,8 +768,8 @@ class Combination extends AudioCalibrator {
|
|
|
768
768
|
.catch(err => {
|
|
769
769
|
console.error(err);
|
|
770
770
|
});
|
|
771
|
-
|
|
772
|
-
this.addTimeStamp(
|
|
771
|
+
|
|
772
|
+
this.addTimeStamp('Get PSD of filtered recording (test component)');
|
|
773
773
|
let test_conv_rec_psd = await this.pyServerAPI
|
|
774
774
|
.getSubtractedPSDWithRetry(return_test_conv_rec, knownGain, knownFreq, sampleRate)
|
|
775
775
|
.then(res => {
|
|
@@ -786,7 +786,7 @@ class Combination extends AudioCalibrator {
|
|
|
786
786
|
|
|
787
787
|
conv_rec = system_conv_recs[0];
|
|
788
788
|
//psd of system
|
|
789
|
-
this.addTimeStamp(
|
|
789
|
+
this.addTimeStamp('Get PSD of filtered recording (system) and unfiltered recording');
|
|
790
790
|
let system_recs_psd = await this.pyServerAPI
|
|
791
791
|
.getPSDWithRetry({
|
|
792
792
|
unconv_rec,
|
|
@@ -808,7 +808,7 @@ class Combination extends AudioCalibrator {
|
|
|
808
808
|
//iir w/ and without bandpass psd. done
|
|
809
809
|
unconv_rec = this.componentInvertedImpulseResponseNoBandpass;
|
|
810
810
|
conv_rec = this.componentInvertedImpulseResponse;
|
|
811
|
-
this.addTimeStamp(
|
|
811
|
+
this.addTimeStamp('Get PSD of component iir and component iir no band pass');
|
|
812
812
|
let component_iir_psd = await this.pyServerAPI
|
|
813
813
|
.getPSDWithRetry({
|
|
814
814
|
unconv_rec,
|
|
@@ -828,7 +828,7 @@ class Combination extends AudioCalibrator {
|
|
|
828
828
|
});
|
|
829
829
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
830
830
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
831
|
-
this.addTimeStamp(
|
|
831
|
+
this.addTimeStamp('Get PSD of system iir and system iir no band pass');
|
|
832
832
|
let system_iir_psd = await this.pyServerAPI
|
|
833
833
|
.getPSDWithRetry({
|
|
834
834
|
unconv_rec,
|
|
@@ -846,8 +846,8 @@ class Combination extends AudioCalibrator {
|
|
|
846
846
|
.catch(err => {
|
|
847
847
|
console.error(err);
|
|
848
848
|
});
|
|
849
|
-
|
|
850
|
-
this.addTimeStamp(
|
|
849
|
+
|
|
850
|
+
this.addTimeStamp('Get PSD of mls sequence');
|
|
851
851
|
let mls_psd = await this.pyServerAPI
|
|
852
852
|
.getMLSPSDWithRetry({mls: this.#mlsBufferView, sampleRate: this.sourceSamplingRate || 96000})
|
|
853
853
|
.then(res => {
|
|
@@ -862,8 +862,7 @@ class Combination extends AudioCalibrator {
|
|
|
862
862
|
console.error(err);
|
|
863
863
|
});
|
|
864
864
|
|
|
865
|
-
|
|
866
|
-
this.addTimeStamp("Get PSD of filered mls (system)");
|
|
865
|
+
this.addTimeStamp('Get PSD of filered mls (system)');
|
|
867
866
|
let system_filtered_mls_psd = await this.pyServerAPI
|
|
868
867
|
.getMLSPSDWithRetry({
|
|
869
868
|
mls: this.systemConvolution,
|
|
@@ -881,8 +880,7 @@ class Combination extends AudioCalibrator {
|
|
|
881
880
|
console.error(err);
|
|
882
881
|
});
|
|
883
882
|
|
|
884
|
-
|
|
885
|
-
this.addTimeStamp("Get PSD of filered mls (component)");
|
|
883
|
+
this.addTimeStamp('Get PSD of filered mls (component)');
|
|
886
884
|
let component_filtered_mls_psd = await this.pyServerAPI
|
|
887
885
|
.getMLSPSDWithRetry({
|
|
888
886
|
mls: this.componentConvolution,
|
|
@@ -978,12 +976,12 @@ class Combination extends AudioCalibrator {
|
|
|
978
976
|
this.#currentConvolution = this.componentConvolution;
|
|
979
977
|
this.filteredMLSRange.component.Min = findMinValue(this.#currentConvolution);
|
|
980
978
|
this.filteredMLSRange.component.Max = findMaxValue(this.#currentConvolution);
|
|
981
|
-
this.addTimeStamp(
|
|
979
|
+
this.addTimeStamp('Play MLS with component IIR');
|
|
982
980
|
} else {
|
|
983
981
|
this.#currentConvolution = this.systemConvolution;
|
|
984
982
|
this.filteredMLSRange.system.Min = findMinValue(this.#currentConvolution);
|
|
985
983
|
this.filteredMLSRange.system.Max = findMaxValue(this.#currentConvolution);
|
|
986
|
-
this.addTimeStamp(
|
|
984
|
+
this.addTimeStamp('Play MLS with system IIR');
|
|
987
985
|
}
|
|
988
986
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
989
987
|
this.#stopCalibrationAudio();
|
|
@@ -997,7 +995,7 @@ class Combination extends AudioCalibrator {
|
|
|
997
995
|
let conv_rec = conv_recs[0];
|
|
998
996
|
let return_conv_rec = conv_rec;
|
|
999
997
|
if (this._calibrateSoundCheck != 'system') {
|
|
1000
|
-
this.addTimeStamp(
|
|
998
|
+
this.addTimeStamp('Play MLS with test IIR');
|
|
1001
999
|
this.#currentConvolution = this.testConvolution;
|
|
1002
1000
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
1003
1001
|
this.#stopCalibrationAudio();
|
|
@@ -1009,7 +1007,7 @@ class Combination extends AudioCalibrator {
|
|
|
1009
1007
|
let knownGain = this.oldComponentIR.Gain;
|
|
1010
1008
|
let knownFreq = this.oldComponentIR.Freq;
|
|
1011
1009
|
let sampleRate = this.sourceSamplingRate || 96000;
|
|
1012
|
-
this.addTimeStamp(
|
|
1010
|
+
this.addTimeStamp('Get PSD of mls recording');
|
|
1013
1011
|
let unconv_results = await this.pyServerAPI
|
|
1014
1012
|
.getSubtractedPSDWithRetry(unconv_rec, knownGain, knownFreq, sampleRate)
|
|
1015
1013
|
.then(res => {
|
|
@@ -1024,7 +1022,7 @@ class Combination extends AudioCalibrator {
|
|
|
1024
1022
|
console.error(err);
|
|
1025
1023
|
});
|
|
1026
1024
|
|
|
1027
|
-
this.addTimeStamp(
|
|
1025
|
+
this.addTimeStamp('Get PSD recording of filtered recording (component)');
|
|
1028
1026
|
let conv_results = await this.pyServerAPI
|
|
1029
1027
|
.getSubtractedPSDWithRetry(conv_rec, knownGain, knownFreq, sampleRate)
|
|
1030
1028
|
.then(res => {
|
|
@@ -1038,8 +1036,8 @@ class Combination extends AudioCalibrator {
|
|
|
1038
1036
|
.catch(err => {
|
|
1039
1037
|
console.error(err);
|
|
1040
1038
|
});
|
|
1041
|
-
|
|
1042
|
-
this.addTimeStamp(
|
|
1039
|
+
|
|
1040
|
+
this.addTimeStamp('Get PSD of filtered recording (test component)');
|
|
1043
1041
|
let test_conv_results = await this.pyServerAPI
|
|
1044
1042
|
.getSubtractedPSDWithRetry(return_test_conv_rec, knownGain, knownFreq, sampleRate)
|
|
1045
1043
|
.then(res => {
|
|
@@ -1056,7 +1054,7 @@ class Combination extends AudioCalibrator {
|
|
|
1056
1054
|
|
|
1057
1055
|
unconv_rec = this.componentInvertedImpulseResponseNoBandpass;
|
|
1058
1056
|
conv_rec = this.componentInvertedImpulseResponse;
|
|
1059
|
-
this.addTimeStamp(
|
|
1057
|
+
this.addTimeStamp('Get PSD of component iir and component iir no bandpass');
|
|
1060
1058
|
let component_iir_psd = await this.pyServerAPI
|
|
1061
1059
|
.getPSDWithRetry({
|
|
1062
1060
|
unconv_rec,
|
|
@@ -1076,7 +1074,7 @@ class Combination extends AudioCalibrator {
|
|
|
1076
1074
|
});
|
|
1077
1075
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
1078
1076
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
1079
|
-
this.addTimeStamp(
|
|
1077
|
+
this.addTimeStamp('Get PSD of system iir and system iir no bandpass');
|
|
1080
1078
|
let system_iir_psd = await this.pyServerAPI
|
|
1081
1079
|
.getPSDWithRetry({
|
|
1082
1080
|
unconv_rec,
|
|
@@ -1094,8 +1092,8 @@ class Combination extends AudioCalibrator {
|
|
|
1094
1092
|
.catch(err => {
|
|
1095
1093
|
console.error(err);
|
|
1096
1094
|
});
|
|
1097
|
-
|
|
1098
|
-
this.addTimeStamp(
|
|
1095
|
+
|
|
1096
|
+
this.addTimeStamp('Get PSD of mls sequence');
|
|
1099
1097
|
let mls_psd = await this.pyServerAPI
|
|
1100
1098
|
.getMLSPSDWithRetry({
|
|
1101
1099
|
mls: this.#mlsBufferView,
|
|
@@ -1113,7 +1111,7 @@ class Combination extends AudioCalibrator {
|
|
|
1113
1111
|
console.error(err);
|
|
1114
1112
|
});
|
|
1115
1113
|
|
|
1116
|
-
this.addTimeStamp(
|
|
1114
|
+
this.addTimeStamp('Get PSD of filtered mls (component)');
|
|
1117
1115
|
let filtered_mls_psd = await this.pyServerAPI
|
|
1118
1116
|
.getMLSPSDWithRetry({
|
|
1119
1117
|
mls: this.componentConvolution,
|
|
@@ -1195,7 +1193,7 @@ class Combination extends AudioCalibrator {
|
|
|
1195
1193
|
impulseResponses: [],
|
|
1196
1194
|
};
|
|
1197
1195
|
} else {
|
|
1198
|
-
this.addTimeStamp(
|
|
1196
|
+
this.addTimeStamp('Get PSD of filtered recording (system) and unfiltered recording');
|
|
1199
1197
|
let results = await this.pyServerAPI
|
|
1200
1198
|
.getPSDWithRetry({
|
|
1201
1199
|
unconv_rec,
|
|
@@ -1217,7 +1215,7 @@ class Combination extends AudioCalibrator {
|
|
|
1217
1215
|
//iir w/ and without bandpass psd
|
|
1218
1216
|
unconv_rec = this.componentInvertedImpulseResponseNoBandpass;
|
|
1219
1217
|
conv_rec = this.componentInvertedImpulseResponse;
|
|
1220
|
-
this.addTimeStamp(
|
|
1218
|
+
this.addTimeStamp('Get PSD of component iir and component iir no band pass');
|
|
1221
1219
|
let component_iir_psd = await this.pyServerAPI
|
|
1222
1220
|
.getPSDWithRetry({
|
|
1223
1221
|
unconv_rec,
|
|
@@ -1237,7 +1235,7 @@ class Combination extends AudioCalibrator {
|
|
|
1237
1235
|
});
|
|
1238
1236
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
1239
1237
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
1240
|
-
this.addTimeStamp(
|
|
1238
|
+
this.addTimeStamp('Get PSD of system iir and system iir no band pass');
|
|
1241
1239
|
let system_iir_psd = await this.pyServerAPI
|
|
1242
1240
|
.getPSDWithRetry({
|
|
1243
1241
|
unconv_rec,
|
|
@@ -1256,7 +1254,7 @@ class Combination extends AudioCalibrator {
|
|
|
1256
1254
|
console.error(err);
|
|
1257
1255
|
});
|
|
1258
1256
|
|
|
1259
|
-
this.addTimeStamp(
|
|
1257
|
+
this.addTimeStamp('Get PSD of mls sequence');
|
|
1260
1258
|
let mls_psd = await this.pyServerAPI
|
|
1261
1259
|
.getMLSPSDWithRetry({
|
|
1262
1260
|
mls: this.#mlsBufferView,
|
|
@@ -1274,8 +1272,7 @@ class Combination extends AudioCalibrator {
|
|
|
1274
1272
|
console.error(err);
|
|
1275
1273
|
});
|
|
1276
1274
|
|
|
1277
|
-
|
|
1278
|
-
this.addTimeStamp("Get PSD of filtered mls (system)");
|
|
1275
|
+
this.addTimeStamp('Get PSD of filtered mls (system)');
|
|
1279
1276
|
let filtered_mls_psd = await this.pyServerAPI
|
|
1280
1277
|
.getMLSPSDWithRetry({
|
|
1281
1278
|
mls: this.systemConvolution,
|
|
@@ -1398,8 +1395,6 @@ class Combination extends AudioCalibrator {
|
|
|
1398
1395
|
* @example
|
|
1399
1396
|
*/
|
|
1400
1397
|
startCalibrationImpulseResponse = async stream => {
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
1398
|
let desired_time = this.desired_time_per_mls;
|
|
1404
1399
|
let checkRec = 'allhz';
|
|
1405
1400
|
|
|
@@ -1408,7 +1403,7 @@ class Combination extends AudioCalibrator {
|
|
|
1408
1403
|
length = this.sourceSamplingRate * desired_time;
|
|
1409
1404
|
//get mls here
|
|
1410
1405
|
const calibrateSoundBurstDb = this._calibrateSoundBurstDb;
|
|
1411
|
-
this.addTimeStamp(
|
|
1406
|
+
this.addTimeStamp('Get MLS sequence');
|
|
1412
1407
|
await this.pyServerAPI
|
|
1413
1408
|
.getMLSWithRetry({length, calibrateSoundBurstDb})
|
|
1414
1409
|
.then(res => {
|
|
@@ -1717,7 +1712,7 @@ class Combination extends AudioCalibrator {
|
|
|
1717
1712
|
|
|
1718
1713
|
#sendToServerForProcessing = lCalib => {
|
|
1719
1714
|
console.log('Sending data to server');
|
|
1720
|
-
this.addTimeStamp(
|
|
1715
|
+
this.addTimeStamp('Send volume data to server');
|
|
1721
1716
|
let left = this.calibrateSound1000HzPreSec;
|
|
1722
1717
|
let right = this.calibrateSound1000HzPreSec + this.calibrateSound1000HzSec;
|
|
1723
1718
|
this.pyServerAPI
|
|
@@ -1758,7 +1753,7 @@ class Combination extends AudioCalibrator {
|
|
|
1758
1753
|
//this.emit('update', {message: `1000 Hz Calibration: Sound Level ${soundLevelToDiscard} dB`});
|
|
1759
1754
|
this.emit('update', {message: this.status});
|
|
1760
1755
|
this.startTime = new Date().getTime();
|
|
1761
|
-
|
|
1756
|
+
|
|
1762
1757
|
do {
|
|
1763
1758
|
// eslint-disable-next-line no-await-in-loop
|
|
1764
1759
|
await this.volumeCalibrationSteps(
|
|
@@ -1816,7 +1811,7 @@ class Combination extends AudioCalibrator {
|
|
|
1816
1811
|
}
|
|
1817
1812
|
|
|
1818
1813
|
// get the volume calibration parameters from the server
|
|
1819
|
-
this.addTimeStamp(
|
|
1814
|
+
this.addTimeStamp('Get Volume Calibration Parameters');
|
|
1820
1815
|
|
|
1821
1816
|
const parameters = await this.pyServerAPI
|
|
1822
1817
|
.getVolumeCalibrationParameters({
|
|
@@ -1937,10 +1932,10 @@ class Combination extends AudioCalibrator {
|
|
|
1937
1932
|
};
|
|
1938
1933
|
|
|
1939
1934
|
// add time stamp
|
|
1940
|
-
addTimeStamp =
|
|
1941
|
-
let startTaskTime = (new Date().getTime() - this.startTime)/1000;
|
|
1935
|
+
addTimeStamp = taskName => {
|
|
1936
|
+
let startTaskTime = (new Date().getTime() - this.startTime) / 1000;
|
|
1942
1937
|
this.timeStamp.push(`SOUND ${Number(startTaskTime.toFixed(1))} s. ${taskName}`);
|
|
1943
|
-
}
|
|
1938
|
+
};
|
|
1944
1939
|
|
|
1945
1940
|
// Example of how to use the writeFrqGain and readFrqGain functions
|
|
1946
1941
|
// writeFrqGain('speaker1', [1, 2, 3], [4, 5, 6]);
|
|
@@ -2005,7 +2000,7 @@ class Combination extends AudioCalibrator {
|
|
|
2005
2000
|
// const OEM = "minidsp";
|
|
2006
2001
|
const micInfo = {
|
|
2007
2002
|
micModelName: isSmartPhone ? micModelName : microphoneName,
|
|
2008
|
-
OEM: OEM,
|
|
2003
|
+
OEM: isSmartPhone ? this.deviceInfo.OEM : micManufacturer,
|
|
2009
2004
|
ID: ID,
|
|
2010
2005
|
HardwareName: isSmartPhone ? this.deviceInfo.hardwarename : microphoneName,
|
|
2011
2006
|
hardwareFamily: isSmartPhone ? this.deviceInfo.hardwarefamily : microphoneName,
|
|
@@ -2079,7 +2074,7 @@ class Combination extends AudioCalibrator {
|
|
|
2079
2074
|
total_results['audioInfo']['sourceSampleRate'] = this.sourceSamplingRate;
|
|
2080
2075
|
total_results['audioInfo']['bitsPerSample'] = this.sampleSize;
|
|
2081
2076
|
const timeStampresult = [...this.timeStamp].join('\n');
|
|
2082
|
-
total_results[
|
|
2077
|
+
total_results['timeStamps'] = timeStampresult;
|
|
2083
2078
|
console.log('total results');
|
|
2084
2079
|
console.log(total_results);
|
|
2085
2080
|
console.log('Time Stamps');
|