# How to know the duration of a programmer sound in advance?

**URL:** <https://qa.fmod.com/t/how-to-know-the-duration-of-a-programmer-sound-in-advance/14987>\
**Category:** Unreal Engine\
**Created:** [August 27, 2019, 2:35pm UTC](https://qa.fmod.com/t/how-to-know-the-duration-of-a-programmer-sound-in-advance/14987 "2019-08-27T14:35:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AgustinCordes](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@AgustinCordes](https://qa.fmod.com/u/AgustinCordes)\
**Post date:** [August 27, 2019, 2:35pm UTC](https://qa.fmod.com/t/how-to-know-the-duration-of-a-programmer-sound-in-advance/14987/1 "2019-08-27T14:35:59Z")

</div>

Hi all! I know there’s been similar topics in the past, but what we need to do is _very_ specific — we have a typewriter-like effect for subtitles in our adventure (as in, each subtitle appears gradually, letter-by-letter, in a similar way to many visual novels). Since our conversation sequences have voice overs, we want to have the subtitles appearing as the character speaks. However, to achieve a precise effect, we need to know the duration of each sample _in advance_, before the subtitle starts the effect.

We’re using programmer sounds for voice overs, so I was wondering if it’s possible to poll the length of each programmer sound before it starts playing. And, if this functionality isn’t exposed in the plugin, where should we look in the C++ API to expose it.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [September 2, 2019, 4:35am UTC](https://qa.fmod.com/t/how-to-know-the-duration-of-a-programmer-sound-in-advance/14987/2 "2019-09-02T04:35:17Z")

</div>

The programmer instrument will always be the same length in the event, but its contents will change depending on the audio file that is provided. In the same piece of code that looks up the audio file and creates an `FMOD::Sound` to provide to the programmer instrument, you can call [`Sound::getLength()`](https://www.fmod.com/resources/documentation-api?version=2.0&page=core-api-sound.html#sound_getlength) to get the length of that audio file.

---

<div class="post-metadata">

**Author:** ![AgustinCordes](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@AgustinCordes](https://qa.fmod.com/u/AgustinCordes)\
**Post date:** [September 2, 2019, 11:49am UTC](https://qa.fmod.com/t/how-to-know-the-duration-of-a-programmer-sound-in-advance/14987/3 "2019-09-02T11:49:33Z")

</div>

Thanks @richard_simms for the reply. We tried that, but calling it immediately after the sound is created we got a `Not ready` error. Is there any restriction we should be aware of? For example, issuing a call to `Sound::getLength()` in the next frame? We need to know the length as soon as possible, preferably the moment the sound is created.

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [September 3, 2019, 2:08am UTC](https://qa.fmod.com/t/how-to-know-the-duration-of-a-programmer-sound-in-advance/14987/4 "2019-09-03T02:08:54Z")

</div>

You might need to call `System::update()` after creating the FMOD::Sound. This will update the system so you can grab the information you need.
