gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
346 stars 69 forks source link

Sound went silent when segment looped in Metasound #81

Open IskandarAlex2 opened 1 month ago

IskandarAlex2 commented 1 month ago

The imported sound went silent when it looped with the beginning loop time set. The output is there so I can track playback time, with and without it the same issue still occurs. This is on my windows machine so if anything this is not just Linux like last time with my past issue here

image

Here's a video to demonstrate the issue https://github.com/user-attachments/assets/71a6c31a-561c-4e0f-92d1-18a0aadd4600

gtreshchev commented 1 month ago

In my experiments I wasn't able to get it working with the regular sound wave, so after the Stop command is executed, the Play command can't be executed again for some reason. Also, the PlaybackTime isn't broadcasting after the Stop is triggered, even after the second Start. I was testing on UE 5.4. Can you please provide additional context regarding the UE version and more BP nodes?

IskandarAlex2 commented 1 month ago

Latest - UE5.4.4 image image

and yes, the loop segment works as usual with regular sound waves, only imported sound waves face this randomly silenced issue.

IskandarAlex2 commented 1 month ago

I made a test between regular wave asset and RAI import (of the same source file) same node other than I changed the loop segment begin and duration time for this one song

https://github.com/user-attachments/assets/c76afda5-80f0-4b2b-86b8-1dd6e96028c7

gtreshchev commented 1 month ago

You should make sure that the sound wave isn't garbage collected prematurely by assigning it to a separate variable in Blueprints so that it's treated as a hard reference.

Also, how exactly are you stopping the playback? Are you calling the Stop trigger via ExecuteTriggerParameter and then playing it again using the Play function from the audio component or ExecuteTriggerParameter with OnPlay?

IskandarAlex2 commented 1 month ago

I don't use the stop trigger for this. At all, it is there for the main purpose but it is not used during the experiment I made. I also did try to make the imported wave as a hard reference variable in the blueprint but the same thing still occurs

gtreshchev commented 1 month ago

Hmm so how do you stop the sound then?

IskandarAlex2 commented 1 month ago

This thing's main purpose includes calling that "stop" trigger input. But right now, the issue isn't that, it's the Metasound wave player went silent when it is supposed to loop the playing wave. From the video of my testing, the looping works perfectly with regular sound wave asset but went completely silent when looped with imported sound wave

IskandarAlex2 commented 1 month ago

I use a workaround by tracking the playback time manually and replaying it with the beginning loop as the start time. I would not consider this as resolved because the plugin failed to support Metasound's wave player node feature.

gtreshchev commented 1 month ago

Hmm, maybe the loop in the wave player requires some virtual function to be implemented for it to work with the wave asset, or perhaps some property needs to be filled. I'll need to look into it over the weekend

aescapes commented 3 weeks ago

Not sure if this is helpful but this could be related to the issue. The WavePlayer's loop start time seems to be the problem when using the importer. It's not that it's not looping but it's looping to the wrong part of the audio (seemingly often twice later than what is set or something). The non-audio outputs of the WavePlayer seem to work as expected as does the Loop Duration input. The silence could be caused by it looping to a point where there's no more audio left.

Happens to me in UE 5.4.3. Works fine in 5.3.x

aescapes commented 3 weeks ago

The looping error amount seems to correlate with the audio channel amount. Mono audio seems to work. Stereo audio seems to double the loop start point. With 6-channel audio (5.1 surround), the loop start point seems to be 6 times the input.