91 if (! approximatelyEqual (lastRatio, localRatio))
93 createLowPass (localRatio);
94 lastRatio = localRatio;
97 const int sampsNeeded = roundToInt (info.
numSamples * localRatio) + 3;
101 if (bufferSize < sampsNeeded + 8)
103 bufferPos %= bufferSize;
104 bufferSize = sampsNeeded + 32;
108 bufferPos %= bufferSize;
110 int endOfBufferPos = bufferPos + sampsInBuffer;
113 while (sampsNeeded > sampsInBuffer)
115 endOfBufferPos %= bufferSize;
117 int numToDo = jmin (sampsNeeded - sampsInBuffer,
118 bufferSize - endOfBufferPos);
121 input->getNextAudioBlock (readInfo);
123 if (localRatio > 1.0001)
127 for (
int i = channelsToProcess; --i >= 0;)
128 applyFilter (buffer.
getWritePointer (i, endOfBufferPos), numToDo, filterStates[i]);
131 sampsInBuffer += numToDo;
132 endOfBufferPos += numToDo;
135 for (
int channel = 0; channel < channelsToProcess; ++channel)
141 int nextPos = (bufferPos + 1) % bufferSize;
145 jassert (sampsInBuffer > 0 && nextPos != endOfBufferPos);
147 const float alpha = (float) subSampleOffset;
149 for (
int channel = 0; channel < channelsToProcess; ++channel)
150 *destBuffers[channel]++ = srcBuffers[channel][bufferPos]
151 + alpha * (srcBuffers[channel][nextPos] - srcBuffers[channel][bufferPos]);
153 subSampleOffset += localRatio;
155 while (subSampleOffset >= 1.0)
157 if (++bufferPos >= bufferSize)
162 nextPos = (bufferPos + 1) % bufferSize;
163 subSampleOffset -= 1.0;
167 if (localRatio < 0.9999)
170 for (
int i = channelsToProcess; --i >= 0;)
173 else if (localRatio <= 1.0001 && info.numSamples > 0)
176 for (
int i = channelsToProcess; --i >= 0;)
179 FilterState& fs = filterStates[i];
183 fs.y2 = fs.x2 = *(endOfBuffer - 1);
191 fs.y1 = fs.x1 = *endOfBuffer;
195 jassert (sampsInBuffer >= 0);