From 948f9607f631d27c17198de4bbbd15438ff6ce76 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Apr 2013 11:49:52 -0700 Subject: [PATCH 1/6] send head position as source position to mixer --- interface/src/Audio.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index f90027d25a..df1e547d31 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -151,10 +151,8 @@ int audioCallback (const void *inputBuffer, unsigned char *currentPacketPtr = dataPacket + 1; // memcpy the three float positions - for (int p = 0; p < 3; p++) { - memcpy(currentPacketPtr, &data->linkedAvatar->getPosition()[p], sizeof(float)); - currentPacketPtr += sizeof(float); - } + memcpy(currentPacketPtr, &data->linkedAvatar->getHeadPosition(), sizeof(float) * 3); + currentPacketPtr += (sizeof(float) * 3); // tell the mixer not to add additional attenuation to our source *(currentPacketPtr++) = 255; From 57c39ceb9908e622cc574d34c1a785f9eae09c26 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Apr 2013 11:53:07 -0700 Subject: [PATCH 2/6] add some debugging to audio mixer for distance attenuation --- audio-mixer/src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio-mixer/src/main.cpp b/audio-mixer/src/main.cpp index 9cb977dc1c..bc9de27844 100644 --- a/audio-mixer/src/main.cpp +++ b/audio-mixer/src/main.cpp @@ -127,7 +127,7 @@ void *sendBuffer(void *args) for (AgentList::iterator otherAgent = agentList->begin(); otherAgent != agentList->end(); otherAgent++) { - if (otherAgent != agent || ( otherAgent == agent && agentWantsLoopback)) { + if (otherAgent != agent || (otherAgent == agent && agentWantsLoopback)) { AudioRingBuffer* otherAgentBuffer = (AudioRingBuffer*) otherAgent->getLinkedData(); float *agentPosition = agentRingBuffer->getPosition(); @@ -146,6 +146,7 @@ void *sendBuffer(void *args) float minCoefficient = std::min(1.0f, powf(0.5, (logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1)); + printf("The DC between agent %d and %d is %f\n", agent->getAgentId(), otherAgent->getAgentId(), minCoefficient); distanceCoeffs[lowAgentIndex][highAgentIndex] = minCoefficient; } From e2cb1866ed0073bac8ad2fc3b859da3d8d82fde2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Apr 2013 11:59:26 -0700 Subject: [PATCH 3/6] add another line of debugging for audio mixer distance coeff --- audio-mixer/src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/audio-mixer/src/main.cpp b/audio-mixer/src/main.cpp index bc9de27844..9dd7b29008 100644 --- a/audio-mixer/src/main.cpp +++ b/audio-mixer/src/main.cpp @@ -146,6 +146,7 @@ void *sendBuffer(void *args) float minCoefficient = std::min(1.0f, powf(0.5, (logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1)); + printf("The distance between the two agents is %d\n", distanceToAgent); printf("The DC between agent %d and %d is %f\n", agent->getAgentId(), otherAgent->getAgentId(), minCoefficient); distanceCoeffs[lowAgentIndex][highAgentIndex] = minCoefficient; } From 7744685de4117a4f477473844e34e836ce4304e5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Apr 2013 12:01:47 -0700 Subject: [PATCH 4/6] debug of distance should be float and not integer --- audio-mixer/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio-mixer/src/main.cpp b/audio-mixer/src/main.cpp index 9dd7b29008..8909475ab3 100644 --- a/audio-mixer/src/main.cpp +++ b/audio-mixer/src/main.cpp @@ -146,7 +146,7 @@ void *sendBuffer(void *args) float minCoefficient = std::min(1.0f, powf(0.5, (logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1)); - printf("The distance between the two agents is %d\n", distanceToAgent); + printf("The distance between the two agents is %f\n", distanceToAgent); printf("The DC between agent %d and %d is %f\n", agent->getAgentId(), otherAgent->getAgentId(), minCoefficient); distanceCoeffs[lowAgentIndex][highAgentIndex] = minCoefficient; } From 5442362b3aa39109d8b2d3417763640a34e23a94 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Apr 2013 17:01:54 -0700 Subject: [PATCH 5/6] change DISTANCE_RATIO const in audio-mixer main --- audio-mixer/src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/audio-mixer/src/main.cpp b/audio-mixer/src/main.cpp index 8909475ab3..a561cbe2bd 100644 --- a/audio-mixer/src/main.cpp +++ b/audio-mixer/src/main.cpp @@ -52,11 +52,10 @@ const float BUFFER_SEND_INTERVAL_USECS = (BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SA const long MAX_SAMPLE_VALUE = std::numeric_limits::max(); const long MIN_SAMPLE_VALUE = std::numeric_limits::min(); -const float DISTANCE_RATIO = 3.0/4.2; +const float DISTANCE_RATIO = 3.0f / 0.3f; const float PHASE_AMPLITUDE_RATIO_AT_90 = 0.5; const int PHASE_DELAY_AT_90 = 20; - const int AGENT_LOOPBACK_MODIFIER = 307; const int LOOPBACK_SANITY_CHECK = 0; From 14012ee44bdf4255b6652ecf19c03d682d22035a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Apr 2013 17:11:51 -0700 Subject: [PATCH 6/6] remove the debugging to confirm that distance attenuation is working --- audio-mixer/src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/audio-mixer/src/main.cpp b/audio-mixer/src/main.cpp index a561cbe2bd..a7c34b8a36 100644 --- a/audio-mixer/src/main.cpp +++ b/audio-mixer/src/main.cpp @@ -145,8 +145,6 @@ void *sendBuffer(void *args) float minCoefficient = std::min(1.0f, powf(0.5, (logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1)); - printf("The distance between the two agents is %f\n", distanceToAgent); - printf("The DC between agent %d and %d is %f\n", agent->getAgentId(), otherAgent->getAgentId(), minCoefficient); distanceCoeffs[lowAgentIndex][highAgentIndex] = minCoefficient; }