manual gain calculations attempt 1
This commit is contained in:
parent
c76027bb84
commit
e35e5ae2fe
|
@ -38,7 +38,7 @@ export class AudioManager {
|
|||
panner.maxDistance = 2500;
|
||||
const gain = this.ac.createGain();
|
||||
const dest = this.ac.createMediaStreamDestination();
|
||||
gain.connect(panner).connect(dest);
|
||||
gain.connect(dest); //.connect(panner)
|
||||
|
||||
let audio = document.createElement("audio");
|
||||
audio.srcObject = dest.stream;
|
||||
|
@ -76,10 +76,13 @@ export class PlayerAudio {
|
|||
});
|
||||
|
||||
this.playerWatcher.subscribe(([[x, y, z], sameStage]) => {
|
||||
this.panner.positionX.value = x;
|
||||
this.panner.positionY.value = y;
|
||||
this.panner.positionZ.value = z;
|
||||
this.gain.gain.value = +sameStage;
|
||||
// this.panner.positionX.value = x;
|
||||
// this.panner.positionY.value = y;
|
||||
// this.panner.positionZ.value = z;
|
||||
let magnitude = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
|
||||
const max = 2500, min = 1500;
|
||||
let scaledGain = 1 - (magnitude - min) / max;
|
||||
this.gain.gain.value = scaledGain * +sameStage;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue