mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 12:10:44 +02:00
add detect if source is self
This commit is contained in:
parent
62b21f52af
commit
1514b58700
1 changed files with 28 additions and 24 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue