From 0c057139551ca1ea9cd7c727c61458d5af039ed4 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 1 Mar 2013 15:47:55 -0800 Subject: [PATCH] the proper test of fred's low pass algorithm --- mixer/src/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mixer/src/main.cpp b/mixer/src/main.cpp index 185eb0305b..7f393ece43 100644 --- a/mixer/src/main.cpp +++ b/mixer/src/main.cpp @@ -142,7 +142,7 @@ void *sendBuffer(void *args) ? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay : otherAgentBuffer->getNextOutput() - numSamplesDelay; - int16_t *lowPassFrame = new int16_t[(BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2) / 4]; + // calculate the low-pass filter intensity float lowPassIntensity = ((agentBearing - otherAgentBuffer->getBearing()) * BEARING_LOW_PASS_FACTOR) + (fabsf(angleToSource) * ANGLE_TO_SOURCE_LOW_PASS_FACTOR); @@ -162,7 +162,11 @@ void *sendBuffer(void *args) if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) { delayedChannel[s + numSamplesDelay] = currentSample; } - + } + + int16_t lowPassFrame[(BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2) / 4]; + + for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) { if ((s + 1) % 4 == 0) { int sampleIndex = ((s + 1) / 4) - 1; // this will be a sample in the lowPassFrame @@ -171,6 +175,7 @@ void *sendBuffer(void *args) } clientMix[s] = lowPassFrame[s / 4]; + clientMix[s + BUFFER_LENGTH_SAMPLES_PER_CHANNEL] = lowPassFrame[(s + BUFFER_LENGTH_SAMPLES_PER_CHANNEL) / 4]; } } }