Hi everybody… I’m Marcello and I want you to forgive me for my english
So, here is the problem:
I want to play audio from an AudioSampleBuffer, so I decided to write a MyAudioSource that inherits from PositionableAudioSource.
this is the code:
int MyAudioSource::getTotalLength() const
{
return (int) reader->getNumSamples();
}
void MyAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info)
{
long lung=info.numSamples;
if ((start+info.numSamples)>reader->getNumSamples())
{
lung=reader->getNumSamples()-start;
info.buffer->clear(info.startSample+lung,info.numSamples);
}
for (int i=0; i<reader->getNumChannels(); i++)
info.buffer->copyFrom(i,info.startSample,*reader,i,start,lung);
nextPlayPos += info.numSamples;
}
(reader is the audiosamplebuffer)
Yes, it play, but it always crash at the end of the playback.
If i try
int MyAudioSource::getTotalLength() const
{
return (int) reader->getNumSamples()-40000; //just to test
}
it play a few samples of the buffer, but with no problems.
What I miss or where i’m wrong???
And… there’s a finest way to play audio from an AudioBufferSource?
Thanks