speaker-calibration 2.2.1 → 2.2.3
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/example/i18n.js +6399 -6370
- package/dist/example/listener.html +1 -1
- package/dist/example/listener.js +53 -27
- package/dist/main.js +3 -3
- package/package.json +1 -1
- package/src/peer-connection/speaker.js +5 -1
- package/src/server/PythonServerAPI.js +50 -0
- package/src/tasks/combination/combination.js +75 -13
- package/.vscode/settings.json +0 -3
|
@@ -142,6 +142,14 @@ class Combination extends AudioCalibrator {
|
|
|
142
142
|
|
|
143
143
|
deviceName = null;
|
|
144
144
|
|
|
145
|
+
desired_time_per_mls = 0;
|
|
146
|
+
|
|
147
|
+
num_mls_to_skip = 0;
|
|
148
|
+
|
|
149
|
+
desired_sampling_rate = 0;
|
|
150
|
+
|
|
151
|
+
#currentConvolution = [];
|
|
152
|
+
|
|
145
153
|
/**generate string template that gets reevaluated as variable increases */
|
|
146
154
|
generateTemplate = () => {
|
|
147
155
|
if (this.percent_complete > 100) {
|
|
@@ -338,7 +346,23 @@ class Combination extends AudioCalibrator {
|
|
|
338
346
|
this.emit('update', {
|
|
339
347
|
message: this.status,
|
|
340
348
|
});
|
|
341
|
-
|
|
349
|
+
let time_to_wait = (this.#mls.length / this.sourceSamplingRate) * this.numMLSPerCapture;
|
|
350
|
+
await sleep(time_to_wait);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
#awaitDesiredMLSLengthConvolved = async () => {
|
|
354
|
+
// seconds per MLS = P / SR
|
|
355
|
+
// await N * P / SR
|
|
356
|
+
this.stepNum += 1;
|
|
357
|
+
console.log('await desired length ' + this.stepNum);
|
|
358
|
+
this.status =
|
|
359
|
+
`All Hz Calibration: sampling the calibration signal...`.toString() + this.generateTemplate();
|
|
360
|
+
this.emit('update', {
|
|
361
|
+
message: this.status,
|
|
362
|
+
});
|
|
363
|
+
let time_to_wait =
|
|
364
|
+
(this.#currentConvolution.length / this.sourceSamplingRate) * this.numMLSPerCapture;
|
|
365
|
+
await sleep(time_to_wait);
|
|
342
366
|
};
|
|
343
367
|
|
|
344
368
|
/** .
|
|
@@ -357,7 +381,25 @@ class Combination extends AudioCalibrator {
|
|
|
357
381
|
this.emit('update', {
|
|
358
382
|
message: this.status,
|
|
359
383
|
});
|
|
360
|
-
|
|
384
|
+
let number_of_bursts_to_skip = this.num_mls_to_skip;
|
|
385
|
+
let time_to_sleep = this.#mls.length / this.sourceSamplingRate;
|
|
386
|
+
//await sleep(this.TAPER_SECS);
|
|
387
|
+
await sleep(time_to_sleep);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
#awaitSignalOnsetConvolved = async () => {
|
|
391
|
+
this.stepNum += 1;
|
|
392
|
+
console.log('await signal onset ' + this.stepNum);
|
|
393
|
+
this.status =
|
|
394
|
+
`All Hz Calibration: waiting for the signal to stabilize...`.toString() +
|
|
395
|
+
this.generateTemplate();
|
|
396
|
+
this.emit('update', {
|
|
397
|
+
message: this.status,
|
|
398
|
+
});
|
|
399
|
+
let number_of_bursts_to_skip = this.num_mls_to_skip;
|
|
400
|
+
let time_to_sleep = this.#currentConvolution.length / this.sourceSamplingRate;
|
|
401
|
+
//await sleep(this.TAPER_SECS);
|
|
402
|
+
await sleep(time_to_sleep);
|
|
361
403
|
};
|
|
362
404
|
|
|
363
405
|
/**
|
|
@@ -464,8 +506,6 @@ class Combination extends AudioCalibrator {
|
|
|
464
506
|
} catch (error) {
|
|
465
507
|
console.error(error);
|
|
466
508
|
}
|
|
467
|
-
console.log('mls second, same?');
|
|
468
|
-
console.log(data);
|
|
469
509
|
const onsetGainNode = audioContext.createGain();
|
|
470
510
|
this.offsetGainNode = audioContext.createGain();
|
|
471
511
|
const source = audioContext.createBufferSource();
|
|
@@ -489,8 +529,6 @@ class Combination extends AudioCalibrator {
|
|
|
489
529
|
*/
|
|
490
530
|
#setCalibrationNodesFromBuffer = (dataBufferArray = [this.#mlsBufferView]) => {
|
|
491
531
|
if (dataBufferArray.length === 1) {
|
|
492
|
-
console.log('data buffer aray');
|
|
493
|
-
console.log(dataBufferArray);
|
|
494
532
|
this.#createCalibrationNodeFromBuffer(dataBufferArray[0]);
|
|
495
533
|
} else {
|
|
496
534
|
throw new Error('The length of the data buffer array must be 1');
|
|
@@ -506,6 +544,7 @@ class Combination extends AudioCalibrator {
|
|
|
506
544
|
|
|
507
545
|
//depends on goal
|
|
508
546
|
if (this._calibrateSoundCheck != 'system') {
|
|
547
|
+
this.#currentConvolution = this.componentConvolution;
|
|
509
548
|
const buffer = audioCtx.createBuffer(
|
|
510
549
|
1, // number of channels
|
|
511
550
|
this.componentConvolution.length,
|
|
@@ -530,6 +569,7 @@ class Combination extends AudioCalibrator {
|
|
|
530
569
|
|
|
531
570
|
this.addCalibrationNodeConvolved(source);
|
|
532
571
|
} else {
|
|
572
|
+
this.#currentConvolution = this.systemConvolution;
|
|
533
573
|
const buffer = audioCtx.createBuffer(
|
|
534
574
|
1, // number of channels
|
|
535
575
|
this.systemConvolution.length,
|
|
@@ -644,11 +684,9 @@ class Combination extends AudioCalibrator {
|
|
|
644
684
|
this.sourceSamplingRate
|
|
645
685
|
).then(mlsGenInterface => {
|
|
646
686
|
this.#mlsGenInterface = mlsGenInterface;
|
|
647
|
-
this.#mlsBufferView = this.#mlsGenInterface.getMLS();
|
|
687
|
+
//this.#mlsBufferView = this.#mlsGenInterface.getMLS();
|
|
648
688
|
});
|
|
649
689
|
|
|
650
|
-
console.log('after mls factory'); //works up to here.
|
|
651
|
-
console.log(this.#mls);
|
|
652
690
|
// after intializating, start the calibration steps with garbage collection
|
|
653
691
|
await this.#mlsGenInterface.withGarbageCollection([
|
|
654
692
|
() =>
|
|
@@ -656,9 +694,9 @@ class Combination extends AudioCalibrator {
|
|
|
656
694
|
stream,
|
|
657
695
|
this.#playCalibrationAudioConvolved, // play audio func (required)
|
|
658
696
|
this.#putInPythonConv, // before play func
|
|
659
|
-
this.#
|
|
697
|
+
this.#awaitSignalOnsetConvolved, // before record
|
|
660
698
|
() => this.numSuccessfulCaptured < 1,
|
|
661
|
-
this.#
|
|
699
|
+
this.#awaitDesiredMLSLengthConvolved, // during record
|
|
662
700
|
this.#afterMLSwIIRRecord, // after record
|
|
663
701
|
'filtered'
|
|
664
702
|
),
|
|
@@ -682,9 +720,24 @@ class Combination extends AudioCalibrator {
|
|
|
682
720
|
this.sourceSamplingRate
|
|
683
721
|
).then(mlsGenInterface => {
|
|
684
722
|
this.#mlsGenInterface = mlsGenInterface;
|
|
685
|
-
this.#mlsBufferView = this.#mlsGenInterface.getMLS();
|
|
723
|
+
//this.#mlsBufferView = this.#mlsGenInterface.getMLS();
|
|
686
724
|
});
|
|
687
725
|
|
|
726
|
+
let desired_time = this.desired_time_per_mls;
|
|
727
|
+
|
|
728
|
+
length = this.sourceSamplingRate * desired_time;
|
|
729
|
+
//get mls here
|
|
730
|
+
await this.pyServerAPI
|
|
731
|
+
.getMLSWithRetry(length)
|
|
732
|
+
.then(res => {
|
|
733
|
+
console.log(res);
|
|
734
|
+
this.#mlsBufferView = res['mls'];
|
|
735
|
+
})
|
|
736
|
+
.catch(err => {
|
|
737
|
+
// this.emit('InvertedImpulseResponse', {res: false});
|
|
738
|
+
console.error(err);
|
|
739
|
+
});
|
|
740
|
+
|
|
688
741
|
// after intializating, start the calibration steps with garbage collection
|
|
689
742
|
await this.#mlsGenInterface.withGarbageCollection([
|
|
690
743
|
() =>
|
|
@@ -1164,8 +1217,17 @@ class Combination extends AudioCalibrator {
|
|
|
1164
1217
|
componentIR = null,
|
|
1165
1218
|
microphoneName = 'MiniDSP-UMIK1-711-4754-vertical',
|
|
1166
1219
|
_calibrateSoundCheck = 'goal', //GOAL PASSed in by default
|
|
1167
|
-
isSmartPhone = false
|
|
1220
|
+
isSmartPhone = false,
|
|
1221
|
+
_calibrateSoundBurstRepeats = 4,
|
|
1222
|
+
_calibrateSoundBurstSec = 1,
|
|
1223
|
+
_calibrateSoundBurstsWarmup = 1,
|
|
1224
|
+
_calibrateSoundHz = 48000
|
|
1168
1225
|
) => {
|
|
1226
|
+
this.numMLSPerCapture = _calibrateSoundBurstRepeats;
|
|
1227
|
+
this.desired_time_per_mls = _calibrateSoundBurstSec;
|
|
1228
|
+
this.num_mls_to_skip = _calibrateSoundBurstsWarmup;
|
|
1229
|
+
this.desired_sampling_rate = _calibrateSoundHz;
|
|
1230
|
+
|
|
1169
1231
|
//feed calibration goal here
|
|
1170
1232
|
this._calibrateSoundCheck = _calibrateSoundCheck;
|
|
1171
1233
|
//check if a componentIR was given to the system, if it isn't check for the microphone. using dummy data here bc we need to
|
package/.vscode/settings.json
DELETED