FFT Spectrum nullPtr

Hello there,
Can you even look at my code something can not be right since .

I always bekomm the error message FFT what nullptr .

#pragma comment(lib,"fmod64_vc.lib")

using namespace std;

FMOD::System* fmodSystem;    
FMOD::Sound *music;
FMOD::Channel* musicChannel = 0;
FMOD_RESULT result;
FMOD::DSP *dsp1;
FMOD_DSP_PARAMETER_FFT *fft;

int fmodini()
{
	if (FAILED(result = FMOD::System_Create(&fmodSystem))) {
		MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
	}

	if (FAILED(result = fmodSystem->init(32, FMOD_INIT_NORMAL, NULL))) {
		MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
	}

	if (FAILED(result = fmodSystem->createStream("Hawaii5O.mp3", FMOD_DEFAULT, 0, &music))) {
		MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
	}

	if (FAILED(result = fmodSystem->playSound(music, 0, false, &musicChannel))) {
		MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
	}

	fmodSystem->createDSPByType(FMOD_DSP_TYPE::FMOD_DSP_TYPE_FFT, &dsp1);
	musicChannel->addDSP(FMOD_DSP_PARAMETER_DATA_TYPE_FFT, dsp1);
	dsp1->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)fft, 0, 0, 0);


	return 0;
}

Always in accessing the variable * fft I get the error message .

As a rule you should check the return code of all FMOD functions.

Channel::addDSP will be returning INVALID_PARAM because the first argument is wrong. It specifies the position in the DSP chain to add, not the DSP type.

Try

result = musicChannel->addDSP(FMOD_CHANNELCONTROL_DSP_HEAD, dsp1);

Which places the DSP at the head of the channels effect chain.

Thanks for the help.
I have modified the code and have carried out a test
the result.

float test = FFT > lenght ;

result = FFT > lenght < Unable to read memory >

result = FFT > numChannels < Unable to read memory >

fft was nullptr.

OK thanks for the help.
Have solved the problem .

When you enter this code
result = dsp1- > getParameterData ( FMOD_DSP_FFT_SPECTRUMDATA , (void ** ) & FFT , 0 , 0 , 0 ) ;

Must be a ( & ) character before the pointer ( * FFT ) are set .
Without it does not go with me .

I need a little help again .

I get all zeros as output .

if (FAILED(result = dsp1->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)&fft, 0, 0, 0))) {
MessageBox(NULL, “Failed”, “Failed”, MB_OK | MB_ICONEXCLAMATION);
}

for (int channel = 0; channel < fft->numchannels; channel++) {
	for (int lenght = 0; lenght < fft->length; lenght++) {
		fmoddata = fft->spectrum[channel][lenght];
	}
}


result=fmodSystem->update();

Thank you have the problem found .

Did reading the data easy in the message loop in mainthread called and so the data is read continuously , and are no longer zero .

You need to let the sound play and read the spectrum continuously.

Whit this code,I get all zeros.

dsp1->setBypass(false);
dsp1->setActive(TRUE);

if (FAILED(result = FMOD::System_Create(&fmodSystem))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}

if (FAILED(result = fmodSystem->init(32, FMOD_INIT_NORMAL, NULL))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}

if (FAILED(result = fmodSystem->createStream("Hawaii5O.mp3", FMOD_DEFAULT, 0, &music))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}

if (FAILED(result = fmodSystem->playSound(music, 0,FALSE, &musicChannel))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}
if (FAILED(result = fmodSystem->createDSPByType(FMOD_DSP_TYPE::FMOD_DSP_TYPE_FFT, &dsp1))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}
if (FAILED(result = musicChannel->addDSP(FMOD_DSP_PARAMETER_DATA_TYPE_FFT, dsp1))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}

if (FAILED(result = dsp1->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)&fft, 0, 0,0))) {
	MessageBox(NULL, "Failed", "Failed", MB_OK | MB_ICONEXCLAMATION);
}

for (int channel = 0; channel < fft->numchannels; channel++) {
	for (int lenght = 0; lenght < fft->length; lenght++) {
		fmoddata = fft->spectrum[channel][lenght];
	}
}
fmodSystem->update();

The sound runs.