gtreshchev / RuntimeAudioImporter

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

After getting a Sound Wave Ref, audio won't call OnAudioFinish, and doesn't Play from 0.0 after. #16

Closed Motanum closed 2 years ago

Motanum commented 2 years ago

I downloaded the plug in, and used it to load a audio wav file not included as a UAsset. I managed to get it to work and to play, but I noticed that it wont properly work as normal UAssets. There are 2 important cases for me that I need to be able to handle correctly.

1, When the wav stops playing, it wont trigger the 'On Audio Finished' event from the AudioComponent.

  1. When stopping the audio and then doing a call to Play with Start Time of 0.0, the wav will just continue playing where it was stopped.

This means, that if the audio finished playing. it won't stop itself. And even if I do stop it myself, and then do a play again, the audio will just try to keep playing beyond which is just pure silence.

This is how I am getting the song. image

I don't know what I could be doing wrong.

gtreshchev commented 2 years ago

Hi. These "features" exist because of the use of USoundWaveProdecural, which has some limitations.

"On Audio Finished" is called only when the imported sound wave has completely finished playing. It is not called if playback has been interrupted externally (this cannot be handled inside the sound wave). Its purpose is to keep track of when the sound wave has completely finished playing.

In order to "reset" the playback of the sound wave, you need to use the "Rewind Playback Time" function and set the time to "0". Read more about this approach here.

In case you don't want to feel these peculiarities of working with a sound wave, you can convert it to a standard sound wave, which will work identically as imported into the editor in a standard way. Read more about it here.

Motanum commented 2 years ago

Thanks so much! It now behaves as I expect.

My only question is, to the Compressed Sound Wave, is there a way to make it a looping sound in blueprint?

image

gtreshchev commented 2 years ago

Yes, it is possible, but so far only in C++ manually.

In the next update, I will make it possible to select this parameter when calling the function to compress the sound wave.

Motanum commented 2 years ago

Cool! My project is C++, what is the function to call?

Thanks so much for the quick replies too!

gtreshchev commented 2 years ago

Hi, if you use C++ then you just need to set the "bLooping" property to "true" in the compressed sound wave.

But in the next update I will make it possible to do this automatically through the "CompressSoundWave" function.

gtreshchev commented 2 years ago

Hi, this feature has been implemented. You can download the latest plugin source and fill in the "Looping" parameter when compressing the sound wave.

Motanum commented 2 years ago

I downloaded it, but I cant compile my game.

GAME/Plugins/RuntimeAudioImporter/Source/RuntimeAudioImporter/Public/RuntimeAudioImporterLibrary.h(111): error : C++ Default parameter not parsed: CompressedSoundWaveInfo "FCompressedSoundWaveInfo()"

gtreshchev commented 2 years ago

It seems that something is wrong in the 4.27 version when parsing some specific ufunction headers. Should be ok now.

Motanum commented 2 years ago

Absolute MVP!

Thanks so much!

image