AudioPlaybackPercent cannot be obtained correctly

Hello,I have a USoundWaveProcedural and I use QueueAudio to add audio streams I received from grpc. I used to play and binding OnAudioPlaybackPercentNative audiocomponent, but it seems not work properly, it seems to work only for the first time to add data? When it prints 1, my audio still continues to play. Can anyone answer that question? Thank you

Another problem: Audio played in this way also does not trigger OnAudioFinishedNative…

1 Like

Hi, this issue arises from a kind of incompatibility between the audio component and the procedural sound wave. To get the audio playback percentage, I suggest implementing your solution manually instead of relying on the audio component. Since the procedural sound wave can be played back only once at a time, you should have enough info about the queued audio data to calculate the percentage manually, such as on tick. The only problem I can think of is that the QueuedAudio and AudioBuffer members in USoundWaveProcedural are private, so you would need to implement your own queuing system on top, such as by overriding the OnGeneratePCMAudio function.

You can take a look at the code I made for the RuntimeAudioImporter plugin as a reference: RuntimeAudioImporter/Source/RuntimeAudioImporter/Public/Sound/ImportedSoundWave.h at main · gtreshchev/RuntimeAudioImporter · GitHub (it might look intricate since it contains a lot of other features besides the playback functionality, but it also supports getting the playback percentage by the GetPlaybackPercentage function)

1 Like

I highly recommend using this plugin as a solution.Thanks again for your work. :grinning:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.