Hello, I need help with this win32 code. When I check the return values the error comes from channel->getSpectrum and it is that I am passing an invalid parameter. I can’t figure out how to fix it though…
Here is the code

include <iostream>

include <fmod.hpp>

include <fstream>

include <fmod_errors.h>

using namespace std;

define SPECTRUMSIZE 16384

float spectrum[SPECTRUMSIZE];

int main()
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
result = FMOD::System_Create(&system);
result = system->init(32, FMOD_INIT_NORMAL, 0);
result = system->createSound("test.wav", FMOD_SOFTWARE, NULL, &sound);
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
result = channel->setVolume(1.0);

result = system-&gt;update();
result = channel-&gt;getSpectrum(spectrum, SPECTRUMSIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE);

for (int loop = 0; loop &lt; SPECTRUMSIZE; loop=loop+100)
    cout &lt;&lt; spectrum[loop] &lt;&lt; &quot; &quot;;

return 0;

Thank you

  • You must to post comments

Note you are posting in the wrong forum.
Sorry, so did this go in the fmod ex forum?

Anyways, I fixed the 16384 thing, and added a Sleep(500) before the getSpectrum call. Then I noticed that no matter how many milliseconds I slept, the data in spectrum was the same. I can’t figure out why though?

  • You must to post comments

what are you only calling it once?
I did that to reduce the length of the posted code. My actual code is much longer and calls it repeadly. I’ve made some sense of it now thankfully.

One more question though…
Is it possible to “mix” two sounds together. What I mean is can you combine two sounds into one using fmod?

  • You must to post comments

I think the question might be if you only want to get the spectrum for those 2 sounds
What I meant to say was that I’m trying to play more than 32 FMOD_DSP_TYPE_OSCILLATORs, and I don’t want any of them to get ignored. I thought maybe you could mix some together rather then giving each it’s own channel.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.