Download

Audio doesn't actually play when there are no devices

Firstly I realise that this is very special case but thought it was interesting enough to post about. I’m using 4.9.2 currently but I know that it has been doing this for a while, just taken a lot of time to warrant posting it. This issue also occurs both in editor and in built packages (development and shipping).

I have disabled on board speakers on my machine and didn’t have my headphones plugged in so there were no audio devices connected to the machine whilst I was doing work. I have a few triggers in my project that are based on audio finishing playing, and they weren’t triggering the whole time that I didn’t have a device plugged in. I came to the conclusion that they weren’t actually playing at all because there is no device connected.

Kind of frustrating as I have no way of controlling that as far as I can see and also have no way of controlling whether or not people play with audio devices or not!

I been digging in to unreal sound system for a while and i can see why that might be happening. UE4 have it’s own instatiation audio device (FAudioDevice) and it’s also class that also controls active sounds (FActiveSound) which notification class that notify end of sound. if audio device is missing then FAudioDevice probably missing too, so do FActiveSound and as result there nothing that is playing sound and there nothing that notifys the end of them.

Current audio system is marked to be rewrited and replaced, so i guess it’s could be suggestion for new system. Other then that in this case you should prepare your code for sound card to be disconnected, but i don’t think there way to detect that via blueprints.

As Shadowriver observed, the audio system does not have any concept of channel virtualization, which is to say that when a sound isn’t playing it isn’t being simulated. This is largely because we rely on the hardware to process it and inform us when it completes and so if there is no audio device there is no hardware to process it. This would also be true if a sound were to simply not sound because too many sounds are active and there are no available channels.

In the new audio system we do plan on supporting channel virtualization so hopefully this kind of issue will no longer be as problematic.

I would recommend for the time being that instead of keying off a sound finishing for these kinds of timing behaviors you instead initialize a timer with the duration of the sound which should generally be close enough (though extremely complicated sound cues that may have highly variable play times won’t work because the duration that the cue returns will be the maximum possible duration and not the specific value of that playing of the sound).