Audio stops playing randomly

Ok,

So I’m trying to play background music, some SFX and some voice sound for AI. I’m on my custom project and didn’t try reproducing the scene on a blank template as I’m half way through my game setup. Reproducing will need a lot of time.

Now,
Here are a video links for the problem,

[1st Trial video][1]

[2nd Trial video][2]

I have 2 sound cues for AI voice sound and bush rattling (sound cues only have few soundwaves and a random node) and 2 soundwaves for music, all of these having default settings except the sound class property is set to relevant class. Here are the settings of the audio files.

NOTE : I use 2 audio component to switch the background sounds and for SFX and Voice sound, I used dedicated audio components for characters and bush actors

If need any more info for debugging lemme know. I’m I missing something or its jus a bug ?

Please help !! its wasting lot of time … :frowning:

This happens to us as well after updating to 4.14.

One thing we noticed is that the sounds that were stopped after loading a map will start play after we resume the game. We use UGameplayStatics::SetGamePaused to pause/resume the game.

From what we know there is no special case where the sounds get heard, the same sound (we are shooting weapons in an FPS game and one weapon uses the same shooting sound) sometimes plays, sometimes it doesn’t. However, it happens to us with a lot of other sounds, no necessarily sounds you shoot fast or with a certain setup.

Let us know if you find out anything else.

Sadly, we can’t really roll back, we have too many changes now to get back to a lower version. There were issues which stopped us updating in 4.13, we came from 4.12.5 directly to 4.14, however, this sound issue seems not to be too widely spread, otherwise we would see more threads here complaining about it and perhaps Unreal guys saying something about it.
There were (I would say ‘major’) changes to the sounds in 4.14 in relation to older versions (if you look for “New: Added a debug command to solo specific sound waves, sound cues, and sound classes” in Unreal Engine 4.14 Released! - Unreal Engine ) and one of them it seems relates to the sound running on a separate thread by default in this release (which might mean some kind of synchronizing needs to gets done by default to have the sounds playing normally which might have something to do to why some of the sounds we start when the level loads are not actually playing or they are paused or not starting correctly).
Anyway, we haven’t had the time to actually test to see exactly what is going on (if we could, might not be able to tell if we don’t start debugging the code).

Yeah that’s a big pain to upgrade engine specially when using C++. Unless we figure out a way to reproduce it unreal guys can’t really do anything. I tried on a blank project and works ok. The sound changes are majorly for lip syncing maybe

BTW the sound debug commands are messy too. the ‘stat sounds -debug’ actually shows sound attenuation radius but it doesn’t most of the time and sometimes it jus disappears. Reentering the command doesn’t help.

Hope your problem gets resolved soon. To avoid wasting time I have to reproduce my code again in previous version. Still would try to figure out a solution for this.

I have to roll back to my previous copy of 4.14 version game where things were fine.

1 thing to note is that in my previous version I used to pause the level when it begins and then used a button to resume the level. The catch here is maybe due to that pause and wait for user input thingy, the engine gets time for executing the functions which are hooked to begin play. When I ran level directly, camera blend didn’t work on begin play. had to ad a 0.1 second delay to get it working. Without that pause sometimes the blueprint functions jus won’t execute even when hooked and enabled breakpoint. The execution jus stops in between. in my case mostly for camera blend and set sound for audio component.

I used to execute level initialization in HUD and widget UI but thought sometimes engine gets messed up due to all BP so shifted the code to level BP. Things went well for a while then got messed up again !

UE4 isn’t that mature for mobile platform compare to unity like not UI particles, no dynamic shadows for ES2 (modulated shadows are inaccurate, cascaded are too heavy) … but I love this engine. Hope to find solution soon !

I’m certain it doesn’t happen in 4.12.5. We’ve been with that version for a while and was fine, certainly appears when we moved up from that version.

I just tested with the sound not running in its own thread, edited BaseEditor.ini

[Audio]
MaxChannels=32
CommonAudioPoolSize=0
UnfocusedVolumeMultiplier=0.0
UseAudioThread=false
EnableAudioMixer=false

and it does the same, so its not related to that. Not sure if this ini edit actually matter when we run in editor but it seems it has no impact on the error if it does.

Posted in Bug Reports

I’m not sure about the ini edits but 4.13 and 4.14 were the big updates in terms of physics, audio and rendering. I read somewhere to delete .ini files and restart the project. But it messed up my project entirely :stuck_out_tongue: all my custom collisions and other settings POOF GONE jus like that ! :smiley:

can u tell me what problems u had with 4.13 ? my previous version of 4.14 is messed up too !! what a PIA … I updated to 4.13 for physical animation as my game is based on ragdoll and 4.14 for rendering stuff and vulkan support

mayb PM me on forums thread is getting quiet big

The .ini files contain custom collision profiles and all project settings :slight_smile: Sorry about that.

I’ll be short. As far as we’ve got with the tests, 4.13 had changed the way MoveToLocation functioned (which probably was for the better but our AI code didn’t work correctly with it at the time. I’m not 100% that was the only issue with the AI in that version, some of the behaviors we seen might’ve been from somewhere else) and the main UI wasn’t showing.
We haven’t got as far as testing the sound with that version since there were other bigger issues (not showing the UI was the main problem and we didn’t had the time to test it further) so I can’t tell if that was an older 4.14 problem or not.

ohhh yeah I remember … EQS get all actors was bugged out too !! or mayb in 4.12 … huhhh if such things persist, i’ll be forced to opt Unity ! as a solo dev I can’t waste time in such things. :frowning:

Hey guys, we recently found the bug in one of our internal projects.

It was introduced when we supported pausing individual sounds in addition to pausing the entire game. The cause of the bug is because sound sources objects are recycled and state needs to be cleared before reuse. Sound sources from a previous life which were paused are causing future sound sources to behave as if they’re paused.

The fix is simple, I’m trying to see if I can get approval for a hotfix, but in the meantime, if you need a quick patch, add the following code in AudioDevice.cpp (line 2911) after successfully initializing a sound source.

if (Source->IsPreparedToInit())
{
	// Init the source, this may result in failure
	bSuccess = Source->Init(WaveInstance);
		
	// If we succeeded then play and update the source
	if (bSuccess)
	{
		// PATCH BEGIN....
		// Clear pause state
		Source->bIsManuallyPaused = false;
		Source->bIsPausedByGame = false;
		// PATCH END...

		// Set the pause before updating it
		Source->SetPauseManually(Source->WaveInstance->bIsPaused);

In 4.15 we have a CommonInit function for sound sources which is called inside Init on all platforms so this will look a little different in 4.15+.

NOOB QUESTION !! I haven’t explore the C++ side much yet.

How do I patch if i’m using launcher version ? do I have to download git version and make changes ? will I be able to upgrade the engine if needed ? will it affect my BP project in anyways ?

I’ve read documentation but there is no reference for editing launcher version engine.

Yes, you’ll have to get the source, add the code above, rebuild the engine. It’s easy to do, but you need the source. Will work exactly like launcher version once your build.

EDIT: This is a bit old now, but I think the process is pretty much the same. - YouTube

EDIT2: Note that I submitted this fix as a patch for 4.14.2 so if you sit tight, might just come down automatically for you.

Hi there !

I tested the engine by editing the source code as mentioned above. I launched my project and as I restarted the game as shown in the video, the background music didn’t show up. Also the stat sounds -debug stops working randomly. Only works when used with other debug commands. I used ‘stat soundwaves’.

EDIT : The root of problem is definitely related to some kind of pausing and audio component. I noticed one thing that when I hit the AIs, sometimes they don’t make sound but after hitting them and if I pause and resume the game, the sound plays immediately. Background music still doesn’t work after resuming as above. Another thing is if I spawn the sound actor instead of placing it in level in first place, the everything works fine (at least for now).

I’ll be using the GitHub version of the engine and will be updating the code from there. it will be easier for me to make changes to engine code if such bugs appear.

Hope to get fixes soon … Love u guys !! :smiley:

Are you sure you rebuilt the engine with the change and are using the version of your built source? Have you stepped into the source with a breakpoint in AudioDevice.cpp to confirm your build is running with the fix? Sounds like you’re not running with the fix and I’m 99% sure the issue is fixed with that change.

Here you go !! I’m 1000% sure I’m running the patched version :smiley: and have built the code several times.

I haven’t updated the engine from launcher but got 4.14.1 from GitHub. if need any more info we could skype if there is time or maybe Email or something to avoid time-zone problems. I’ll be gathering more info about it parallel. For now spawning the sound actor works for me but as its a major bug, I would like to help fix it as much as I can.

If you’re still seeing issues after running with that code, then this is a totally new problem I’ve not heard about – I’ll have to get my audio QA to help track down a repro from this thread.

Sure,
Please let me know if any more info needed as I find this issue very rare.