I noticed that the magnitude of the signal is increased in the oversampled buffer.
is that a bug or am I missing something?
here attached is a PIP plugin with the following process code that asserts when checking that the magnitude in the oversampled block is <= 1
OversamplingTest.h (6,2 Ko)
TestProcessor()
: AudioProcessor (BusesProperties().withInput ("Input", AudioChannelSet::stereo())
.withOutput ("Output", AudioChannelSet::stereo()))
{
oversampling = new dsp::Oversampling<float> (2, 1,
dsp::Oversampling<float>::filterHalfBandFIREquiripple,
true);
}
//==============================================================================
void prepareToPlay (double, int samplesPerBlock) override
{
oversampling->initProcessing ((size_t) samplesPerBlock);
oversampling->reset();
}
void processBlock (AudioBuffer<float>& buffer, MidiBuffer&) override
{
int numChannels = buffer.getNumChannels();
int numSamples = buffer.getNumSamples();
// overwrite the buffer with noise
for (int i = 0; i < numChannels; ++i)
{
auto* buf = buffer.getWritePointer (i);
for (int j = 0; j < numSamples; ++j)
buf[j] = random.nextFloat() * 2.f - 1.f;
}
// check the magnitude in our buffer
{
auto r = FloatVectorOperations::findMinAndMax (buffer.getReadPointer (0),
(int) buffer.getNumSamples());
auto magnitude = jmax (r.getStart(), -r.getStart(), r.getEnd(), -r.getEnd());
jassert (magnitude <= 1.f);
}
// Upsampling
dsp::AudioBlock<float> block (buffer);
dsp::AudioBlock<float> oversampledBlock = oversampling->processSamplesUp (block);
// check the magnitude in the oversampled block
{
auto r = FloatVectorOperations::findMinAndMax (oversampledBlock.getChannelPointer (0),
(int) oversampledBlock.getNumSamples());
auto magnitude = jmax (r.getStart(), -r.getStart(), r.getEnd(), -r.getEnd());
jassert (magnitude <= 1.f); // ASSERTS !
}
// Downsampling
oversampling->processSamplesDown (block);
// clear buffer
buffer.clear();
}
