0
0

Hello ! :)

First I apologize for my bad english, I’m belgian.

I’ve a problem in using the function [i:3jityp0h][color=#FF0000:3jityp0h]FMOD_Channel_GetSpectrum[/color:3jityp0h][/i:3jityp0h], I’ve tried to use it in my program and I had errors that I didn’t understand so I made a simple code in which I only use this method but the problem is the same..

When I use this function, the first value of my float array is 0.0000 and then, every others are this unexplainable value : [b:3jityp0h][color=#FF0000:3jityp0h]-107374176.000000[/color:3jityp0h][/b:3jityp0h]

To be clear, when I print all the values of my array I’ve this :

0.000000
-107374176.000000
-107374176.000000
-107374176.000000
-107374176.000000
-107374176.000000
-107374176.000000

So here is my code :

[code:3jityp0h]#include <stdlib.h>

include <stdio.h>

include "SDL.h"

include "fmod.h"

define NBFREQUENCE 1024

int main (int argc, char* argv [])
{
int continuer = 1, iFrequence;
float frequenceMusique [NBFREQUENCE];

SDL_Surface* ecran = SDL_SetVideoMode(1024, 400, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_Event myEvent;

FMOD_SYSTEM* system;
FMOD_SOUND* musique;
FMOD_CHANNEL* channel;

FMOD_System_Create(&amp;system);

SDL_Init(SDL_INIT_VIDEO);
FMOD_System_Init(system, 16, FMOD_INIT_NORMAL, NULL);

FMOD_System_GetChannel(system, FMOD_CHANNEL_FREE, &amp;channel);
FMOD_System_CreateSound(system, &quot;musique.mp3&quot;, FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &amp;musique);
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL);

while(continuer)
{
    FMOD_Channel_GetSpectrum(channel, frequenceMusique, NBFREQUENCE, 0, FMOD_DSP_FFT_WINDOW_RECT);
    FMOD_System_Update(system);

    for(iFrequence = 0; iFrequence &lt; 512; iFrequence ++)
        {
            fprintf(stderr,&quot;%f\n&quot;, frequenceMusique[iFrequence]);
        }

    while(SDL_PollEvent(&amp;myEvent))
    {
        switch(myEvent.type)
        {
            case SDL_MOUSEBUTTONDOWN: continuer = 0;
                break;
        }
    }
}

FMOD_System_Close(system);
FMOD_System_Release(system);
SDL_Quit ();

return EXIT_SUCCESS;

}[/code:3jityp0h]

Thanks for help and sorry for my bad english ! :/

  • You must to post comments
0
0

You are not initializing the [b:192clo9g]channel[/b:192clo9g] object correctly. FMOD_Channel_GetSpectrum will be returning the value FMOD_ERR_INVALID_HANDLE which you are not checking for.

To correctly play the sound and receive the channel handle use this code, [b:192clo9g]channel[/b:192clo9g] needs to be the last argument to FMOD_System_PlaySound.
[code:192clo9g]FMOD_System_CreateSound(system, "musique.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &musique);
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, &channel);[/code:192clo9g]

  • You must to post comments
0
0

Oh yes you’re right !

Thank’s a lot and sorry for the trouble :/

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.