AudioSampleBuffer Data

does an audiosamplebuffer object contain wave data or just a reference to it? if it’s only a reference is it up to you to delete the original data once the audiosamplebuffer object is deleted, or is there a way to have it do this automatically? what about when you use the AudioSampleBuffer(const int numChannels, const int numSamples) constructor, where is the data stored then?

thanks in advance :smiley:

It can do both… the comments on the constructors explain all this, don’t they?

kind of… it says that memory that is allocated will be deleted automatically but it will not delete any memory that isn’t allocated. is there a way to tell it to automatically delete data that is passed in through the constructor? what happens if you call delete, does it clear the referenced memory?

I’m sure it doesn’t say anything as confusing as that!

It’s very simple - any memory it allocates internally is taken care of and you don’t need to worry about it. Or if you pass your own pointer in there, it’ll leave it alone.

ohh… :stuck_out_tongue:

so if you pass the data in it refers to that data (for applying gain, volume ramps, ect…) and you have to delete it yourself… correct?

thanx again for the help and the great library! (and great sequencer :smiley: )

yes - but obviously there’s no point in actually allocating the memory yourself - you might as well just let the object handle it. The main reason it lets you wrap up an external array is for handling arrays you have no control over, like the ones that get passed into native audio driver callbacks, etc.

ok makes sense, thanx :smiley:


  1. I would like to know, what happens, if I delete my Pointer to which AudioSampleBuffer refers to?

  2. I want to get my Data from my “own” Buffer (it´s an Array of Pointers like float** ppMyData) to an AudioSampleBuffer from AudioSource.

(I still do copyFrom, but I guess referTo should be better? What do you recommendend?)

for (int i = 0; i < m_iRNumOfChannels; i++) info.buffer->copyFrom (i, 0, m_apfProcessOutputData[i], _OUTPUT_BUFFER_SIZE)

The comments for the AudioBuffer constructor explain exactly how the ownership of those buffers is handled.

Yes, but only the handling when its amount of channels or its sizes changes. But not how AudioSampleBuffer reacts, when the pointer will be deleted after some usage. Do I miss something? I sill use the online Doc. (I didnt get the SVN-Thing)

Sorry, I thought that’s what you were asking about?

If you give it some of your own data to refer to, then surely it’s just common sense that you shouldn’t delete that memory while it’s still using it (??)

In the latest SVN your additional note explains this very well. I was using the v1.46 Online-Doc before.