Add Shift+C microphone input calibration

This commit is contained in:
Jage9
2026-02-22 16:16:16 -05:00
parent e4b0955f50
commit 9707a57169
4 changed files with 131 additions and 2 deletions

View File

@@ -37,6 +37,7 @@ export class AudioEngine {
private outboundSource: MediaStreamAudioSourceNode | null = null;
private outboundInputGain: GainNode | null = null;
private outboundInputGainValue = 1;
private outboundDestination: MediaStreamAudioDestinationNode | null = null;
private outboundEffectRuntime: EffectRuntime | null = null;
private loopbackEnabled = false;
@@ -97,6 +98,7 @@ export class AudioEngine {
if (!this.outboundInputGain) {
this.outboundInputGain = this.audioCtx.createGain();
}
this.outboundInputGain.gain.value = this.outboundInputGainValue;
if (!this.outboundDestination) {
this.outboundDestination = this.audioCtx.createMediaStreamDestination();
}
@@ -183,6 +185,19 @@ export class AudioEngine {
return this.voiceLayerEnabled;
}
setOutboundInputGain(value: number): number {
const next = Math.max(0.01, Number.isFinite(value) ? value : 1);
this.outboundInputGainValue = next;
if (this.outboundInputGain && this.audioCtx) {
this.outboundInputGain.gain.setValueAtTime(next, this.audioCtx.currentTime);
}
return next;
}
getOutboundInputGain(): number {
return this.outboundInputGainValue;
}
toggleLoopback(): boolean {
this.loopbackEnabled = !this.loopbackEnabled;
this.rebuildOutboundEffectGraph();