Hello!
I am trying to get the length of an audio clip in an audio table that is playing back though a programmer instrument. After reviewing the API documentation and with some help from a forum post (Get length/duration of Programmer Instrument audio table loaded sound), I came up with this:
FMOD.Sound voSound;
var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(voSoundInfo.name_or_data, soundMode | voSoundInfo.mode, ref voSoundInfo.exinfo, out voSound);
FMOD.Sound subSound;
voSound.getSubSound(voSoundInfo.subsoundindex, out subSound);
subSound.getLength(out uint length, FMOD.TIMEUNIT.MS);
The first time the audio plays back, the value assigned to “length” is the audio clip length (as expected). However, on subsequent playbacks (of any clip), the value assigned to “length” is 0.
Any suggestions on how to improve this code to return the audio clip length every time the audio plays back would be greatly appreciated! Here is a little more of the surrounding code for reference: