# Getting length of Programming Sounds in Unreal Engine (from the Audio Table)

**URL:** <https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811>\
**Category:** Unreal Engine\
**Created:** [December 15, 2025, 11:12am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811 "2025-12-15T11:12:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FSapio](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@FSapio](https://qa.fmod.com/u/FSapio)\
**Post date:** [December 15, 2025, 11:12am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/1 "2025-12-15T11:12:30Z")

</div>

Hi, sorry for the duplicate in the topic, but I didn’t find any solution that works so far, and a little bit of help would be very much appreciated. I made the following 5 tries.

1. I tried to use call-backs, like the code below, but they never get called:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/ec23bc52037d942386283e3ebd4befc5e1bc9970.png)

_Since I cannot insert multiple images in the post, I will continue in the replies down below._

---

<div class="post-metadata">

**Author:** ![FSapio](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@FSapio](https://qa.fmod.com/u/FSapio)\
**Post date:** [December 15, 2025, 11:13am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/2 "2025-12-15T11:13:04Z")

</div>

1. I tried modify the AudioComponent to get directly the value of the sound, but it is not ready yet with error 46:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f04ac25cbb5241be45798c7f495f0fad8d28e2ef.png)

---

<div class="post-metadata">

**Author:** ![FSapio](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@FSapio](https://qa.fmod.com/u/FSapio)\
**Post date:** [December 15, 2025, 11:13am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/3 "2025-12-15T11:13:35Z")

</div>

1. So, I tried to save the variable MyCustomSound, and try to access it later, but I get error 31:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/edf0583ca158260ac2a8a4bf2c0e22ec8bf22033.png)

---

<div class="post-metadata">

**Author:** ![FSapio](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@FSapio](https://qa.fmod.com/u/FSapio)\
**Post date:** [December 15, 2025, 11:14am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/4 "2025-12-15T11:14:07Z")

</div>

1. I tried to save the length in this way, but I get always the same number “8582624”:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/a/afec40997089bca9e6fc956a87916e5027d32ace.png)

---

<div class="post-metadata">

**Author:** ![FSapio](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@FSapio](https://qa.fmod.com/u/FSapio)\
**Post date:** [December 15, 2025, 11:15am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/5 "2025-12-15T11:15:38Z")

</div>

1. Finally, I tried accessing it in a different way (still, no luck), the code reaches the very end, so no errors, but the length is always zero:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/27ce3436c2bdbce1e72b631be88256e7edca81b5.png)

Sorry for the long post, for so much code (in case I can also give you the code to copy and paste if images are not comfortable) and that it is divided in multiple answers. However, I wanted to make you understand all the attempts I did so far.

What am I doing wrong?

Thank you again for your help! 🙏

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [December 16, 2025, 4:31am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/7 "2025-12-16T04:31:44Z")

</div>

Hi,

Thanks for the images, code can be added in blocks with the `formatted text` option:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/8517c6eb26cd8207662ba08ac7e4e314d2ba6550.png)

Under: [Unreal Integration | User Guide - Using Programmer Instruments Via The Fmod Studio Api](https://fmod.com/docs/2.03/unreal/user-guide.html#using-programmer-instruments-via-the-fmod-studio-api) we outline how to set up custom programmer instrument callbacks, in the initial image I am thinking it may be an issue with calling `setCallback()` 3 times. More flags can be added to the argument with `|`.

The error: `46 - NOT READY` from the fact we are loading the sound from an audio table. To solve that we can check the `FMOD_OPENSTATE` and wait till it is ready:

```cpp
FMOD_OPENSTATE state = FMOD_OPENSTATE_MAX;
bool starving, diskBusy = false;
unsigned int percent = 0;
FMOD_RESULT result = Sound->getOpenState(&state, &percent, &starving, &diskBusy);
while (state != FMOD_OPENSTATE_READY && result == FMOD_OK)
{
    result = Sound->getOpenState(&state, &percent, &starving, &diskBusy);
}
if (result != FMOD_OK)
{
    // Log error here
}

```

([FMOD Engine | Core Api Sound - Sound::Getopenstate](https://www.fmod.com/docs/2.00/api/core-api-sound.html#sound_getopenstate))

Since we are loading the sound from an Audio table, it wont actually be `Sound` that is the `Master.bank`. So we will need to retrieve actual sound with [FMOD Engine | Core Api Sound - Sound::Getsubsound](https://www.fmod.com/docs/2.00/api/core-api-sound.html#sound_getsubsound)

```cpp
FMOD::Sound* subSound1 = nullptr;
result = Sound->getSubSound(0, &subSound1);
unsigned int length = 0;
result = FMOD_Sound_GetLength((FMOD_SOUND*)subSound1, &length, FMOD_TIMEUNIT_MS);

```

This should return to correct length. You can add some more checks:

- Confirm a sub sound exists [FMOD Engine | Core Api Sound - Sound::Getnumsubsounds](https://www.fmod.com/docs/2.00/api/core-api-sound.html#sound_getnumsubsounds)

- Confirm the name of the asset the is being played [FMOD Engine | Core Api Sound - Sound::Getname](https://www.fmod.com/docs/2.00/api/core-api-sound.html#sound_getname)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![FSapio](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@FSapio](https://qa.fmod.com/u/FSapio)\
**Post date:** [December 16, 2025, 2:04pm UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/8 "2025-12-16T14:04:03Z")

</div>

Hi, thanks for the prompt reply!

For the code formatting, I even tried with different browsers, but it seems that the option to add code in the forum is missing on my side! ☹

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/1/16bdf2bde74458453f858ee6229058de51e9d685.png)

As for the rest, everything was super clear, thanks! I was able to make it work by modifying the AudioComponent.cpp, storing the Sound in a variable, and upon request in another function, retrieve the subsound and getting the correct length.

As for the _setCallback()_, the three times where just an example, I tried one at the time. However, still no luck, it seems that the callback is never actually called.

I will mark your reply as the solution, as it actually solved the problem. In case I will need the callbacks, I will open another forum post.

Thank you so much once again for your kind help Connor, have a wonderful day ahead!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [December 17, 2025, 3:28am UTC](https://qa.fmod.com/t/getting-length-of-programming-sounds-in-unreal-engine-from-the-audio-table/23811/9 "2025-12-17T03:28:12Z")

</div>

> [@FSapio](#):
>
> For the code formatting, I even tried with different browsers, but it seems that the option to add code in the forum is missing on my side! ☹

Interesting, if you surround the code with ``` does that work?  
e.g.

````cpp
```
// Code here
```

````

Good the hear the issue is solved! If there is anything else we can assist with, please do not hesitate to reach out!
