0
0

Hi.

I’m trying to make a simple real-time spectrum analyzer. I’ve read a lot of topic in the forum, looking for some hints, but I still can’t get it work.

I’m new to FMOD so I don’t know if I’m doing this the right way: I set up everything to play an audio file, this way:

system->setOutput(FMOD_OUTPUTTYPE_DSOUND );
system->init(32, FMOD_INIT_NORMAL, 0);
result = system->createSound("a.mp3", FMOD_LOOP_NORMAL,NULL, &sound);
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);

Then I have the code that gets the spectrum:

result = channel->getSpectrum(spectrum, SPECTRUMSIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE);

If i put that code into a button, and i keep on pressing it while the sound is playing, i see the values of the spectrum changing.
Now, to get this done in real time, I put the code in a loop (i.e. a while loop), but the program just freeze as it starts executing the code where the getSpectrum function is.

Can anybody tell me where the problem is? Am I doing it the right way?

I’m working in Visual Studio 2010, language C++.

Thanks in advance, sorry if my english wasn’t right at all.

  • You must to post comments
0
0

I solved it by putting the getSpectrum() into a function, which I call using the Visual Studio component "Timer". So in my case the getSpectrum() gets the data every 10 milliseconds. Is it a smart solution?

Now I have to understand which/how many values of the getSpectrum’s array I must use to do a correct spectrum analysis of a song.

I will post again to let you know how far I go with my program.

  • You must to post comments
0
0

yes I tried to call it every time in the loop, but still got the same problem.

  • You must to post comments
0
0

Are you calling the FMOD System Update function periodically as well?

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.