Get Fmod Studio tracks order c++

I could get each tracks rms level using ChannelGroup.

But I can’t get Fmod Studio Tracks order.
How can I get the order of Studio?

Thanks in advance
using UE4.25
Here is source code.

.H
TArrayFMOD::ChannelGroup* ChannelGroupArray;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FMOD", meta = (AllowPrivateAccess = "true"))
TArray<class UFMODEvent*>	EventArray;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FMOD", meta = (AllowPrivateAccess = "true"))
TArray<FString>				EventNameArray;


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FMOD", meta = (AllowPrivateAccess = "true"))
TArray<float>	TrackLeftRMSVolumeArray;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FMOD", meta = (AllowPrivateAccess = "true"))
TArray<float>	TrackRightRMSVolumeArray;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FMOD", meta = (AllowPrivateAccess = "true"))
TArray<FString>	TrackName;

.CPP
int ChannelCount = 0;

pChannelGroup->getNumGroups(&ChannelGroupCount);

for (int i = 0; i < ChannelGroupCount; ++i)
{
	FMOD::ChannelGroup* SubGroup = nullptr;
	pChannelGroup->getGroup(i, &SubGroup);

	char	ChannelName[128] = {};
	SubGroup->getName(ChannelName, 128);

	FString	NameStr = ChannelName;

	TrackName.Add(NameStr);

	//GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Red, NameStr);

	ChannelGroupArray.Add(SubGroup);

	TrackLeftRMSVolumeArray.Add(0.f);
	TrackRightRMSVolumeArray.Add(0.f);

	FMOD::DSP* pSubDSP = nullptr;

	SubGroup->getDSP(0, &pSubDSP);

	DSPArray.Add(pSubDSP);

	ErrCheck(pSubDSP->setMeteringEnabled(true, true), TEXT("setMeteringEnabled"));
}


unreal

Unfortunately the track order is immaterial to the API so there is no easy way to get the order of tracks as they appear in FMOD Studio. If you let me know what the high level concept is that you’re trying to achieve here / why you need the track order, I can help come up with a workaround?

I just want to check which instrument(tracks in studio) is getting metering.
I want to use each track’s metering data but When I add tracks in studio, order of Array(in UE) is changing.
Or can i get the name of tracks?

Thanks for feedback.

After digging around through our API, I haven’t found any easy way to get the name of a track- ChannelGroup::getName() doesn’t return the name of the track, and as you have found the track order can change any time and has no relationship to the track order in Studio.
At this time I don’t think there is any direct way of achieving what you are after. That said, I can see that individual track metering info isn’t useful by itself so there really should be some kind of identifier letting you know where it came from; I will add it as a suggestion and hopefully get it added in a future release.

I got it. I will be helpful if you add in future release.
Thanks

I think this is exactly what I am after too. I need something to identifier a Channel in Code (Unreal Engine 5.2), if it is the index that is equal to the order of the events(although this is dangerous), the name of the track you entered in fmod or another variable you can set in fmod, a number or a string field.

Perhaps you could try setting User Properties to map the audio file names on each instrument to their respective tracks in the event?


It would be a little fiddly with high track or asset counts, but this would allow you to identify the track each sound is playing back on. Here is an example of how you might access the user properties at runtime via an FMOD_STUDIO_EVENT_CALLBACK_SOUND_PLAYED callback:

FMOD_RESULT CallbackSoundStarted(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE *event, void *parameters)
{
    FMOD::Studio::EventInstance    *instance = (FMOD::Studio::EventInstance *)event;
    FMOD::Sound                    *sound    = (FMOD::Sound *)parameters;
    FMOD::Studio::EventDescription *description;
    FMOD_STUDIO_USER_PROPERTY       prop;
    int                             numproperties;

    instance->getDescription(&description);
    description->getUserPropertyCount(&numproperties);

    for (int i = 0; i < numproperties; ++i)
    {  
        description->getUserPropertyByIndex(i, &prop);
        if (prop.type == FMOD_STUDIO_USER_PROPERTY_TYPE_STRING)
        {
            char name[256];
            sound->getName(name, 256);

            if (strstr(name, prop.stringvalue) != NULL)
            {
                UE_LOG(LogFMOD, Display, TEXT("%s playing back on %s track."),
                    UTF8_TO_TCHAR(name), UTF8_TO_TCHAR(prop.name));
            }
        }
    }
    return FMOD_OK;
}