Get sounds being played in-game to blueprints?

Hey there,

I’m wondering if there’s a way, through blueprints, to get the names of sounds/soundcues/ambient actors being played while in-game. I’d like to read any sound being heard by the player. It’d be nice to get the names and even their locations in the world.

Tall order, I know, but It’d be real helpful if I could get this info. Thanks everyone!

Nope, put all your music in a struct array, with the name saved.

Call song, call song name.

They’re is no way to do that from blueprints currently…However, there is a member function of FAudioDevice called GetSortedActiveWaveInstances() which could be exposed in order to achieve this.

Thanks, I guess I’ll have to figure something else out.

Well it might be possible if you’re playing all your sounds using blueprints. What you could do is to add any sound cue that starts playing into a ‘Sound Cue array’ and remove anything that stops playing from the array. This way you will always have a list of sounds that’s being played at any moment. From the array, you can loop and get all sound cues and get display name as shown:

If it’s the location you want, you could store ambient sound actors into the array instead of sound cues. That way you can get the location as well as the sound cue name.

Thanks for the reply. Unfortunately, in this case I have to be able to read sounds from all kinds of sources - like anim notifies, blueprints, and sound actors in the level.

Found this while searching for a solution to a similar issue. 9 years later, and still no solution for this. :frowning_face: :man_facepalming:

Hello. This is my solution.

Short description.

Short code.
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnVolumeChanged, USoundBase*, Sound, const TArray&, NewVolume, FVector, Vector, int, Id);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnSoundAdded, USoundBase*, Sound, FVector, Vector, int, Id);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnSoundRemoved, USoundBase*, Sound, FVector, Vector, int, Id);

UCLASS(Blueprintable)
class MAGIC_API UMySoundListenerSubsystem : public UAudioEngineSubsystem
, public IActiveSoundUpdateInterface
{
GENERATED_BODY()

public:

UPROPERTY(BlueprintAssignable, Category = "Audio")
FOnVolumeChanged OnVolumeChanged;

UPROPERTY(BlueprintAssignable, Category = "Audio")
FOnSoundAdded OnSoundAdded;

UPROPERTY(BlueprintAssignable, Category = "Audio")
FOnSoundRemoved OnSoundRemoved;


virtual bool ShouldCreateSubsystem(UObject* Outer) const override
{
	return !IsRunningDedicatedServer();
}

virtual void Update() override;

virtual void OnNotifyAddActiveSound(FActiveSound& ActiveSound) override;

virtual void OnNotifyPendingDelete(const FActiveSound& ActiveSound) override;

TArray<FActiveSound*> ActiveSounds;

};

void UMySoundListenerSubsystem::Update()
{
for (FActiveSound* ActiveSound : ActiveSounds)
{
uint32 ID = ActiveSound->GetObjectId();
FVector Position = ActiveSound->LastLocation;
USoundBase* SoundBase = ActiveSound->GetSound();
TArray Volumes;
TMap<UPTRINT, FWaveInstance*> Waves = ActiveSound->GetWaveInstances();
for (TPair<UPTRINT, FWaveInstance*> Pair : Waves)
{
Volumes.Add(Pair.Value->GetActualVolume());
}

	AsyncTask(ENamedThreads::GameThread, [this, Volumes, SoundBase, Position, ID]()
		{
			OnVolumeChanged.Broadcast(SoundBase, Volumes, Position, ID);

		});
	
}

}

void UMySoundListenerSubsystem::OnNotifyAddActiveSound(FActiveSound& ActiveSound)
{
uint32 ID = ActiveSound.GetObjectId();
FVector Position = ActiveSound.LastLocation;
USoundBase* SoundBase = ActiveSound.GetSound();

if (!SoundBase)
{
	UE_LOG(LogTemp, Warning, TEXT("ActiveSound does not have a valid SoundBase!"));
	return;
}

ActiveSounds.Add(&ActiveSound);

AsyncTask(ENamedThreads::GameThread, [this, SoundBase, Position, ID]()
	{
		OnSoundAdded.Broadcast(SoundBase, Position, ID);

	});

}

void UMySoundListenerSubsystem::OnNotifyPendingDelete(const FActiveSound& ActiveSound)
{
uint32 ID = ActiveSound.GetObjectId();
FVector Position = ActiveSound.LastLocation;
USoundBase* SoundBase = ActiveSound.GetSound();

if (!SoundBase)
{
	UE_LOG(LogTemp, Warning, TEXT("ActiveSound does not have a valid SoundBase!"));
	return;
}
FActiveSound* RemoveActiveSound = const_cast<FActiveSound*>(&ActiveSound);
ActiveSounds.Remove(RemoveActiveSound);
AsyncTask(ENamedThreads::GameThread, [this, SoundBase, Position, ID]()
	{
		OnSoundRemoved.Broadcast(SoundBase, Position, ID);
	});

}