From ba2b79b0785deba77fb48aa88061caee38574f7c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 26 Feb 2013 17:12:41 -0800 Subject: [PATCH] accentuate the distance dampening by squaring the coefficient --- mixer/src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mixer/src/main.cpp b/mixer/src/main.cpp index e008a4709f..85313b6a6e 100644 --- a/mixer/src/main.cpp +++ b/mixer/src/main.cpp @@ -76,13 +76,15 @@ void *sendBuffer(void *args) float *agentPosition = ((AudioRingBuffer *)agent->getLinkedData())->getPosition(); float *otherAgentPosition = otherAgentBuffer->getPosition(); + float distanceToAgent = sqrtf(powf(agentPosition[0] - otherAgentPosition[0], 2) + powf(agentPosition[1] - otherAgentPosition[1], 2) + powf(agentPosition[2] - otherAgentPosition[2], 2)); - float distanceCoeff = 1 / (log(DISTANCE_RATIO * distanceToAgent) / log(3)); + + float distanceCoeff = powf((logf(DISTANCE_RATIO * distanceToAgent) / logf(3)), 2); for (int s = 0; s < BUFFER_LENGTH_SAMPLES; s++) { - int16_t sample = (otherAgentBuffer->getNextOutput()[s] * distanceCoeff); + int16_t sample = (otherAgentBuffer->getNextOutput()[s] / distanceCoeff); clientMix[s] += sample; } }