speaker-calibration 2.2.251 → 2.2.252
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
|
@@ -209,6 +209,10 @@ class Speaker extends AudioPeer {
|
|
|
209
209
|
params.calibrateSoundSimulateMicrophoneTime,
|
|
210
210
|
params.calibrateSoundSimulateLoudspeaker,
|
|
211
211
|
params.calibrateSoundSimulateLoudspeakerTime,
|
|
212
|
+
params.calibrateSoundSimulateMicrophoneFrequencies,
|
|
213
|
+
params.calibrateSoundSimulateLoudspeakerFrequencies,
|
|
214
|
+
params.calibrateSoundSimulateMicrophoneType,
|
|
215
|
+
params.calibrateSoundSimulateLoudspeakerType,
|
|
212
216
|
params.isLoudspeakerCalibration
|
|
213
217
|
);
|
|
214
218
|
speaker.#removeUIElems();
|
|
@@ -347,6 +351,10 @@ class Speaker extends AudioPeer {
|
|
|
347
351
|
params.calibrateSoundSimulateMicrophoneTime,
|
|
348
352
|
params.calibrateSoundSimulateLoudspeaker,
|
|
349
353
|
params.calibrateSoundSimulateLoudspeakerTime,
|
|
354
|
+
params.calibrateSoundSimulateMicrophoneFrequencies,
|
|
355
|
+
params.calibrateSoundSimulateLoudspeakerFrequencies,
|
|
356
|
+
params.calibrateSoundSimulateMicrophoneType,
|
|
357
|
+
params.calibrateSoundSimulateLoudspeakerType,
|
|
350
358
|
params.isLoudspeakerCalibration
|
|
351
359
|
);
|
|
352
360
|
speaker.#removeUIElems();
|
|
@@ -939,6 +947,10 @@ class Speaker extends AudioPeer {
|
|
|
939
947
|
params.calibrateSoundSimulateMicrophoneTime,
|
|
940
948
|
params.calibrateSoundSimulateLoudspeaker,
|
|
941
949
|
params.calibrateSoundSimulateLoudspeakerTime,
|
|
950
|
+
params.calibrateSoundSimulateMicrophoneFrequencies,
|
|
951
|
+
params.calibrateSoundSimulateLoudspeakerFrequencies,
|
|
952
|
+
params.calibrateSoundSimulateMicrophoneType,
|
|
953
|
+
params.calibrateSoundSimulateLoudspeakerType,
|
|
942
954
|
params.isLoudspeakerCalibration
|
|
943
955
|
);
|
|
944
956
|
clearInterval(permissionCheckInterval);
|
|
@@ -126,9 +126,50 @@ class PythonServerAPI {
|
|
|
126
126
|
return res.data[task];
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
+
getImpulseResponseFromFrequencyResponse = async ({
|
|
130
|
+
frequencies,
|
|
131
|
+
gains,
|
|
132
|
+
sample_rate,
|
|
133
|
+
iir_length,
|
|
134
|
+
calibrateSoundIIRPhase,
|
|
135
|
+
totalDuration,
|
|
136
|
+
totalDuration1000Hz,
|
|
137
|
+
}) => {
|
|
138
|
+
const task = 'frequency-response-to-impulse-response';
|
|
139
|
+
let res = null;
|
|
140
|
+
|
|
141
|
+
const data = JSON.stringify({
|
|
142
|
+
task,
|
|
143
|
+
frequencies,
|
|
144
|
+
gains,
|
|
145
|
+
sample_rate,
|
|
146
|
+
iir_length,
|
|
147
|
+
calibrateSoundIIRPhase,
|
|
148
|
+
total_duration: totalDuration,
|
|
149
|
+
total_duration_1000hz: totalDuration1000Hz,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
await axios({
|
|
153
|
+
method: 'post',
|
|
154
|
+
baseURL: PythonServerAPI.PYTHON_SERVER_URL,
|
|
155
|
+
url: `/task/${task}`,
|
|
156
|
+
headers: {
|
|
157
|
+
'Content-Type': 'application/json',
|
|
158
|
+
},
|
|
159
|
+
data,
|
|
160
|
+
})
|
|
161
|
+
.then(response => {
|
|
162
|
+
res = response;
|
|
163
|
+
})
|
|
164
|
+
.catch(error => {
|
|
165
|
+
throw error;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return res.data[task];
|
|
169
|
+
};
|
|
170
|
+
|
|
129
171
|
getFrequencyResponseFromImpulseResponse = async ({
|
|
130
|
-
|
|
131
|
-
impulseResponseLoudspeaker,
|
|
172
|
+
impulseResponse,
|
|
132
173
|
sampleRate,
|
|
133
174
|
timeArray,
|
|
134
175
|
totalDuration,
|
|
@@ -139,8 +180,7 @@ class PythonServerAPI {
|
|
|
139
180
|
|
|
140
181
|
const data = JSON.stringify({
|
|
141
182
|
task,
|
|
142
|
-
|
|
143
|
-
impulse_response_loudspeaker: impulseResponseLoudspeaker,
|
|
183
|
+
impulse_response: impulseResponse,
|
|
144
184
|
sample_rate: sampleRate,
|
|
145
185
|
time_array: timeArray,
|
|
146
186
|
total_duration: totalDuration,
|
|
@@ -3323,6 +3323,10 @@ class Combination extends AudioCalibrator {
|
|
|
3323
3323
|
calibrateSoundSimulateMicrophoneTime = null,
|
|
3324
3324
|
calibrateSoundSimulateLoudspeaker = null,
|
|
3325
3325
|
calibrateSoundSimulateLoudspeakerTime = null,
|
|
3326
|
+
calibrateSoundSimulateMicrophoneFrequencies = null,
|
|
3327
|
+
calibrateSoundSimulateLoudspeakerFrequencies = null,
|
|
3328
|
+
calibrateSoundSimulateMicrophoneType = 'impulseResponse',
|
|
3329
|
+
calibrateSoundSimulateLoudspeakerType = 'impulseResponse',
|
|
3326
3330
|
isLoudspeakerCalibration = true
|
|
3327
3331
|
) => {
|
|
3328
3332
|
this._calibrateSoundBurstDownsample = calibrateSoundBurstDownsample;
|
|
@@ -3477,48 +3481,103 @@ class Combination extends AudioCalibrator {
|
|
|
3477
3481
|
}
|
|
3478
3482
|
} else {
|
|
3479
3483
|
//simulation.
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3484
|
+
if (calibrateSoundSimulateMicrophoneType === 'impulseResponse') {
|
|
3485
|
+
const frequencyResponse = await this.pyServerAPI.getFrequencyResponseFromImpulseResponse({
|
|
3486
|
+
impulseResponse: this.calibrateSoundSimulateMicrophone,
|
|
3487
|
+
sampleRate: this.sourceSamplingRate,
|
|
3488
|
+
timeArray: calibrateSoundSimulateMicrophoneTime,
|
|
3489
|
+
totalDuration: allHzDuation,
|
|
3490
|
+
totalDuration1000Hz: this.CALIBRATION_TONE_DURATION,
|
|
3491
|
+
});
|
|
3492
|
+
this.calibrateSoundSimulateMicrophone = frequencyResponse.impulse_response;
|
|
3493
|
+
this.calibrateSoundSimulateMicrophone1000Hz = frequencyResponse.impulse_response_1000hz;
|
|
3494
|
+
this.simulatedMicrophoneIR = {
|
|
3495
|
+
Freq: frequencyResponse.frequencies,
|
|
3496
|
+
Gain: frequencyResponse.gains,
|
|
3497
|
+
};
|
|
3498
|
+
if (isLoudspeakerCalibration) {
|
|
3499
|
+
this.componentIR = {
|
|
3500
|
+
Freq: frequencyResponse.frequencies,
|
|
3501
|
+
Gain: frequencyResponse.gains,
|
|
3502
|
+
};
|
|
3503
|
+
this.componentGainDBSPL = frequencyResponse.gain_at_1000hz;
|
|
3504
|
+
lCalib = this.componentGainDBSPL;
|
|
3505
|
+
}
|
|
3506
|
+
} else {
|
|
3507
|
+
const impulseResponse = await this.pyServerAPI.getImpulseResponseFromFrequencyResponse({
|
|
3508
|
+
frequencies: calibrateSoundSimulateMicrophoneFrequencies,
|
|
3509
|
+
gains: this.calibrateSoundSimulateMicrophone,
|
|
3510
|
+
sample_rate: this.sourceSamplingRate,
|
|
3511
|
+
iir_length: this.iirLength,
|
|
3512
|
+
calibrateSoundIIRPhase: this.calibrateSoundIIRPhase,
|
|
3513
|
+
totalDuration: allHzDuation,
|
|
3514
|
+
totalDuration1000Hz: this.CALIBRATION_TONE_DURATION,
|
|
3515
|
+
});
|
|
3516
|
+
if (isLoudspeakerCalibration) {
|
|
3517
|
+
this.componentIR = {
|
|
3518
|
+
Freq: impulseResponse.frequencies,
|
|
3519
|
+
Gain: impulseResponse.gains,
|
|
3520
|
+
};
|
|
3521
|
+
this.componentGainDBSPL = impulseResponse.gain_at_1000hz;
|
|
3522
|
+
lCalib = this.componentGainDBSPL;
|
|
3523
|
+
}
|
|
3524
|
+
this.simulatedMicrophoneIR = {
|
|
3525
|
+
Freq: impulseResponse.frequencies,
|
|
3526
|
+
Gain: impulseResponse.gains,
|
|
3527
|
+
};
|
|
3528
|
+
this.calibrateSoundSimulateMicrophone = impulseResponse.impulse_response;
|
|
3529
|
+
this.calibrateSoundSimulateMicrophone1000Hz = impulseResponse.impulse_response_1000hz;
|
|
3530
|
+
}
|
|
3531
|
+
|
|
3532
|
+
if (calibrateSoundSimulateLoudspeakerType === 'impulseResponse') {
|
|
3533
|
+
const frequencyResponse = await this.pyServerAPI.getFrequencyResponseFromImpulseResponse({
|
|
3534
|
+
impulseResponse: this.calibrateSoundSimulateLoudspeaker,
|
|
3535
|
+
sampleRate: this.sourceSamplingRate,
|
|
3536
|
+
timeArray: calibrateSoundSimulateLoudspeakerTime,
|
|
3537
|
+
totalDuration: allHzDuation,
|
|
3538
|
+
totalDuration1000Hz: this.CALIBRATION_TONE_DURATION,
|
|
3539
|
+
});
|
|
3540
|
+
|
|
3541
|
+
if (!isLoudspeakerCalibration) {
|
|
3542
|
+
this.componentIR = {
|
|
3543
|
+
Freq: frequencyResponse.frequencies,
|
|
3544
|
+
Gain: frequencyResponse.gains,
|
|
3545
|
+
};
|
|
3546
|
+
this.componentGainDBSPL = frequencyResponse.gain_at_1000hz;
|
|
3547
|
+
lCalib = this.componentGainDBSPL;
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
this.calibrateSoundSimulateLoudspeaker = frequencyResponse.impulse_response;
|
|
3551
|
+
this.calibrateSoundSimulateLoudspeaker1000Hz = frequencyResponse.impulse_response_1000hz;
|
|
3552
|
+
this.simulatedLoudspeakerIR = {
|
|
3553
|
+
Freq: frequencyResponse.frequencies,
|
|
3554
|
+
Gain: frequencyResponse.gains,
|
|
3510
3555
|
};
|
|
3511
|
-
console.log('this.componentIR', this.componentIR);
|
|
3512
|
-
this.componentGainDBSPL = frequencyResponse.gain_at_1000hz_microphone;
|
|
3513
|
-
lCalib = this.componentGainDBSPL;
|
|
3514
3556
|
} else {
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3557
|
+
const impulseResponse = await this.pyServerAPI.getImpulseResponseFromFrequencyResponse({
|
|
3558
|
+
frequencies: calibrateSoundSimulateLoudspeakerFrequencies,
|
|
3559
|
+
gains: this.calibrateSoundSimulateLoudspeaker,
|
|
3560
|
+
sample_rate: this.sourceSamplingRate,
|
|
3561
|
+
iir_length: this.iirLength,
|
|
3562
|
+
calibrateSoundIIRPhase: this.calibrateSoundIIRPhase,
|
|
3563
|
+
totalDuration: allHzDuation,
|
|
3564
|
+
totalDuration1000Hz: this.CALIBRATION_TONE_DURATION,
|
|
3565
|
+
});
|
|
3566
|
+
|
|
3567
|
+
this.simulatedLoudspeakerIR = {
|
|
3568
|
+
Freq: impulseResponse.frequencies,
|
|
3569
|
+
Gain: impulseResponse.gains,
|
|
3519
3570
|
};
|
|
3520
|
-
|
|
3521
|
-
|
|
3571
|
+
if (!isLoudspeakerCalibration) {
|
|
3572
|
+
this.componentIR = {
|
|
3573
|
+
Freq: impulseResponse.frequencies,
|
|
3574
|
+
Gain: impulseResponse.gains,
|
|
3575
|
+
};
|
|
3576
|
+
this.componentGainDBSPL = impulseResponse.gain_at_1000hz;
|
|
3577
|
+
lCalib = this.componentGainDBSPL;
|
|
3578
|
+
}
|
|
3579
|
+
this.calibrateSoundSimulateLoudspeaker = impulseResponse.impulse_response;
|
|
3580
|
+
this.calibrateSoundSimulateLoudspeaker1000Hz = impulseResponse.impulse_response_1000hz;
|
|
3522
3581
|
}
|
|
3523
3582
|
}
|
|
3524
3583
|
|