Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Fmod Spectrum problems

This thread is locked; no one can reply to it. rss feed Print
Fmod Spectrum problems
Albin Engström
Member #8,110
December 2006
avatar

Howdie allegators.. I'm working on a simple openGL (allegroGL) demo and It's coming along quite nicely:
http://www.allegro.cc/files/attachment/594379
http://www.allegro.cc/files/attachment/594380
http://www.allegro.cc/files/attachment/594381
(sorry for the size)

But i have a problem(duh), These effects are somewhat boring and i want to create scenes with more fluffy side content, one thing i want too do is syncing some effect with the music I'll be playing, to do this i want to get the channel spectrum from fmod to use, I've searched their forum for post on the matter but they all seem to old to work with my current version or something :S..

here's how i play a sound:

    FMOD_System_Create(&fmod_system);
    FMOD_System_Init(fmod_system, 16, 0, NULL);
    
    FMOD_System_CreateSound(fmod_system, "music.mp3", FMOD_2D, NULL, &music);

    FMOD_System_PlaySound(core->fmod_system, (FMOD_CHANNELINDEX)1, core->music, FALSE, NULL);

I hope someone has a spectrum analyzing code compatible with my code :(..

Thank you very much for your support :P.

Jakub Wasilewski
Member #3,653
June 2003
avatar

FMOD Ex has a Channel::getSpectrum method that does exactly what you want. It basically gives you a parametrized spectrum of whatever sound is playing on the channel.

I don't really know about regular FMOD, but it should have something similar, and I'm pretty sure it has some very general FFT stuff.

EDIT: A quick Google revealed regular FMOD has something called FMOD_System_GetSpectrum that is equivalent.

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Albin Engström
Member #8,110
December 2006
avatar

EDIT: I think I've gotten it to work.. NOT.

It doesn't crash now at least..
Here's a picture of the visualisation:
{"name":"594386","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/c\/6c313d7c8d357f9f84b068d6810b143d.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/c\/6c313d7c8d357f9f84b068d6810b143d"}594386

This does not move at all :S. I've read a lot about every value being 0 but i haven't found any information on this..

Hmm.. it seems to return 0.

I call FMOD_System_GetSpectrum every time i draw this.

Jakub Wasilewski
Member #3,653
June 2003
avatar

Well, it wouldn't hurt if you showed us some code, you know.

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Albin Engström
Member #8,110
December 2006
avatar

Like what sort of code? All possible code related to the spectrum has already been posted :S.

woops.. when i said it returns 0 i meant FMOD_System_GetSpectrum retuned 0 :P..

GullRaDriel
Member #3,861
September 2003
avatar

FMOD_System_GetSpectrum return something between 0 and 1, so if you cast that into an int, there is a high chance you will always got a 0

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Albin Engström
Member #8,110
December 2006
avatar

if(FMOD_System_GetSpectrum(fmod_system, spectrum, 512, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE) == 0.0f)core->running = false; is the condition valid? This closes my application as supposed to if GetSpectrum returns 0.0f.

GullRaDriel
Member #3,861
September 2003
avatar

I do not see why you use GetSpectrum to see if the song is finished or not.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Albin Engström
Member #8,110
December 2006
avatar

Edit: I got it work now :), thank you.

I don't.. i just use the core->running = false; approach to confirm things fast and easy.. when "running" is true the application will go on, when "running" is false the application will close.

Go to: