Fmod Unreal Spectrum visualizer

,

Hi everyone,
I am designing a game on Unreal 4.27 with music interactions. I am using Fmod to play the game’s music and I am trying to build a c++ actor that can analyze currently playing audio.

I saw this example in Unity : https://www.fmod.com/docs/2.01/unity/examples-spectrum-analysis.html which seems to be doing what I want to achieve.

But I am stuck pretty quickly, as I am trying to get the master Bus, here is what I’ve done so far :

SoundManager_Fmod::SoundManager_Fmod(): selectedBus()
{
	userData.studioSystem = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Runtime);
	userData.studioSystem->getCoreSystem(&userData.coreSystem);
}

int SoundManager_Fmod::initializeBus()
{
	mFFT->setParameterInt((int)FMOD_DSP_FFT_WINDOWTYPE, (int)FMOD_DSP_FFT_WINDOW_HANNING);
	mFFT->setParameterInt((int)FMOD_DSP_FFT_WINDOWSIZE,WindowSize*2);
	userData.studioSystem->flushCommands();


	const FString busPathFstring = FPaths::ProjectContentDir() + "FMOD/" + "Bus/" ;
	
	FMOD_RESULT result = userData.studioSystem->getBus(TCHAR_TO_ANSI(*busPathFstring), selectedBus);
	
	if(result == FMOD_OK)
	{
		UE_LOG(LogTemp, Warning, TEXT("It's working !"));
	}

	UE_LOG(LogTemp, Warning, TEXT("It is not working"));
	
	return 0;
	
}

Here are the .h parts :

struct UserData
{
	FMOD::System* coreSystem = nullptr;
	FMOD::Studio::System* studioSystem = nullptr;
	FString key = FString();
};

protected:
	UserData userData = UserData();
		
private:
	FMOD_STUDIO_BANK** musicBank = nullptr;
	FMOD::Studio::Bus** selectedBus = nullptr;
	FMOD::DSP* mFFT = nullptr;
	float* mFFTSpetrum;
	const int WindowSize = 1024;


	FMOD::Studio::System* system;

So apparently my method for getting the master Bus is not working as it always prints “It is not working”, what am I doing wrong ?

For info : my music is in a dedicated Bank named “Music”

Hi,

Thank you for providing the code snippets. Would it be possible to get a stripped-out version of the project to test on my side either uploaded to your Profile or DM’d to me?

The solution was changing:

	const FString busPathFstring = FPaths::ProjectContentDir() + "FMOD/" + "Bus/" ;
	
	FMOD_RESULT result = userData.studioSystem->getBus(TCHAR_TO_ANSI(*busPathFstring), selectedBus);

To:

FMOD_RESULT result = userData.studioSystem->getBus("Path to the bus in your FMOD Studio Project e.g. bus:/ExampleBus", selectedBus);