0
0

Hello everyone…
I’m a new member of this forum ( I used to read all the time as Guest ).

I search everywhere on the forum a post like mine, but I didn’t find it…
I’m sure the question has been answered a bunch of time, I’m surely not using right keyword (English is not my born language, so I might be wrong on the keyword)

Whatever…
I’m trying to get the full spectrum using the getSepctrum fonction of a song… but I only succeded when i’m playing the sound… I Haven’t when the song is not playing…

EDIT :
After reading some post, I started some stuff…
first :

[quote:1wg9atgh]
result = system->setOutput(FMOD_OUTPUTTYPE_NOSOUND_NRT);
ERRCHECK(result);

result = system->init(32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);

bool IsPlaying = false;
while (IsPlaying){
result = channel->getSpectrum(spectrum, SPECTRUMSIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE);
ERRCHECK(result);

[…]

 channel->isPlaying(&IsPlaying);
 system->update();

}
[/quote:1wg9atgh]

And I get the error :

"FMOD error! (36) An invalid object handle was used."

I can tell it is from the line :

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

Anyone can help ? thank you…

  • You must to post comments
0
0

UP : Big EDIT…

  • You must to post comments
0
0

[quote:1yawekba]"FMOD error! (36) An invalid object handle was used." [/quote:1yawekba]

It looks like you’re channel is gone. When a sound finishes playing the channel pointer is no longer valid. So if you add that condition to your while loop it should be fine.
[code:1yawekba]
while (IsPlaying && result != FMOD_ERR_INVALID_HANDLE)[/code:1yawekba]

and since you know what this error is you can add:
[code:1yawekba]if (result != FMOD_ERR_INVALID_HANDLE)
ERRCHECK(result);[/code:1yawekba]

Hope this helps,

-Petroz

  • You must to post comments
0
0

Thank you for this answer [b:2lr4h4a1]PeterStirling[/b:2lr4h4a1]

Altough I would have another question…

With readData, when you are putting the whole music on the buffer…
How can you get the spectrum of each millliseconds ?

That would be great if someone can give me the answer, because right now i’m kinda stuck, I haven’t find anywhere this answer… is it possible ?

What king of the structure is the buffer, when it is filled ?

  • You must to post comments
0
0

readData is for FMOD::Sound.

If you want the spectrum you might want to try using
Channel->getSpectrum(float * spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype);

if you want the spectrum of a single milisecond of data (assuming the sample rate is 44kHz) you would make numvalues = 44. This may not be enough data to get accurate spectrum.

  • You must to post comments
0
0

The thing is, if I use

Channel->getSpectrum(float * spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype);

I need a Channel wich is created, with the data I did read with readData.
I haven’t seen the possiblity to do that… Have I missed something ?

  • You must to post comments
0
0

Anyone can give us (I say Us because, i’m sure, i’m not the only one) some source sode about getting the whole spectrum of a sound…

Is FMOD the best option for doing that ?

  • You must to post comments
0
0

I can only say I’m interested about this as well. Though I must say I haven’t given it a try. I’m sure FMOD offers this functionality though, TheSquad. No worries. ๐Ÿ˜‰

  • You must to post comments
0
0

The only way you can do it is to use Channel::getSpectrum but you would have to process it using FMOD_OUTPUTTYPE_NOSOUND_NONRT.

  • You must to post comments
0
0

Hello,I think I have the same situation with you:
English is not my born language,
and in I my program,
I want to get the full Spectrum without playing the sound.
:)

In my initial test, the code may like these:
float *foo(unsigned int pos)
{
float *b=new float[64];
FMOD_Channel_SetMute(channel, true);
FMOD_Channel_SetPosition(channel, pos, FMOD_TIMEUNIT_MS);
FMOD_Channel_GetSpectrum(channel, b, 64, 0,
FMOD_DSP_FFT_WINDOW_RECT);
return b;
}

// in antoher function
float **b[64];
unsigned int i;
FMOD_Sound_GetLength(sound, &i,FMOD_TIMEUNIT_MS);
for (int j = 0, j<i, i++) {
b[j] = foo(j*1000); //every second
}

the code may have some problem,
because they are not the original one,
but the algorithm is effective!

Also, if you want to use this in a GUI app,
you should use multi-thread to avoid the GUI lose response .
(actually, in my test it worked very fast,
intel core T2450 2×2.0GHz, mp3:192kbps 4:13)

I hope this can help you… ๐Ÿ˜‰

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.