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

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!

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() to get the length of that audio file.

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.

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.

1 Like