Playing audio files in a Plugin


Hello folks!

I’m trying to make a wav player plugin.
In order to achieve this, I :

created an audioFormatReader and gave it the wave file;
created an audioSampleBuffer;
resized it to fit the file’s length;
called the readFromAudioReader function
and gave it the reader.

Now, in the processBlock function, I need to copy the samples from the wave buffer into the function’s buffer.
I tried with copyFrom, iterations, nothing!

Can anybody help me?
I’m not so good with dsp stuff!


use getSampleData and just copy it?


Yeah, that’s the point.
I need to deal with the processBlock buffer’s size and the wavefile’s size.

I have to write a iteration such as:

int blockSize = buffer.getSampleData(0);

while (–blockSize >=0)
copy N samples from wavefile into buffer;
when the last of N samples is reached,
get the next N samples;
repeat until the end of wavefile.

where N samples is equal to blockSize.

I think you made something like this in your SamplerVoice::renderNextBlock, Jules.


Unless you’ve got a very good reason to write your own algorithm, I’d really recommend just using the Sampler class to do all this for you…


Ok, I’ve done it using the audioFormatReader - audioTransportSource way.
I was trying to recreate your classes!!!

Thank you !