AudioSampleBuffer Data


#1

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:


#2

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


#3

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?


#4

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.


#5

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: )


#6

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.


#7

ok makes sense, thanx :smiley:


#8

Hi,

  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)
Thx!


#9

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


#10

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)


#11

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 (??)


#12

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


#13