So far I am doing like this : std::vector<float*> oversampleArray;
yes, there are several problems with your code ;-)
First you have to undestand the difference of float and float*. You create a vector of pointers to floats, which doesn't help you much, because the pointers don't point to allocated memory (see Timurs post about that...).
Also you should understand the difference of stack memory vs. heap memory. If you write
float* x = new float();
you have a pointer to one single float value, which is probably not what you wanted. Also if you use new, you need a corresponding delete, otherwise your code is leaking memory (i.e. allocating memory and not freeing will consume the resources until it stops working).
A good read for that is Jules' Coding Standards: http://www.juce.com/learn/coding-standards and see object lifetime and ownership.
I would strongly suggest to use a second AudioBuffer in your AudioProcessor class.
The benefit is, that the AudioBuffer owns the memory block and if the AudioProcessor is deallocated, the memory is freed automatically...
You can see a good example in the plugin demo code:
And see the delayBuffer there (forget for the moment the template for float and double...)
So you can call in prepareToPlay the setSize method:
class MyProcessor : public AudioProcessor
void prepareToPlay prepareToPlay (double sampleRate, int estimatedSamplesPerBlock)
resampledBuffer.setSize (getTotalNumInputChannels(), estimatedSamplesPerBlock * oversampling);
void processBlock (AudioBuffer< float > &buffer, MidiBuffer &midiMessages)
for (int i=0; i<buffer.getNumChannels(); ++i)
const float* reader = buffer.getReadPointer (i);
float* writer = resampledBuffer.getWritePointer (i);
for (int x=0; x<buffer.getNumSamples()-1; ++x) // note -1 otherwise you go out of bounds...
writer[x*oversampling] = reader[x];
writer[x*oversampling+1] = (reader[x] + reader[x+1]) * 0.5;
// do something usefull at the end, as last sample is unknown
This is untested code, but something alike I used in a previous project...
I hope you get the idea...
Good luck, Daniel