[BUG] Audio Duration not working

A few months back I posted a bug report stating that the Get Duration node for determining the length of an audio file was not working correctly. [BUG REPORT] Audio "Get Duration" is not getting the correct length - Audio - Epic Developer Community Forums

In reply I was told that I had been using the random function of a cue file incorrectly and that I should use an array of wav files to solve the problem. I have since switched to using an array but this is also not working correctly so either I’ve set up the array incorrectly or I think the Get Duration node is broken.

Here’s my current setup:

and here is a video showcasing my results:

The Array is a Sound Base variable with 4 wav files, each of an exact length, one second, three seconds, five seconds and ten seconds in length. I created the project from scratch using the Third Person Blueprint template in 4.13

Also, the second to last time I push the “J” key, the print strings happen but it doesn’t play the audio at all for some strange reason.

here’s a link to my test project:

Hello TorQueMoD,

So I opened up your project and discovered why you are getting the incorrect audio duration each time you call the sound wave to play.

In your case, you had an array of Sound Base class, which it does allow for Sound Waves or Sound Cues. For simplicity I created/converted that array into an ‘Array of Sound Waves’ to be called to play between a random range of 0 and 3. The main issue with your setup is you were calling the ‘Get’ from the Sound Base array two separate times, which is why the duration usually didn’t match up with the sound that was being called to play.

If you use the modified setup I have implemented below, Pressing the ‘J’ Key will get a random sound wave in the array, set that as the Sound Wave variable to be played, then you can call from that set to get the duration and other attributes of the Sound Wave.

Let me know if you have further questions or need additional assistance.

Thank you,

Ok awesome. I was actually building out the array based on the way a previous staff member suggested but I’ll try this one and let you know the results. Is there something wrong with leaving it as a Sound Base array so I can use both wav files and cue files? That shouldn’t affect the results of the duration should it?

Thank you so much Andrew, this fixed the issue. I can see how it helps to set the audio file to play and get the duration from that so it’s not accidentally grabbing a new random cue. I didn’t think it would be, but I can see how this just guarantees success. Exactly what I needed!

Glad I could point you in the right direction. Yeah, I can also see how the process you provided to me would make sense as well. Sometimes it can be easy to overlook something like calling a ‘Get’ node twice as it is often necessary, but I have found the best way to find these issues is to vocally step through the logic by saying what each node will do at any given time. This helps me figure out where/what I could have done wrong and make those corrections as necessary.