Delay turning mic off to compensate for WebAudio latency (fixes #72)
This commit is contained in:
parent
cb0e091c30
commit
5f9cca9289
1 changed files with 14 additions and 3 deletions
|
@ -719,9 +719,20 @@ export const setMicVolume = (
|
|||
): AppThunk => dispatch => {
|
||||
// no tween fuckery here, just cut the level
|
||||
const levelVal = level === "full" ? 1 : 0;
|
||||
dispatch(
|
||||
mixerState.actions.setMicLevels({ volume: levelVal, gain: levelVal })
|
||||
);
|
||||
// actually, that's a lie - if we're turning it off we delay it a little to compensate for
|
||||
// processing latency
|
||||
if (levelVal !== 0) {
|
||||
dispatch(
|
||||
mixerState.actions.setMicLevels({ volume: levelVal, gain: levelVal })
|
||||
);
|
||||
} else {
|
||||
window.setTimeout(() => {
|
||||
dispatch(
|
||||
mixerState.actions.setMicLevels({ volume: levelVal, gain: levelVal })
|
||||
);
|
||||
// latency, plus a little buffer
|
||||
}, audioContext.baseLatency * 1000 + 150);
|
||||
}
|
||||
};
|
||||
|
||||
let analyser: AnalyserNode | null = null;
|
||||
|
|
Loading…
Reference in a new issue