speaker-calibration 2.1.28 → 2.1.30
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/.vscode/settings.json +3 -0
- package/dist/example/i18n.js +440 -647
- package/dist/example/listener.html +3 -24
- package/dist/example/listener.js +44 -10
- package/dist/main.js +3 -3
- package/package.json +1 -1
- package/src/peer-connection/speaker.js +17 -6
- package/src/server/PythonServerAPI.js +59 -4
- package/src/tasks/combination/combination.js +63 -18
|
@@ -129,6 +129,9 @@ class Combination extends AudioCalibrator {
|
|
|
129
129
|
/**@private */
|
|
130
130
|
componentIR = null;
|
|
131
131
|
|
|
132
|
+
/**@private */
|
|
133
|
+
oldComponentIR = null;
|
|
134
|
+
|
|
132
135
|
/**@private */
|
|
133
136
|
systemIR = null;
|
|
134
137
|
|
|
@@ -144,7 +147,7 @@ class Combination extends AudioCalibrator {
|
|
|
144
147
|
if (this.percent_complete > 100) {
|
|
145
148
|
this.percent_complete = 100;
|
|
146
149
|
}
|
|
147
|
-
const template = `<div style="display: flex; justify-content: center;"><div style="width:
|
|
150
|
+
const template = `<div style="display: flex; justify-content: center;"><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>`;
|
|
148
151
|
return template;
|
|
149
152
|
};
|
|
150
153
|
|
|
@@ -708,10 +711,49 @@ class Combination extends AudioCalibrator {
|
|
|
708
711
|
let recs = this.getAllRecordedSignals();
|
|
709
712
|
let unconv_rec = recs[0];
|
|
710
713
|
let conv_rec = conv_recs[0];
|
|
711
|
-
|
|
714
|
+
if (this._calibrateSoundCheck != 'system'){
|
|
715
|
+
let knownGain = this.oldComponentIR.Gain;
|
|
716
|
+
let knownFreq = this.oldComponentIR.Freq;
|
|
717
|
+
let sampleRate = this.sourceSamplingRate || 96000;
|
|
718
|
+
let unconv_results = await this.pyServerAPI.getSubtractedPSDWithRetry(unconv_rec,knownGain,knownFreq,sampleRate).then(res => {
|
|
719
|
+
this.incrementStatusBar();
|
|
720
|
+
this.status =
|
|
721
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
722
|
+
this.generateTemplate().toString();
|
|
723
|
+
this.emit('update', {message: this.status});
|
|
724
|
+
return res;
|
|
725
|
+
})
|
|
726
|
+
.catch(err => {
|
|
727
|
+
console.error(err);
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
let conv_results = await this.pyServerAPI.getSubtractedPSDWithRetry(conv_rec,knownGain,knownFreq,sampleRate).then(res => {
|
|
731
|
+
this.incrementStatusBar();
|
|
732
|
+
this.status =
|
|
733
|
+
`All Hz Calibration: done computing the PSD graphs...`.toString() +
|
|
734
|
+
this.generateTemplate().toString();
|
|
735
|
+
this.emit('update', {message: this.status});
|
|
736
|
+
return res;
|
|
737
|
+
})
|
|
738
|
+
.catch(err => {
|
|
739
|
+
console.error(err);
|
|
740
|
+
});
|
|
741
|
+
iir_ir_and_plots = {
|
|
742
|
+
systemIIR: this.systemInvertedImpulseResponse,
|
|
743
|
+
componentIIR: this.componentInvertedImpulseResponse,
|
|
744
|
+
x_unconv: unconv_results['x'],
|
|
745
|
+
y_unconv: unconv_results['y'],
|
|
746
|
+
x_conv: conv_results['x'],
|
|
747
|
+
y_conv: conv_results['y'],
|
|
748
|
+
componentIR: this.componentIR,
|
|
749
|
+
systemIR: this.systemIR,
|
|
750
|
+
};
|
|
751
|
+
}else{
|
|
752
|
+
let results = await this.pyServerAPI
|
|
712
753
|
.getPSDWithRetry({
|
|
713
754
|
unconv_rec,
|
|
714
755
|
conv_rec,
|
|
756
|
+
sampleRate: this.sourceSamplingRate || 96000
|
|
715
757
|
})
|
|
716
758
|
.then(res => {
|
|
717
759
|
this.incrementStatusBar();
|
|
@@ -724,16 +766,18 @@ class Combination extends AudioCalibrator {
|
|
|
724
766
|
.catch(err => {
|
|
725
767
|
console.error(err);
|
|
726
768
|
});
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
769
|
+
iir_ir_and_plots = {
|
|
770
|
+
systemIIR: this.systemInvertedImpulseResponse,
|
|
771
|
+
componentIIR: this.componentInvertedImpulseResponse,
|
|
772
|
+
x_unconv: results['x_unconv'],
|
|
773
|
+
y_unconv: results['y_unconv'],
|
|
774
|
+
x_conv: results['x_conv'],
|
|
775
|
+
y_conv: results['y_conv'],
|
|
776
|
+
componentIR: this.componentIR,
|
|
777
|
+
systemIR: this.systemIR,
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
|
|
737
781
|
if (this.#download) {
|
|
738
782
|
this.downloadSingleUnfilteredRecording();
|
|
739
783
|
this.downloadSingleFilteredRecording();
|
|
@@ -1054,8 +1098,8 @@ class Combination extends AudioCalibrator {
|
|
|
1054
1098
|
};
|
|
1055
1099
|
|
|
1056
1100
|
writeGainat1000Hz = async (speakerID, gain) => {
|
|
1057
|
-
const data = {
|
|
1058
|
-
await set(ref(database, `Microphone/${speakerID}`),
|
|
1101
|
+
const data = {Gain: gain};
|
|
1102
|
+
await set(ref(database, `Microphone/${speakerID}/Gain1000`), gain);
|
|
1059
1103
|
};
|
|
1060
1104
|
|
|
1061
1105
|
convertToDB = gain => {
|
|
@@ -1091,7 +1135,7 @@ class Combination extends AudioCalibrator {
|
|
|
1091
1135
|
|
|
1092
1136
|
writeIsSmartPhone = async (speakerID, isSmartPhone) => {
|
|
1093
1137
|
const data = {isSmartPhone: isSmartPhone};
|
|
1094
|
-
await set(ref(database, `Microphone/${speakerID}`),
|
|
1138
|
+
await set(ref(database, `Microphone/${speakerID}/isSmartPhone`), isSmartPhone);
|
|
1095
1139
|
};
|
|
1096
1140
|
|
|
1097
1141
|
// Example of how to use the writeFrqGain and readFrqGain functions
|
|
@@ -1105,13 +1149,12 @@ class Combination extends AudioCalibrator {
|
|
|
1105
1149
|
gainValues,
|
|
1106
1150
|
lCalib = 104.92978421490648,
|
|
1107
1151
|
componentIR = null,
|
|
1108
|
-
microphoneName = '
|
|
1109
|
-
_calibrateSoundCheck = '
|
|
1152
|
+
microphoneName = 'MiniDSP-UMIK1-711-4754-vertical',
|
|
1153
|
+
_calibrateSoundCheck = 'goal', //GOAL PASSed in by default
|
|
1110
1154
|
isSmartPhone = false
|
|
1111
1155
|
) => {
|
|
1112
1156
|
//feed calibration goal here
|
|
1113
1157
|
this._calibrateSoundCheck = _calibrateSoundCheck;
|
|
1114
|
-
|
|
1115
1158
|
//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
|
|
1116
1159
|
//check the db based on the microphone currently connected
|
|
1117
1160
|
|
|
@@ -1141,6 +1184,8 @@ class Combination extends AudioCalibrator {
|
|
|
1141
1184
|
await this.writeIsSmartPhone(microphoneName, isSmartPhone);
|
|
1142
1185
|
}
|
|
1143
1186
|
|
|
1187
|
+
this.oldComponentIR = this.componentIR;
|
|
1188
|
+
|
|
1144
1189
|
//TODO:
|
|
1145
1190
|
//if *1000 is in, lcalib is that value and componentGainDBSPL is that value converted to dB
|
|
1146
1191
|
//this value (lcalib) is 1000 hz offset so it must be added to every gain
|