From 58ba3038f0f88e7724f22d43806ac2fa548ec4f7 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Sun, 4 Mar 2012 12:55:00 -0500 Subject: [PATCH] Any sample rate seems to work, as long as tempBuffer is large enough --- Source/Audio/AudioComponent.cpp | 2 +- Source/Processors/ResamplingNode.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Audio/AudioComponent.cpp b/Source/Audio/AudioComponent.cpp index bd28c5c6f..93119a912 100644 --- a/Source/Audio/AudioComponent.cpp +++ b/Source/Audio/AudioComponent.cpp @@ -47,7 +47,7 @@ AudioComponent::AudioComponent() : isPlaying(false) AudioDeviceManager::AudioDeviceSetup setup; deviceManager.getAudioDeviceSetup(setup); - setup.bufferSize = 128; /// larger buffer = fewer empty blocks, but longer latencies + setup.bufferSize = 1024; /// larger buffer = fewer empty blocks, but longer latencies setup.useDefaultInputChannels = false; setup.inputChannels = 0; setup.useDefaultOutputChannels = true; diff --git a/Source/Processors/ResamplingNode.cpp b/Source/Processors/ResamplingNode.cpp index a77f70e5f..1c17cdd5c 100644 --- a/Source/Processors/ResamplingNode.cpp +++ b/Source/Processors/ResamplingNode.cpp @@ -134,7 +134,7 @@ void ResamplingNode::prepareToPlay (double sampleRate_, int estimatedSamplesPerB if (destBufferIsTempBuffer) { destBufferSampleRate = sampleRate_; - tempBuffer->setSize(getNumInputs(), 2048); + tempBuffer->setSize(getNumInputs(), 4096); } else { destBufferSampleRate = float(destBufferWidth) / destBufferTimebaseSecs; @@ -189,7 +189,7 @@ void ResamplingNode::process(AudioSampleBuffer &buffer, if (destBufferIsTempBuffer) { ratio = float(nSamps) / float(buffer.getNumSamples()); - valuesNeeded = tempBuffer->getNumSamples(); + valuesNeeded = buffer.getNumSamples(); } else { ratio = sourceBufferSampleRate / destBufferSampleRate; valuesNeeded = (int) buffer.getNumSamples() / ratio; @@ -278,7 +278,10 @@ void ResamplingNode::process(AudioSampleBuffer &buffer, if (destBufferIsTempBuffer) { // copy the temp buffer into the original buffer + + buffer = *tempBuffer; + //buffer = AudioSampleBuffer(tempBuffer->getArrayOfChannels(), 2, buffer.getNumSamples()); //buffer.setSize(2,0,true,false,true); -- GitLab