# AudioSampleBuffer Data

**URL:** <https://forum.juce.com/t/audiosamplebuffer-data/190>\
**Category:** General JUCE discussion\
**Created:** [March 11, 2005, 4:02pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190 "2005-03-11T16:02:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 11, 2005, 4:02pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/1 "2005-03-11T16:02:13Z")

</div>

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 😃

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 12, 2005, 12:32pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/2 "2005-03-12T12:32:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 12, 2005, 2:05pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/3 "2005-03-12T14:05:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 14, 2005, 10:28am UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/4 "2005-03-14T10:28:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 14, 2005, 5:01pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/5 "2005-03-14T17:01:51Z")

</div>

ohh… 😛

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 15, 2005, 8:11pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/6 "2005-03-15T20:11:13Z")

</div>

> [@](#):
>
> 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?

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.

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [March 15, 2005, 10:29pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/7 "2005-03-15T22:29:48Z")

</div>

ok makes sense, thanx 😃

---

<div class="post-metadata">

**Author:** ![pooz](https://avatars.discourse-cdn.com/v4/letter/p/b9e5f3/32.png) [@pooz](https://forum.juce.com/u/pooz)\
**Post date:** [December 3, 2008, 5:40pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/8 "2008-12-03T17:40:01Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [December 3, 2008, 5:44pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/9 "2008-12-03T17:44:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pooz](https://avatars.discourse-cdn.com/v4/letter/p/b9e5f3/32.png) [@pooz](https://forum.juce.com/u/pooz)\
**Post date:** [December 3, 2008, 5:48pm UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/10 "2008-12-03T17:48:23Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [December 4, 2008, 9:42am UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/11 "2008-12-04T09:42:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pooz](https://avatars.discourse-cdn.com/v4/letter/p/b9e5f3/32.png) [@pooz](https://forum.juce.com/u/pooz)\
**Post date:** [December 5, 2008, 9:24am UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/12 "2008-12-05T09:24:26Z")

</div>

> [@jules](#):
>
> The comments for the AudioBuffer constructor explain exactly how the ownership of those buffers is handled.

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 9:57am UTC](https://forum.juce.com/t/audiosamplebuffer-data/190/13 "2017-05-12T09:57:10Z")

</div>

Closed on May 12, 2017, 9:57am UTC


