speaker-calibration 2.2.218 → 2.2.219
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 +2748 -2772
- package/dist/example/styles.css +75 -22
- package/dist/listener.js +745 -2621
- package/dist/main.js +3 -14
- package/package.json +1 -1
- package/src/listener-app/listener.js +288 -90
- package/src/main.js +1 -2
- package/src/peer-connection/listener.js +37 -17
- package/src/peer-connection/speaker.js +98 -55
- package/src/tasks/combination/combination.js +7 -0
|
@@ -45,6 +45,7 @@ class Speaker extends AudioPeer {
|
|
|
45
45
|
this.deviceId = params?.micrpohoneIdFromWebAudioApi ?? '';
|
|
46
46
|
this.buttonsContainer = params?.buttonsContainer ?? document.createElement('div');
|
|
47
47
|
this.phrases = params?.phrases ?? {};
|
|
48
|
+
this.permissionStatus = 'pending';
|
|
48
49
|
|
|
49
50
|
/* Set up callbacks that handle any events related to our peer object. */
|
|
50
51
|
}
|
|
@@ -138,10 +139,19 @@ class Speaker extends AudioPeer {
|
|
|
138
139
|
await speaker.initPeer();
|
|
139
140
|
// wrap the calibration process in a promise so we can await it
|
|
140
141
|
return new Promise((resolve, reject) => {
|
|
142
|
+
// Add a permission check handler
|
|
143
|
+
const permissionCheckInterval = setInterval(() => {
|
|
144
|
+
if (speaker.permissionStatus === 'error' || speaker.permissionStatus === 'denied') {
|
|
145
|
+
clearInterval(permissionCheckInterval);
|
|
146
|
+
speaker.#removeUIElems();
|
|
147
|
+
resolve('permission denied');
|
|
148
|
+
}
|
|
149
|
+
}, 100);
|
|
150
|
+
|
|
141
151
|
// when a call is received
|
|
142
152
|
speaker.peer.on('call', async call => {
|
|
143
|
-
//
|
|
144
|
-
|
|
153
|
+
clearInterval(permissionCheckInterval); // Clear interval when call is received
|
|
154
|
+
// Rest of the existing call handling code...
|
|
145
155
|
call.answer();
|
|
146
156
|
speaker.#removeUIElems();
|
|
147
157
|
speaker.#showSpinner();
|
|
@@ -218,6 +228,7 @@ class Speaker extends AudioPeer {
|
|
|
218
228
|
});
|
|
219
229
|
// if we do not receive a result within the timeout, reject
|
|
220
230
|
setTimeout(() => {
|
|
231
|
+
clearInterval(permissionCheckInterval);
|
|
221
232
|
reject(
|
|
222
233
|
new CalibrationTimedOutError(
|
|
223
234
|
`Calibration failed to produce a result after ${
|
|
@@ -657,6 +668,20 @@ class Speaker extends AudioPeer {
|
|
|
657
668
|
this.ac.setDeviceInfo(data.payload);
|
|
658
669
|
console.log('Received device info from listener: ', data.payload);
|
|
659
670
|
break;
|
|
671
|
+
case 'permissionStatus':
|
|
672
|
+
console.log('Received permission status from listener: ', data.payload);
|
|
673
|
+
if (data.payload.type === 'error') {
|
|
674
|
+
this.permissionStatus = 'error';
|
|
675
|
+
this.ac.setPermissionStatus('error');
|
|
676
|
+
} else if (data.payload.type === 'denied') {
|
|
677
|
+
this.permissionStatus = 'denied';
|
|
678
|
+
this.ac.setPermissionStatus('denied');
|
|
679
|
+
} else if (data.payload.type === 'granted') {
|
|
680
|
+
this.permissionStatus = 'granted';
|
|
681
|
+
this.ac.setPermissionStatus('granted');
|
|
682
|
+
console.log('Permission granted');
|
|
683
|
+
}
|
|
684
|
+
break;
|
|
660
685
|
case UnsupportedDeviceError.name:
|
|
661
686
|
case MissingSpeakerIdError.name:
|
|
662
687
|
throw data.payload;
|
|
@@ -700,59 +725,77 @@ class Speaker extends AudioPeer {
|
|
|
700
725
|
|
|
701
726
|
console.log('This is a repeat');
|
|
702
727
|
// wrap the calibration process in a promise so we can await it
|
|
703
|
-
return new Promise(
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
728
|
+
return new Promise((resolve, reject) => {
|
|
729
|
+
// Add a permission check handler
|
|
730
|
+
const permissionCheckInterval = setInterval(() => {
|
|
731
|
+
if (this.permissionStatus === 'error' || this.permissionStatus === 'denied') {
|
|
732
|
+
clearInterval(permissionCheckInterval);
|
|
733
|
+
this.#removeUIElems();
|
|
734
|
+
resolve('permission denied');
|
|
735
|
+
}
|
|
736
|
+
}, 100);
|
|
737
|
+
|
|
738
|
+
// Start calibration process
|
|
739
|
+
(async () => {
|
|
740
|
+
try {
|
|
741
|
+
const result = await this.ac.startCalibration(
|
|
742
|
+
stream,
|
|
743
|
+
params.gainValues,
|
|
744
|
+
params.ICalib,
|
|
745
|
+
params.knownIR,
|
|
746
|
+
params.microphoneName,
|
|
747
|
+
params.calibrateSoundCheck,
|
|
748
|
+
params.isSmartPhone,
|
|
749
|
+
params.calibrateSoundBurstDb,
|
|
750
|
+
params.calibrateSoundBurstFilteredExtraDb,
|
|
751
|
+
params.calibrateSoundBurstLevelReTBool,
|
|
752
|
+
params.calibrateSoundBurstUses1000HzGainBool,
|
|
753
|
+
params.calibrateSoundBurstRepeats,
|
|
754
|
+
params.calibrateSoundBurstSec,
|
|
755
|
+
params._calibrateSoundBurstPreSec,
|
|
756
|
+
params._calibrateSoundBurstPostSec,
|
|
757
|
+
params.calibrateSoundHz,
|
|
758
|
+
params.calibrateSoundIRSec,
|
|
759
|
+
params.calibrateSoundIIRSec,
|
|
760
|
+
params.calibrateSoundIIRPhase,
|
|
761
|
+
params.calibrateSound1000HzPreSec,
|
|
762
|
+
params.calibrateSound1000HzSec,
|
|
763
|
+
params.calibrateSound1000HzPostSec,
|
|
764
|
+
params.calibrateSoundBackgroundSecs,
|
|
765
|
+
params.calibrateSoundSmoothOctaves,
|
|
766
|
+
params.calibrateSoundSmoothMinBandwidthHz,
|
|
767
|
+
params.calibrateSoundPowerBinDesiredSec,
|
|
768
|
+
params.calibrateSoundPowerDbSDToleratedDb,
|
|
769
|
+
params.calibrateSoundTaperSec,
|
|
770
|
+
params.micManufacturer,
|
|
771
|
+
params.micSerialNumber,
|
|
772
|
+
params.micModelNumber,
|
|
773
|
+
params.micModelName,
|
|
774
|
+
params.calibrateMicrophonesBool,
|
|
775
|
+
params.authorEmails,
|
|
776
|
+
params.webAudioDeviceNames,
|
|
777
|
+
params.IDsToSaveInSoundProfileLibrary,
|
|
778
|
+
params.restartButton,
|
|
779
|
+
params.reminder,
|
|
780
|
+
params.calibrateSoundLimit,
|
|
781
|
+
params.calibrateSoundBurstNormalizeBy1000HzGainBool,
|
|
782
|
+
params.calibrateSoundBurstScalarDB,
|
|
783
|
+
params.calibrateSound1000HzMaxSD_dB,
|
|
784
|
+
params._calibrateSoundBurstMaxSD_dB,
|
|
785
|
+
params.calibrateSoundSamplingDesiredBits,
|
|
786
|
+
params.language,
|
|
787
|
+
params.loudspeakerModelName,
|
|
788
|
+
params.phrases,
|
|
789
|
+
params.soundSubtitleId
|
|
790
|
+
);
|
|
791
|
+
clearInterval(permissionCheckInterval);
|
|
792
|
+
this.#removeUIElems();
|
|
793
|
+
resolve(result);
|
|
794
|
+
} catch (error) {
|
|
795
|
+
clearInterval(permissionCheckInterval);
|
|
796
|
+
reject(error);
|
|
797
|
+
}
|
|
798
|
+
})();
|
|
756
799
|
});
|
|
757
800
|
};
|
|
758
801
|
}
|
|
@@ -296,6 +296,8 @@ class Combination extends AudioCalibrator {
|
|
|
296
296
|
fs2;
|
|
297
297
|
icapture = 0;
|
|
298
298
|
|
|
299
|
+
permissionStatus = null;
|
|
300
|
+
|
|
299
301
|
/**generate string template that gets reevaluated as variable increases */
|
|
300
302
|
generateTemplate = status => {
|
|
301
303
|
if (this.isCalibrating) {
|
|
@@ -362,6 +364,10 @@ class Combination extends AudioCalibrator {
|
|
|
362
364
|
this.deviceInfo = deviceInfo;
|
|
363
365
|
};
|
|
364
366
|
|
|
367
|
+
setPermissionStatus = permissionStatus => {
|
|
368
|
+
this.permissionStatus = permissionStatus;
|
|
369
|
+
};
|
|
370
|
+
|
|
365
371
|
/** .
|
|
366
372
|
* .
|
|
367
373
|
* .
|
|
@@ -3147,6 +3153,7 @@ class Combination extends AudioCalibrator {
|
|
|
3147
3153
|
total_results['system']['phase'] = this.systemIRPhase;
|
|
3148
3154
|
total_results['qualityMetrics'] = this.SDofFilteredRange;
|
|
3149
3155
|
total_results['flags'] = this.flags;
|
|
3156
|
+
total_results['permissionStatus'] = this.permissionStatus;
|
|
3150
3157
|
console.log('total results');
|
|
3151
3158
|
console.log(total_results);
|
|
3152
3159
|
console.log('Time Stamps');
|