speaker-calibration 2.2.68 → 2.2.70

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