x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Any way to only have one sound play at any given time?

I'm currently working on a project aimed at children who cannot read.


All menus and buttons are narrated to aid their understanding of the game.

The Problem : Currently, the player can sporadically move the mouse over various buttons and be greeted with a cacophony of overlapping voice sounds being played.


The way this is set up:

  • All buttons have their narration sounds played using the "On Hover" setting in UMG.

  • Some menus also have a sound play on construct, to explain the meaning of the particular screen.

  • This is a 100% blueprint based project.


I have my sound classes and mix set up, and all of the sound files are set to have a maximum of 1 concurrent play, meaning the sound cannot be repeated unless the first has finished.

However, this only applies to individual sounds overlapping themselves. Is there any way of applying this logic to an entire sound class? Meaning that only one sound in the narration class can be played at any time?

Any help would be greatly appreciated.

Thank You.

Product Version: Not Selected
Tags:
more ▼

asked Feb 02 '15 at 08:03 PM in Using UE4

avatar image

Kenomica
434 40 40 46

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

You need to playout sound from single audio component, it works like player and single audio component won't play 2 sound cues in same time. You will need to stop sound, switch sound and play it

more ▼

answered Feb 02 '15 at 08:38 PM

avatar image

Shadowriver
35.8k 927 169 1105

avatar image Kenomica Feb 02 '15 at 09:05 PM

Thank you for your answer, though I'm not sure I fully understand.

I am using UMG's button hovers to activate the individual sounds since I have need of these over various levels and menus.

I have updated my original post to make my situation more clear.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You can do this easily if you're willing to write a little C++ Blueprint utility function. Something like this:

 bool UUtilities::PlaySoundIfNotRecentlyPlayed(UObject* WorldContextObject, USoundBase* Sound, FVector Location, float MinimumTimeElapsed, float VolumeMultiplier, float PitchMultiplier)
 {
     UWorld* ThisWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
     FAudioDevice* Dev = GEngine->GetAudioDevice();
     if (!ThisWorld || !Dev) return false;
     for (const FActiveSound* ExistingSound : Dev->GetActiveSounds())
     {
         if (ExistingSound->Sound == Sound && ExistingSound->PlaybackTime < MinimumTimeElapsed && ExistingSound->World == ThisWorld && some_other_custom_comparison_logic)
         {
             return false;
         }
     }
     UGameplayStatics::PlaySoundAtLocation(WorldContextObject, Sound, Location, VolumeMultiplier, PitchMultiplier);
     // or some other sound playing function
     return true;
 }

Add your own custom logic at some_other_custom_comparison_logic to decide if the sound shouldn't be played.

more ▼

answered Feb 03 '15 at 05:58 AM

avatar image

cancel
2.4k 100 72 123

avatar image Kenomica Feb 03 '15 at 05:57 PM

Thank you for the reply.

Sadly, I have absolutely no idea on how to code - especially with C++.

I'm using 100% blueprints here. I understand the logic of the code you posted, but have no idea on how to achieve this with BP (if it is possible at all)

avatar image eXi Feb 12 '15 at 10:03 AM

Isn't it somehow possible to use a simple bool for that? I don't know if this would really work, but is it possible to get the remaining time of a sound?

You could do this for every sound (a function that gets the sounds as a paramter would be helpfull then). Just chech if the bool (e.g.) "bIsPlaying" is false and only then play your sound. If you play your sound, set the bool to true and get the remaining time of the sound. If the remaining time is less than 0.1 or something like that, set the bool back to false.

I'm totally sorry if this doesn't work, since i haven't worked with sounds yet and i have no time digging into my Editor right now. Maybe this still helps you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question