I can't seem to get a C++ script to get the current active sounds as an array.

Hello! I’m building out a TouchOSC template for use in testing and mixing audio in engine, and I’d like to add a live feed of the current active sounds to the build. I’ve written a script with C++ (with the help of some Chatbots) but it’s returning an empty array.

I know I’m making an iterating over an array, but not filling it with anything. Thus making it empty. Unfortunately, I’m not familiar enough with C++ to understand what I need to add. Any help to get this code working is very appreciated!

Here is the header file
#pragma once

include “CoreMinimal.h”
include “Kismet/BlueprintFunctionLibrary.h”
include “TrackActiveAudio.generated.h”

UCLASS()
class MYPROJECT_API UTrackActiveAudio : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
// Exposed function to retrieve the active sounds
UFUNCTION(BlueprintCallable, Category = “Audio”)
static TArray<USoundWave*> GetActiveSounds();
};


and here is the cpp file

include “GetActiveSounds.h”
include “AudioDevice.h”
include “TouchOSC_BuildOut.h”
include “Engine.h”

TArray<USoundWave*> UGetActiveSounds::GetActiveSounds()
{
TArray<USoundWave*> ActiveSounds;
FAudioDeviceHandle AudioDeviceHandle = GEngine->GetMainAudioDevice();

if (AudioDeviceHandle.IsValid())
{
    FAudioDevice* AudioDevice = AudioDeviceHandle.GetAudioDevice();

    TArray<FWaveInstance*> ActiveWaveInstances;

    for(FWaveInstance * WaveInstance : ActiveWaveInstances)
    {
        if (WaveInstance->WaveData)
        {
            USoundWave* SoundWave = WaveInstance->WaveData;
            if (SoundWave)
            {
                ActiveSounds.Add(SoundWave);
            }
        }
    }
}

return ActiveSounds;

}