speaker-calibration 2.2.209 → 2.2.211
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/.gitignore +81 -0
- package/dist/main.js +1223 -1223
- package/dist/main.js.LICENSE.txt +118 -118
- package/package.json +1 -1
- package/src/tasks/audioCalibrator.js +19 -4
- package/src/tasks/combination/combination.js +35 -20
- package/.github/workflows/update-phrases.yml +0 -37
- package/makefile +0 -74
package/dist/main.js.LICENSE.txt
CHANGED
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2018 Google LLC
|
|
21
|
-
*
|
|
22
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
-
* you may not use this file except in compliance with the License.
|
|
24
|
-
* You may obtain a copy of the License at
|
|
25
|
-
*
|
|
26
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
-
* See the License for the specific language governing permissions and
|
|
32
|
-
* limitations under the License.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @license
|
|
37
|
-
* Copyright 2019 Google LLC
|
|
38
|
-
*
|
|
39
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
40
|
-
* you may not use this file except in compliance with the License.
|
|
41
|
-
* You may obtain a copy of the License at
|
|
42
|
-
*
|
|
43
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
44
|
-
*
|
|
45
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
46
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
47
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
48
|
-
* See the License for the specific language governing permissions and
|
|
49
|
-
* limitations under the License.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @license
|
|
54
|
-
* Copyright 2020 Google LLC
|
|
55
|
-
*
|
|
56
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
57
|
-
* you may not use this file except in compliance with the License.
|
|
58
|
-
* You may obtain a copy of the License at
|
|
59
|
-
*
|
|
60
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
61
|
-
*
|
|
62
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
63
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
64
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
65
|
-
* See the License for the specific language governing permissions and
|
|
66
|
-
* limitations under the License.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @license
|
|
71
|
-
* Copyright 2021 Google LLC
|
|
72
|
-
*
|
|
73
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
74
|
-
* you may not use this file except in compliance with the License.
|
|
75
|
-
* You may obtain a copy of the License at
|
|
76
|
-
*
|
|
77
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
78
|
-
*
|
|
79
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
80
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
81
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
82
|
-
* See the License for the specific language governing permissions and
|
|
83
|
-
* limitations under the License.
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @license
|
|
88
|
-
* Copyright 2022 Google LLC
|
|
89
|
-
*
|
|
90
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
91
|
-
* you may not use this file except in compliance with the License.
|
|
92
|
-
* You may obtain a copy of the License at
|
|
93
|
-
*
|
|
94
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
95
|
-
*
|
|
96
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
97
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
98
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
99
|
-
* See the License for the specific language governing permissions and
|
|
100
|
-
* limitations under the License.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @license
|
|
105
|
-
* Copyright 2023 Google LLC
|
|
106
|
-
*
|
|
107
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
108
|
-
* you may not use this file except in compliance with the License.
|
|
109
|
-
* You may obtain a copy of the License at
|
|
110
|
-
*
|
|
111
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
112
|
-
*
|
|
113
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
114
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
115
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
116
|
-
* See the License for the specific language governing permissions and
|
|
117
|
-
* limitations under the License.
|
|
118
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2018 Google LLC
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
+
* you may not use this file except in compliance with the License.
|
|
24
|
+
* You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @license
|
|
37
|
+
* Copyright 2019 Google LLC
|
|
38
|
+
*
|
|
39
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
40
|
+
* you may not use this file except in compliance with the License.
|
|
41
|
+
* You may obtain a copy of the License at
|
|
42
|
+
*
|
|
43
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
44
|
+
*
|
|
45
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
46
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
47
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
48
|
+
* See the License for the specific language governing permissions and
|
|
49
|
+
* limitations under the License.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2020 Google LLC
|
|
55
|
+
*
|
|
56
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
57
|
+
* you may not use this file except in compliance with the License.
|
|
58
|
+
* You may obtain a copy of the License at
|
|
59
|
+
*
|
|
60
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
61
|
+
*
|
|
62
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
63
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
64
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
65
|
+
* See the License for the specific language governing permissions and
|
|
66
|
+
* limitations under the License.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @license
|
|
71
|
+
* Copyright 2021 Google LLC
|
|
72
|
+
*
|
|
73
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
74
|
+
* you may not use this file except in compliance with the License.
|
|
75
|
+
* You may obtain a copy of the License at
|
|
76
|
+
*
|
|
77
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
78
|
+
*
|
|
79
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
80
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
81
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
82
|
+
* See the License for the specific language governing permissions and
|
|
83
|
+
* limitations under the License.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @license
|
|
88
|
+
* Copyright 2022 Google LLC
|
|
89
|
+
*
|
|
90
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
91
|
+
* you may not use this file except in compliance with the License.
|
|
92
|
+
* You may obtain a copy of the License at
|
|
93
|
+
*
|
|
94
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
95
|
+
*
|
|
96
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
97
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
98
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
99
|
+
* See the License for the specific language governing permissions and
|
|
100
|
+
* limitations under the License.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @license
|
|
105
|
+
* Copyright 2023 Google LLC
|
|
106
|
+
*
|
|
107
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
108
|
+
* you may not use this file except in compliance with the License.
|
|
109
|
+
* You may obtain a copy of the License at
|
|
110
|
+
*
|
|
111
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
112
|
+
*
|
|
113
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
114
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
115
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
116
|
+
* See the License for the specific language governing permissions and
|
|
117
|
+
* limitations under the License.
|
|
118
|
+
*/
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ class AudioCalibrator extends AudioRecorder {
|
|
|
23
23
|
this.numCaptures = numCaptures;
|
|
24
24
|
this.numMLSPerCapture = numMLSPerCapture;
|
|
25
25
|
this.pyServerAPI = new PythonServerAPI();
|
|
26
|
+
this.currentTime = 0;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/** @private */
|
|
@@ -70,9 +71,22 @@ class AudioCalibrator extends AudioRecorder {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
addTimeStamp = taskName => {
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
const currentTime = new Date().getTime(); // Current time in milliseconds
|
|
75
|
+
const elapsedTime = (currentTime - this.startTime) / 1000; // Total time since start in seconds
|
|
76
|
+
const stepDuration = elapsedTime - this.currentTime; // Time taken for the current step
|
|
77
|
+
|
|
78
|
+
this.currentTime = elapsedTime; // Update for the next step
|
|
79
|
+
|
|
80
|
+
// Round to 1 decimal place for consistent formatting
|
|
81
|
+
|
|
82
|
+
;
|
|
83
|
+
|
|
84
|
+
// Log the timestamp with aligned bars
|
|
85
|
+
this.timeStamp.push(
|
|
86
|
+
`SOUND Total: ${elapsedTime.toFixed(1)} s Step: ${stepDuration.toFixed(1)} s ${taskName}`
|
|
87
|
+
);
|
|
75
88
|
};
|
|
89
|
+
|
|
76
90
|
|
|
77
91
|
recordBackground = async (
|
|
78
92
|
stream,
|
|
@@ -144,7 +158,7 @@ class AudioCalibrator extends AudioRecorder {
|
|
|
144
158
|
console.warn('beforeRecord');
|
|
145
159
|
await beforeRecord();
|
|
146
160
|
const totalSec = this._calibrateSoundBurstPreSec + (this.numMLSPerCapture - this.num_mls_to_skip) * this._calibrateSoundBurstSec + this._calibrateSoundBurstPostSec;
|
|
147
|
-
|
|
161
|
+
|
|
148
162
|
|
|
149
163
|
// calibration loop
|
|
150
164
|
while (loopCondition()) {
|
|
@@ -194,6 +208,7 @@ class AudioCalibrator extends AudioRecorder {
|
|
|
194
208
|
) => {
|
|
195
209
|
this.numCalibratingRoundsCompleted = 0;
|
|
196
210
|
this.numCalibratingRounds = 2;
|
|
211
|
+
console.log("maxSD in VolumeCaibrationSteps: ", maxSD, '0' >= maxSD);
|
|
197
212
|
// calibration loop
|
|
198
213
|
while (!this.isCalibrating && this.numCalibratingRoundsCompleted < this.numCalibratingRounds) {
|
|
199
214
|
if (this.isCalibrating) break;
|
|
@@ -213,7 +228,7 @@ class AudioCalibrator extends AudioRecorder {
|
|
|
213
228
|
if (this.isCalibrating) break;
|
|
214
229
|
// after recording
|
|
215
230
|
await afterRecord(lCalib);
|
|
216
|
-
const sd = await checkSD()
|
|
231
|
+
const sd = await checkSD();
|
|
217
232
|
if (sd <= maxSD) {
|
|
218
233
|
console.log(`SD =${sd}, less than calibrateSound1000HzMaxSD_dB=${maxSD}`);
|
|
219
234
|
this.numCalibratingRoundsCompleted += 2;
|
|
@@ -455,7 +455,7 @@ class Combination extends AudioCalibrator {
|
|
|
455
455
|
const componentIRFreqs = this.componentIR['Freq'];
|
|
456
456
|
//normalize the component IR gains
|
|
457
457
|
componentIRGains = componentIRGains.map(value => {
|
|
458
|
-
return value
|
|
458
|
+
return value - this._calibrateSoundBurstScalarDB - this._calibrateSoundBurstDb;
|
|
459
459
|
});
|
|
460
460
|
if (this._calibrateSoundBurstNormalizeBy1000HzGainBool) {
|
|
461
461
|
const sineGainAt1000Hz_dB = this.gainDBSPL;
|
|
@@ -551,7 +551,7 @@ class Combination extends AudioCalibrator {
|
|
|
551
551
|
// Slice the array from the calculated start index to the end of the array
|
|
552
552
|
const background_rec = background_rec_whole.slice(startIndex);
|
|
553
553
|
console.log('Sending background recording to server for processing');
|
|
554
|
-
this.addTimeStamp('Compute background
|
|
554
|
+
this.addTimeStamp('Compute PSD of background');
|
|
555
555
|
this.pyServerAPI
|
|
556
556
|
.getBackgroundNoisePSDWithRetry({
|
|
557
557
|
background_rec,
|
|
@@ -780,7 +780,7 @@ class Combination extends AudioCalibrator {
|
|
|
780
780
|
*/
|
|
781
781
|
#afterMLSRecord = async () => {
|
|
782
782
|
console.log('after record');
|
|
783
|
-
this.addTimeStamp(`Send
|
|
783
|
+
this.addTimeStamp(`Send MLS to the server`);
|
|
784
784
|
await this.sendRecordingToServerForProcessing();
|
|
785
785
|
};
|
|
786
786
|
|
|
@@ -903,8 +903,8 @@ class Combination extends AudioCalibrator {
|
|
|
903
903
|
const post = this._calibrateSoundBurstPostSec;
|
|
904
904
|
const total_dur = pre + repeats * burst + post;
|
|
905
905
|
this.addTimeStamp(
|
|
906
|
-
`Record ${total_dur.toFixed(1)} s
|
|
907
|
-
`(${pre.toFixed(1)}
|
|
906
|
+
`Record ${total_dur.toFixed(1)} s ` +
|
|
907
|
+
`(${pre.toFixed(1)} + ${repeats}×${burst.toFixed(1)} + ${post.toFixed(1)} s) of MLS ver. ${this.icapture}`
|
|
908
908
|
);
|
|
909
909
|
this.status = this.generateTemplate(`All Hz Calibration: playing the calibration tone...`.toString()).toString();
|
|
910
910
|
} else if (this.mode === 'filtered') {
|
|
@@ -1337,7 +1337,7 @@ class Combination extends AudioCalibrator {
|
|
|
1337
1337
|
this.filteredMLSRange.component.Max = findMaxValue(this.#currentConvolution);
|
|
1338
1338
|
this.soundCheck = 'component';
|
|
1339
1339
|
this.addTimeStamp(`Record ${total_dur} s of MLS with ${this.soundCheck} IIR.`)
|
|
1340
|
-
this.addTimeStamp(`Record ${total_dur} s of MLS with speaker or microphone IIR.`);
|
|
1340
|
+
//this.addTimeStamp(`Record ${total_dur} s of MLS with speaker or microphone IIR.`);
|
|
1341
1341
|
if (this.isCalibrating) return null;
|
|
1342
1342
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
1343
1343
|
this.stopCalibrationAudio();
|
|
@@ -1347,7 +1347,7 @@ class Combination extends AudioCalibrator {
|
|
|
1347
1347
|
this.filteredMLSRange.system.Max = findMaxValue(this.#currentConvolution);
|
|
1348
1348
|
this.soundCheck = 'system';
|
|
1349
1349
|
this.addTimeStamp(`Record ${total_dur} s of MLS with ${this.soundCheck} IIR.`)
|
|
1350
|
-
this.addTimeStamp(`Record ${total_dur} s of MLS with speaker or microphone IIR.`);
|
|
1350
|
+
//this.addTimeStamp(`Record ${total_dur} s of MLS with speaker or microphone IIR.`);
|
|
1351
1351
|
if (this.isCalibrating) return null;
|
|
1352
1352
|
await this.playMLSwithIIR(stream, this.#currentConvolution);
|
|
1353
1353
|
this.stopCalibrationAudio();
|
|
@@ -1427,7 +1427,7 @@ class Combination extends AudioCalibrator {
|
|
|
1427
1427
|
console.error(err);
|
|
1428
1428
|
});
|
|
1429
1429
|
|
|
1430
|
-
this.addTimeStamp('Compute PSD recording of filtered recording
|
|
1430
|
+
this.addTimeStamp('Compute PSD recording of speaker+ mic IIR-filtered MLS recording');
|
|
1431
1431
|
if (this.isCalibrating) return null;
|
|
1432
1432
|
let conv_results = await this.pyServerAPI
|
|
1433
1433
|
.getSubtractedPSDWithRetry(conv_rec, knownGain, knownFreq, sampleRate)
|
|
@@ -1468,7 +1468,7 @@ class Combination extends AudioCalibrator {
|
|
|
1468
1468
|
|
|
1469
1469
|
unconv_rec = this.componentInvertedImpulseResponseNoBandpass;
|
|
1470
1470
|
conv_rec = this.componentInvertedImpulseResponse;
|
|
1471
|
-
this.addTimeStamp('Compute PSD of
|
|
1471
|
+
this.addTimeStamp('Compute PSD of speaker or mic IIR, with and without bandpass');
|
|
1472
1472
|
if (this.isCalibrating) return null;
|
|
1473
1473
|
let component_iir_psd = await this.pyServerAPI
|
|
1474
1474
|
.getPSDWithRetry({
|
|
@@ -1487,7 +1487,7 @@ class Combination extends AudioCalibrator {
|
|
|
1487
1487
|
});
|
|
1488
1488
|
unconv_rec = this.systemInvertedImpulseResponseNoBandpass;
|
|
1489
1489
|
conv_rec = this.systemInvertedImpulseResponse;
|
|
1490
|
-
this.addTimeStamp('Compute PSD of
|
|
1490
|
+
this.addTimeStamp('Compute PSD of speaker +mic IIR, with and without bandpass');
|
|
1491
1491
|
if (this.isCalibrating) return null;
|
|
1492
1492
|
let system_iir_psd = await this.pyServerAPI
|
|
1493
1493
|
.getPSDWithRetry({
|
|
@@ -1505,7 +1505,7 @@ class Combination extends AudioCalibrator {
|
|
|
1505
1505
|
console.error(err);
|
|
1506
1506
|
});
|
|
1507
1507
|
|
|
1508
|
-
this.addTimeStamp('Compute PSD of MLS
|
|
1508
|
+
this.addTimeStamp('Compute PSD of MLS');
|
|
1509
1509
|
if (this.isCalibrating) return null;
|
|
1510
1510
|
let mls_psd = await this.pyServerAPI
|
|
1511
1511
|
.getMLSPSDWithRetry({
|
|
@@ -1522,7 +1522,7 @@ class Combination extends AudioCalibrator {
|
|
|
1522
1522
|
console.error(err);
|
|
1523
1523
|
});
|
|
1524
1524
|
|
|
1525
|
-
this.addTimeStamp('Compute PSD of
|
|
1525
|
+
this.addTimeStamp('Compute PSD of speaker or mic');
|
|
1526
1526
|
if (this.isCalibrating) return null;
|
|
1527
1527
|
let filtered_mls_psd = await this.pyServerAPI
|
|
1528
1528
|
.getMLSPSDWithRetry({
|
|
@@ -2087,6 +2087,7 @@ class Combination extends AudioCalibrator {
|
|
|
2087
2087
|
if (this.isCalibrating) return null;
|
|
2088
2088
|
this.percent_complete = 100;
|
|
2089
2089
|
this.status = this.generateTemplate(`All Hz Calibration: Finished`.toString()).toString();
|
|
2090
|
+
this.addTimeStamp('Done');
|
|
2090
2091
|
this.emit('update', {message: this.status});
|
|
2091
2092
|
|
|
2092
2093
|
//here after calibration we have the component calibration (either loudspeaker or microphone) in the same form as the componentIR
|
|
@@ -2249,14 +2250,7 @@ class Combination extends AudioCalibrator {
|
|
|
2249
2250
|
|
|
2250
2251
|
#sendToServerForProcessing = async lCalib => {
|
|
2251
2252
|
console.log('Sending data to server');
|
|
2252
|
-
|
|
2253
|
-
this.addTimeStamp(
|
|
2254
|
-
"1000 Hz: recorded at " + this.inDB +
|
|
2255
|
-
" dB (" + this.calibrateSound1000HzPreSec.toFixed(1) +
|
|
2256
|
-
" s pre + " + this.calibrateSound1000HzSec.toFixed(1) +
|
|
2257
|
-
" s used + " + this.calibrateSound1000HzPostSec.toFixed(1) +
|
|
2258
|
-
" s post)"
|
|
2259
|
-
);
|
|
2253
|
+
|
|
2260
2254
|
let left = this.calibrateSound1000HzPreSec;
|
|
2261
2255
|
let right = this.calibrateSound1000HzPreSec + this.calibrateSound1000HzSec;
|
|
2262
2256
|
if (this.isCalibrating) return null;
|
|
@@ -2293,6 +2287,27 @@ class Combination extends AudioCalibrator {
|
|
|
2293
2287
|
this._calibrateSoundPowerBinDesiredSec);
|
|
2294
2288
|
console.log(res);
|
|
2295
2289
|
this.recordingChecks['volume'][this.inDB] = res;
|
|
2290
|
+
console.log("Recording checks in sendToServer", this.recordingChecks['volume']);
|
|
2291
|
+
const getSD = () => this.recordingChecks['volume'][this.inDB]['sd'];
|
|
2292
|
+
const getSDMessage = () => {
|
|
2293
|
+
//SOUND 6.7 s. 2.5+2.5+0.5 s. 1000 Hz at -60 dB. SD = 1.3 dB
|
|
2294
|
+
// And reporting each rejected recording as
|
|
2295
|
+
// SOUND 6.7 s. 2.5+2.5+0.5 s. 1000 Hz at -60 dB, SD = 19.7 > 4 dB.
|
|
2296
|
+
|
|
2297
|
+
if(this.numCalibratingRoundsCompleted==1)
|
|
2298
|
+
return `, SD = ${getSD()} > ${this.calibrateSound1000HzMaxSD_dB} dB.`;
|
|
2299
|
+
return `. SD = ${getSD()} dB`
|
|
2300
|
+
}
|
|
2301
|
+
const total_dur = this.calibrateSound1000HzPreSec + this.calibrateSound1000HzSec + this.calibrateSound1000HzPostSec;
|
|
2302
|
+
|
|
2303
|
+
this.addTimeStamp(
|
|
2304
|
+
`${this.calibrateSound1000HzPreSec.toFixed(1)}` +
|
|
2305
|
+
`+ ${this.calibrateSound1000HzSec.toFixed(1)}` +
|
|
2306
|
+
`+ ${this.calibrateSound1000HzPostSec.toFixed(1)} s.` +
|
|
2307
|
+
`1000 Hz at ${this.inDB} dB${getSDMessage()}`
|
|
2308
|
+
);
|
|
2309
|
+
|
|
2310
|
+
|
|
2296
2311
|
};
|
|
2297
2312
|
|
|
2298
2313
|
startCalibrationVolume = async (stream, gainValues, lCalib, componentGainDBSPL) => {
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: Update International Phrases
|
|
2
|
-
|
|
3
|
-
on: workflow_dispatch
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
phrases:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/checkout@v3
|
|
10
|
-
- uses: actions/setup-node@v3
|
|
11
|
-
with:
|
|
12
|
-
node-version: 16
|
|
13
|
-
- name: Set commit account information
|
|
14
|
-
run: |
|
|
15
|
-
git config --global user.name "github-actions[bot]"
|
|
16
|
-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
17
|
-
- name: Installs
|
|
18
|
-
run: |
|
|
19
|
-
npm install
|
|
20
|
-
- name: Decrypt credentials
|
|
21
|
-
run: |
|
|
22
|
-
gpg --quiet --batch --yes --passphrase="${{secrets.google_api_pw}}" \
|
|
23
|
-
--output dist/example/credentials.json \
|
|
24
|
-
--decrypt dist/example/credentials.json.gpg
|
|
25
|
-
- name: Fetch and update phrases
|
|
26
|
-
run: |
|
|
27
|
-
npm run phrases
|
|
28
|
-
- name: Remove credentials
|
|
29
|
-
run: |
|
|
30
|
-
rm dist/example/credentials.json
|
|
31
|
-
- name: Commit and push changes
|
|
32
|
-
run: |
|
|
33
|
-
git status
|
|
34
|
-
git add -A
|
|
35
|
-
git commit -m 'github action: update phrases' --no-verify
|
|
36
|
-
git remote set-url origin https://x-access-token:${{secrets.ci_token}}@github.com/EasyEyes/speaker-calibration
|
|
37
|
-
git push
|
package/makefile
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
##################################### UTILITIES ######################################
|
|
2
|
-
COM_COLOR = \033[0;34m
|
|
3
|
-
OBJ_COLOR = \033[0;36m
|
|
4
|
-
OK_COLOR = \033[0;32m
|
|
5
|
-
ERROR_COLOR = \033[0;31m
|
|
6
|
-
WARN_COLOR = \033[0;33m
|
|
7
|
-
NO_COLOR = \033[m
|
|
8
|
-
|
|
9
|
-
OK_STRING = "[OK]"
|
|
10
|
-
ERROR_STRING = "[ERROR]"
|
|
11
|
-
WARN_STRING = "[WARNING]"
|
|
12
|
-
COM_STRING = "Compiling..."
|
|
13
|
-
|
|
14
|
-
define run_and_test
|
|
15
|
-
printf "%b" "$(COM_COLOR)$(COM_STRING) $(OBJ_COLOR)$(@F)$(NO_COLOR)\r"; \
|
|
16
|
-
$(1) 2> $@.log; \
|
|
17
|
-
RESULT=$$?; \
|
|
18
|
-
if [ $$RESULT -ne 0 ]; then \
|
|
19
|
-
printf "%-60b%b" "$(COM_COLOR)$(COM_STRING)$(OBJ_COLOR) $@" "$(ERROR_COLOR)$(ERROR_STRING)$(NO_COLOR)\n" ; \
|
|
20
|
-
elif [ -s $@.log ]; then \
|
|
21
|
-
printf "%-60b%b" "$(COM_COLOR)$(COM_STRING)$(OBJ_COLOR) $@" "$(WARN_COLOR)$(WARN_STRING)$(NO_COLOR)\n" ; \
|
|
22
|
-
else \
|
|
23
|
-
printf "%-60b%b" "$(COM_COLOR)$(COM_STRING)$(OBJ_COLOR) $(@F)" "$(OK_COLOR)$(OK_STRING)$(NO_COLOR)\n" ; \
|
|
24
|
-
fi; \
|
|
25
|
-
cat $@.log; \
|
|
26
|
-
rm -f $@.log; \
|
|
27
|
-
exit $$RESULT
|
|
28
|
-
endef
|
|
29
|
-
|
|
30
|
-
##################################### WASM ########################################
|
|
31
|
-
PROJECT_NAME = mlsGen
|
|
32
|
-
|
|
33
|
-
# directories
|
|
34
|
-
DIST_DIR = ./dist/
|
|
35
|
-
SRC_DIR = $(addprefix ./src/tasks/impulse-response/,$(PROJECT_NAME)/)
|
|
36
|
-
|
|
37
|
-
# WASM files
|
|
38
|
-
SRC_FILE := $(addprefix $(SRC_DIR),$(PROJECT_NAME).cpp) # SRC_DIR + PROJECT_NAME + .cpp
|
|
39
|
-
OBJ_FILE := $(addprefix $(SRC_DIR),$(PROJECT_NAME).o)
|
|
40
|
-
OUTPUT_WASM_JS := $(addprefix $(DIST_DIR),$(PROJECT_NAME).js) # DIST_DIR + PROJECT_NAME + .js
|
|
41
|
-
OUTPUT_WASM := $(addprefix $(DIST_DIR),$(PROJECT_NAME).wasm) # DIST_DIR + PROJECT_NAME + .wasm
|
|
42
|
-
OUTPUT := $(addprefix $(DIST_DIR),$(PROJECT_NAME).*) # DIST_DIR + PROJECT_NAME + .*
|
|
43
|
-
|
|
44
|
-
# emcc compiler options
|
|
45
|
-
EMCC = em++ # emcc compiler front end
|
|
46
|
-
STD = --std=c++17 # C++ standard
|
|
47
|
-
OPTIMIZE = -O3 # Optimization level O0 ~ 28.8 kB, O1 ~ 20.3 kB, O2 ~ 20.3 kB, O3 ~ 19.7 kB
|
|
48
|
-
ENV = -s ENVIRONMENT='web' # environment
|
|
49
|
-
NOENTRY = --no-entry # no entry point (no main function)
|
|
50
|
-
MODULARIZE = -s MODULARIZE=1 -s 'EXPORT_NAME="createMLSGenModule"' # puts all of the generated JavaScript into a factory function
|
|
51
|
-
BIND = -lembind # links against embind library
|
|
52
|
-
MEMORY_CHECKS = -s ASSERTIONS=1 -fsanitize=address -g2
|
|
53
|
-
|
|
54
|
-
# gcc compiler options
|
|
55
|
-
GCC = gcc # gcc compiler front end
|
|
56
|
-
|
|
57
|
-
# KISSFFT Library
|
|
58
|
-
KISS_LIB= /Users/hugo/Desktop/dev/easyeyes/speaker-calibration/src/tasks/impulse-response/kissfft/libkissfft-float.a
|
|
59
|
-
KISS_H= -I /Users/hugo/Desktop/dev/easyeyes/speaker-calibration/src/tasks/impulse-response/kissfft/
|
|
60
|
-
|
|
61
|
-
# build the WASM + JS glue module, linked with embind
|
|
62
|
-
$(PROJECT_NAME)_bind: # $(OBJ_FILE)
|
|
63
|
-
@mkdir -p $(@D)
|
|
64
|
-
@$(call run_and_test, $(EMCC) $(STD) $(BIND) $(SRC_FILE) -o $(OUTPUT_WASM_JS) $(MODULARIZE) $(OPTIMIZE) $(ENV) $(MEMORY_CHECKS) $(KISS_H) $(KISS_LIB))
|
|
65
|
-
|
|
66
|
-
# clean the WASM + JS files
|
|
67
|
-
.PHONY: clean
|
|
68
|
-
clean:
|
|
69
|
-
@mkdir -p $(@D)
|
|
70
|
-
@$(call run_and_test, rm -f $(OUTPUT))
|
|
71
|
-
|
|
72
|
-
.PHONY: rebuild
|
|
73
|
-
rebuild:
|
|
74
|
-
@make clean; make $(PROJECT_NAME)_bind
|