UGameplayStatics::PlaySoundAttached never works if sound is less than 1 second in duration

I have some sounds and a sound cue available to a dev on a dropbox in case you want to test this yourself.

We have multiple sounds controlled by a crossfade by param node in a sound cue (see attached picture).

In UGameplayStatics::PlaySoundAttached function it calls FAudioDevice::CreateComponent which calls Sound->IsAudibleSimple. If duration of sound cue is less than 1.0 seconds then this function always returns false because GetMaxAudibleDistance() is always returning 1.0 and I still cannot find out where this is getting set for this SoundCue.

Anyhow, if I make one of sounds greater than 1 second thereby making SoundCue’s duration larger than one second then it will always work.

I think USoundBase::IsAudibleSimple function needs to be reworked because this sound should be audible. Also, we have attenuation settings in our sound cue but it does not even look there and passes NULL/nullptr, otherwise this may work.

I am testing with Play In Editor on UE4 4.7 (release branch from github).

Thanks so much,
Kory

I forgot to attach picture. Here I highlighted new wave player that I had to add with 0.0 probability with a duration longer than 1 second so that sounds can play.

Hello Kory,

Thank you for detailed report about this issue. Would you mind providing me with your dxdiag please?

I am going to gather as much information about approach you are taking as well as minimum accepted length of a sound wave/cue.

Let me know if there are any additional comments or more information that might help us find a resolution to issue.

Thank you,

Hi Kory,

We haven’t heard back from you in a while, so I’m resolving this post for tracking purpose. If you’re still experiencing a problem with PlaySoundAttached, please feel free to respond with information requested by above and we can continue investigating. Thanks!

Were you not able to replicate issue? Where shall I provide dxdiag information? I do not want to share it here. Also, regarding more information, I think my first post was verbose enough and easy enough to test with as I specified exactly where in code it is checking if duration is longer than 1 second.
Thanks,
Kory

If you do not wish to share with us your ‘dxdiag’ on AnswerHub, you can send it to me via a private message on Forums.

Thank you,

PM was sent.

Hey Kory,

Thank you for providing me with your dxdiag. We can use this information for tracking purposes as well as other statistical information we might need in future. I have looped in our lead audio engineer about minimal accepted length of sound waves in engine, and whether or not you are seeing an expected outcome, or if it is in fact a bug.

Thank you for your patience while we attempt to troubleshoot your issue.

Regards,

Hi Kory,

just looped me in on this thread. We’re working to repro issue you describe but in mean time I have some insight into this that might help you.

For sounds shorter than 1.0 seconds, in USoundBase::IsAudibleSimple, GetMaxAudibleDistance() function result is based on your AttenuationSettings of sound (via USoundWave::GetMaxAudibleDistance override of USoundBase class) itself or optional override AttenuationSettings which is passed in to PlaySoundAttached function. It sounds like this optional settings is null in your case.

In both cases, though, properties of AttenuationSettings to check are FalloffDistance and AttenuationShapeExtents properties (which are both editable from editor).

It could definitely be case that there is a bug with AttenuationSettings so we are, as I said, looking to repro situation on our end. But in meantime, I recommend checking out what your attenuation settings are or set a breakpoint in USoundWave::GetMaxAudibleDistance() and see what’s going on there. If issue still persists, it would be helpful to know what those settings are and/or what your debugging says FAttenuationSettings::GetMaxDimension() is returning.

Finally, as a programmer, I deeply appreciate your detailed write up of issue! Thank you very much :slight_smile:

Hi , going from my memory 2 weeks ago here is what I remember.

I think we had attenuation settings set in Sound Cue but they were only coming through NULL/nullptr. GetMaxAudibleDistance was returning 1.0 and I couldn’t find where that was being set.

Actually, looking at my first write-up above, I’ve already mentioned those things.

Hi Kory,

Yes, I saw that you mentioned that, which is what I meant by:

“It sounds like this optional settings is null in your case.”

AttenuationSettings that are passed in from static function are optional (and are set to default to null) and override settings from your sound wave. If you wanted to use that, you’d pass it in as an argument to static function from blueprint. place to check in this case is attenuation settings that are set on your sound asset.

Here’s documentation on that:

If GetMaxAudibleDistance() is returning 1.0, that means FAttenuationSettings::GetMaxDimension() is returning 1.0, which means your attenuation settings on sound wave are 1.0 (or there’s a nasty bug somewhere).

Ah yes, I see now. Can you send me a link to your dropbox of project? I’ll try and repro this. SoundCue code does look fishy.

OK, I have a demo project for you to use and test this with.

If I had only one sound in a sound cue without Crossfade by Param node then it works when it is < 1 second. But once I use Sound Cue from our project it stops working. I can post this project to my dropbox for you guys to test with if you would like. This project works by firing gun.
Thanks,
Kory

Here is dropbox project that has problem:
link text

Oh and I forgot to mention that if you remove all of nodes except for only sound it still does not work. But if you close and reopen editor then it starts working again. If you hook these nodes back up it works. But if you close and reopen again then it doesn’t. So keep that in mind as well.

Awesome! Got your demo project and was able to repro on latest head revision in UE4 no problem. Figured out that issue was in SoundNodeParamCrossFade you were using. Internally that’s implemented as a sub-class of SoundNodeDistanceCrossFade, which is fine for most part (it’s basically same calculation but instead of distance its your blueprint param). However, when it was going to calculate that node’s max distance, it used SoundNodeDistanceCrossFade version because sub-class didn’t override method. fix is to just make a dummy pass-through implementation for SoundNodeParamCrossFade class.

Unfortunately this fix just missed deadline for upcoming release of UE4, but you’re welcome to patch it in yourself if you don’t want to wait. fix is:

SoundNodeParamCrossFade.h, line 23,add:

virtual float MaxAudibleDistance(float CurrentMaxDistance) override;

and SoundNodeParamCrossFade.cpp, line 29, add:

float USoundNodeParamCrossFade::MaxAudibleDistance(float CurrentMaxDistance)
{
	// Param-based crossfades are not a factor in max distance calculations
	return CurrentMaxDistance;
}

Thanks man!

Also, I think this is because max distance calculation is cached… there might be an issue with it refreshing/recomputed max distance when it needs to be.