OnAudioPlaybackPercent only returning zero

We have run into a bug in 4.21.2 with the OnAudioPlaybackPercent event from AudioComponent. It will only return 0.0 after you restart the editor. We also reproduced this bug with Starter Content audio.

Repro Steps:

  1. Create a new 4.21.2 project

  2. Import a .WAV file

  3. Create a new Actor blueprint

  4. Add a Audio Component to the new actor.

  5. Via BeginPlay, call Bind to OnAudioPlayPercent from the Audio Component. Via this node call Play on the Audio Component.

  6. Drag off of the red delegate input for Bind to OnAudioPlayerPercent and create a new event.

  7. Via the new event, call Print String.

  8. Connect Playback Percent variable from the event to the string of Print String (It should add a convert node)

  9. Place the actor in the level, set the sound property of the audio component to the sound wave file imported before.

  10. play the game. Noticed the number printed goes from 0.0 to 1.0

  11. close and reopen the project.

  12. play the game again. the number printed should only be 0.0.

We included a sample project with repro steps and details in the ReadMe here:

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks

Forcing people to a new bug report system is just a way to silence them. And for the record this bug is still there in 4.23 despite being reported since 4.20 or so.

“Won’t fix”

MathewW: so this is the code causing the issue, it was duration related and designed like this for whatever reason. Setting it to streaming probably fixed it since it went down another pipe. The DecompressionType being set to RealTime and not Native was the issue. This code

   // handle audio decompression
    if (FPlatformProperties::SupportsAudioStreaming() && SoundWave->IsStreaming())
    {
        SoundWave->DecompressionType = DTYPE_Streaming;
        SoundWave->bCanProcessAsync = false;
    }
    else if (!bForceFullDecompression &&
              SupportsRealtimeDecompression() &&
              ((bDisableAudioCaching || DisablePCMAudioCaching()) ||
              (!SoundGroup.bAlwaysDecompressOnLoad &&
              (ForceRealtimeDecompressionCvar || SoundWave->Duration > CompressedDurationThreshold || (RealtimeDecompressZeroDurationSoundsCvar && SoundWave->Duration <= 0.0f)))))
    {
        // Store as compressed data and decompress in realtime
        SoundWave->DecompressionType = DTYPE_RealTime;

MathewW: was setting it to RealTime if certain things failed and one of them is a fixed set duration of 5 seconds based on the Group setting in the Audio file (all of the group are defaulted to 5 or 0 so the “fix” is to go into the defaultengine.ini file and change it from 5 to something like 15 like this

[/Script/Engine.SoundGroups]
+SoundGroupProfiles=(SoundGroup=SOUNDGROUP_Default, bAlwaysDecompressOnLoad=false, DecompressedDuration=15)

MathewW: and then sounds up to 15 will be treated as Native for the type and the samples will not be 0 (this was the actual issue, realtime shows up as 0 samples). or uh…

+SoundGroupProfiles=(SoundGroup=SOUNDGROUP_Percent, bAlwaysDecompressOnLoad=false, DecompressedDuration=30)

MathewW: add that as a new line after the other profiles and magically it will all fix itself if you have default selected basically you are trading off realtime decompression which saves on memory or native decompression which loads it into memory but you get your # of samples correctly

1 Like