speaker-calibration 2.1.9 → 2.1.11

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.1.9",
3
+ "version": "2.1.11",
4
4
  "description": "Speaker calibration library for auditory testing",
5
5
  "main": "dist/main.js",
6
6
  "directories": {
@@ -51,6 +51,34 @@ class PythonServerAPI {
51
51
  return res.data[task];
52
52
  };
53
53
 
54
+ getPSD = async ({unconv_rec, conv_rec}) => {
55
+ const task = 'psd';
56
+ let res = null;
57
+
58
+ const data = JSON.stringify({
59
+ task,
60
+ unconv_rec,
61
+ conv_rec,
62
+ });
63
+
64
+ await axios({
65
+ method: 'post',
66
+ baseURL: PythonServerAPI.PYTHON_SERVER_URL,
67
+ url: `/task/${task}`,
68
+ headers: {
69
+ 'Content-Type': 'application/json',
70
+ },
71
+ data,
72
+ })
73
+ .then(response => {
74
+ res = response;
75
+ })
76
+ .catch(error => {
77
+ throw error;
78
+ });
79
+ return res.data[task];
80
+ };
81
+
54
82
  getInverseImpulseResponse = async ({payload,mls,lowHz,highHz}) => {
55
83
  const task = 'inverse-impulse-response';
56
84
  let res = null;
@@ -481,7 +481,31 @@ class ImpulseResponse extends AudioCalibrator {
481
481
  await this.playMLSwithIIR(stream, this.invertedImpulseResponse);
482
482
  this.#stopCalibrationAudioConvolved();
483
483
 
484
- return this.invertedImpulseResponse;
484
+ let recs = this.getAllRecordedSignals();
485
+ let unconv_rec = recs[0];
486
+ let conv_rec = recs[4];
487
+
488
+ let results = await this.pyServerAPI
489
+ .getPSD({
490
+ unconv_rec,
491
+ conv_rec,
492
+ })
493
+ .then(res => {
494
+ return res;
495
+ })
496
+ .catch(err => {
497
+ console.error(err);
498
+ })
499
+
500
+ let iir_and_plots = {
501
+ "iir": this.invertedImpulseResponse,
502
+ "x_unconv": results["x_unconv"],
503
+ "y_unconv": results["y_unconv"],
504
+ "x_conv": results["x_conv"],
505
+ "y_conv": results["y_conv"]
506
+ }
507
+
508
+ return iir_and_plots;
485
509
  };
486
510
  }
487
511