# Difference between samples per block and buffer size

**URL:** <https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164>\
**Category:** Audio Plugins\
**Created:** [August 27, 2018, 10:01pm UTC](https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164 "2018-08-27T22:01:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bk81](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@bk81](https://forum.juce.com/u/bk81)\
**Post date:** [August 27, 2018, 10:01pm UTC](https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164/1 "2018-08-27T22:01:45Z")

</div>

What is the difference between the samples per block value in the prepareToPlay function and the size of the buffer that is passed to the processBlock function?. I thought both where the same but on Fl Studio I get different values and I’m getting insane cpu values because of this.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 27, 2018, 10:04pm UTC](https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164/2 "2018-08-27T22:04:02Z")

</div>

The one in prepareToPlay is an upper limit, so you can allocate enough space. Always work with the actual one in processBlock…

---

<div class="post-metadata">

**Author:** ![bk81](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@bk81](https://forum.juce.com/u/bk81)\
**Post date:** [August 27, 2018, 10:47pm UTC](https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164/3 "2018-08-27T22:47:02Z")

</div>

Thanks! for the response! But I was debugging and I also discovered another issue, Fl Studio uses multiple block sizes that spike the cpu use.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 27, 2018, 11:13pm UTC](https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164/4 "2018-08-27T23:13:30Z")

</div>

To measure CPU usage, you should a) use a release build and b) use a profiler, not the overall meter… it is a rough number for a start, but to actually trim your code, there is no way around the profiler and measuring the release build (XCode Instruments e.g.)

Sorry if I got you wrong, but since you said debugging, I was assuming you are looking at a debug build…

---

<div class="post-metadata">

**Author:** ![bk81](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@bk81](https://forum.juce.com/u/bk81)\
**Post date:** [August 28, 2018, 11:29pm UTC](https://forum.juce.com/t/difference-between-samples-per-block-and-buffer-size/29164/5 "2018-08-28T23:29:47Z")

</div>

Thank you, and yes I was using a debug build! I’ll try that
