add detect if source is self

This commit is contained in:
Philip Rosedale 2014-09-16 01:30:25 -07:00
parent 62b21f52af
commit 1514b58700

View file

@ -144,6 +144,8 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream*
bool shouldDistanceAttenuate = true;
bool sourceIsSelf = (streamToAdd == listeningNodeStream);
// if the two stream pointers do not match then these are different streams
glm::vec3 relativePosition = streamToAdd->getPosition() - listeningNodeStream->getPosition();
@ -176,7 +178,7 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream*
glm::quat inverseOrientation = glm::inverse(listeningNodeStream->getOrientation());
if (streamToAdd->getType() != PositionalAudioStream::Injector) {
if (!sourceIsSelf && (streamToAdd->getType() != PositionalAudioStream::Injector)) {
// source is another avatar, apply fixed off-axis attenuation to make them quieter as they turn away from listener
glm::vec3 rotatedListenerPosition = glm::inverse(streamToAdd->getOrientation()) * relativePosition;
@ -212,6 +214,7 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream*
if (showDebug) qDebug() << "distanceCoefficient: " << distanceCoefficient;
}
if (!sourceIsSelf) {
// Compute sample delay for the two ears to create phase panning
glm::vec3 rotatedSourcePosition = inverseOrientation * relativePosition;
@ -236,6 +239,7 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream*
numSamplesDelay *= distanceBetween / RADIUS_OF_HEAD;
weakChannelAmplitudeRatio += (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio) * distanceBetween / RADIUS_OF_HEAD;
}
}
if (showDebug) {
qDebug() << "attenuation: " << attenuationCoefficient;
@ -300,7 +304,7 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(PositionalAudioStream*
}
}
if (_enableFilter) {
if (!sourceIsSelf && _enableFilter) {
const float TWO_OVER_PI = 2.0f / PI;