# Create sample size limit

**URL:** <https://qa.fmod.com/t/create-sample-size-limit/12820>\
**Category:** FMOD Engine\
**Created:** [November 17, 2016, 10:41pm UTC](https://qa.fmod.com/t/create-sample-size-limit/12820 "2016-11-17T22:41:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave1](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dave1](https://qa.fmod.com/u/dave1)\
**Post date:** [November 17, 2016, 10:41pm UTC](https://qa.fmod.com/t/create-sample-size-limit/12820/1 "2016-11-17T22:41:49Z")

</div>

Hello,

I think I’ve hit up against a sample length limit of CreateSample…

Somewhere between 20,274,048 samples and 21,170,304 samples, absolute positioning seems to go out: the start of the track seems to get truncated (2 channels, standard amazon mp3s).

For this particular task I do need the whole track in memory, I use a stream on other occasions.

Wondering if I’m missing an option to increase this? Is this intentional? I can manually populate an array for the time being, was curious about any limit.

Many thanks in advance

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [November 18, 2016, 12:53am UTC](https://qa.fmod.com/t/create-sample-size-limit/12820/2 "2016-11-18T00:53:24Z")

</div>

> [@](#):
>
> Hello,
> 
> I think I’ve hit up against a sample length limit of CreateSample…
> 
> Somewhere between 20,274,048 samples and 21,170,304 samples, absolute positioning seems to go out: the start of the track seems to get truncated (2 channels, standard amazon mp3s).
> 
> For this particular task I do need the whole track in memory, I use a stream on other occasions.
> 
> Wondering if I’m missing an option to increase this? Is this intentional? I can manually populate an array for the time being, was curious about any limit.
> 
> Many thanks in advance

do you have an example file that you’re talking about? 20 million samples is only like 7 minutes or something. I don’t know what you mean by the ‘absolute position seems to go out’. Are you talking about an issue with setPosition, or you’re just losing the start of large mp3s?

---

<div class="post-metadata">

**Author:** ![dave1](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dave1](https://qa.fmod.com/u/dave1)\
**Post date:** [November 18, 2016, 11:04am UTC](https://qa.fmod.com/t/create-sample-size-limit/12820/3 "2016-11-18T11:04:01Z")

</div>

Hi Brett, many thanks.

Track is: Control (feat. Joe Le Groove), Defected In the House Ibiza 2016.

Given:

result = system-\>createSound(pPath, FMOD\_DEFAULT | FMOD\_CREATESAMPLE, nullptr, &sound);

unsigned int uBytePosition = 0;  
unsigned int uByteCount = 1024 \* 2 \* 2;

result = sound-\>lock(uBytePosition, uByteCount, reinterpret\_cast\<void\*\*\>(&pByteData), nullptr, &read, nullptr);

With tracks larger than a certain size the data returned for uBytePosition -\> uBytePosition + uByteCount is not accurate. Seems the start is truncated, not the end, so the data returned is ‘further along’ than it should be.

Is that useful?

FTR, I’ve switched in a manually populated byte array (using a stream) and the data is correct. (It does take considerably longer though!)

Let me know is you need any more info.

Thanks again,

---

<div class="post-metadata">

**Author:** ![dave1](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dave1](https://qa.fmod.com/u/dave1)\
**Post date:** [November 18, 2016, 12:03pm UTC](https://qa.fmod.com/t/create-sample-size-limit/12820/4 "2016-11-18T12:03:28Z")

</div>

Hi Brett,

Done some more testing. Seems I need the AccurateTime flag on CreateSample. It only seems necessary on the larger files as this hasn’t come up before? Mayby I just got lucky…

With that flag all seems ok. Many thanks.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [November 20, 2016, 11:15pm UTC](https://qa.fmod.com/t/create-sample-size-limit/12820/5 "2016-11-20T23:15:06Z")

</div>

FMOD\_ACCURATETIME is used with VBR sounds. As it doesn’t know the length in PCM at the start, if you load it as a sample (and not a stream), it is going to only allocate memory for what it assumes is the size (based on the first few frames) and more likely would cut the end of the sound off.  
Also seeking would not be accurate if it was a stream, so FMOD\_ACCURATETIME scans the file and makes a seek table for accurate seek positioning with a VBR file.  
If it is decompressed into memory then seeking is just like seeking in PCM, and is not affected.
