Reputation: 614
I'm creating an array of sounds with PositionalAudio:
var newVoice = new THREE.PositionalAudio(listener);
newVoice.setBuffer(buffer);
newVoice.setRefDistance(20);
newVoice.autoplay = true;
newVoice.setLoop(true);
voices.push(newVoice);
And I've attached these voices to cubes, but I want to only allow the user to hear the sound if they are facing the cube from an angle straight on of 30degress. Anything outside of a 30degree cone should be silent.
I see the documentation here but the only parameter that is working is the one i used 'setRefDistance.' The others do not work. I'm using r74.
Any ideas? The gist is here: https://gist.github.com/evejweinberg/949e297c34177199386f945549a45c06
Upvotes: 5
Views: 1103
Reputation: 4494
Three.js Audio is a wrapper for the web audio API. You can apply all the settings to the panner, which is availiable using getOutput()
:
var sound = new THREE.PositionalAudio( listener );
var panner = sound.getOutput();
panner.coneInnerAngle = innerAngleInDegrees;
panner.coneOuterAngle = outerAngleInDegrees;
panner.coneOuterGain = outerGainFactor;
coneInnerAngle: A parameter for directional audio sources, this is an angle, inside of which there will be no volume reduction. The default value is 360.
coneOuterAngle: A parameter for directional audio sources, this is an angle, outside of which the volume will be reduced to a constant value of coneOuterGain. The default value is 360.
coneOuterGain: A parameter for directional audio sources, this is the amount of volume reduction outside of the coneOuterAngle. The default value is 0.
Sources:
Upvotes: 3