Answered
0
0

Hi, I work on Fmodex and I need to get the spectrum of a music. My code is not very difficult but didn’t work. I get 0.00026 for the first value if the spectrum array is 512 and 0.00051 if it is 1024 but every values else are 0.00000.
Here my program :

int main()
{

FMOD_SYSTEM *system;
FMOD_SOUND *musique;
FMOD_CHANNEL *canal;

FMOD_System_Create(&system);
FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);

int a = 1024;
int i;
float spectre[a];
for (i = 0; i < a; i++)
{
    spectre[i] = 0;                      /*Array initialisation */
}

/* Open musique */
FMOD_System_CreateSound(system, "More_Than_Seven.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &musique);

/* Play music */
FMOD_System_PlaySound(system, 0, musique, 0, &canal);
FMOD_Channel_SetVolume(canal, 1.0);

/* Wait a little bit */
Sleep(1500);

/* Get the spectrum*/
FMOD_Channel_GetSpectrum(canal, spectre, a, 0,  FMOD_DSP_FFT_WINDOW_RECT);

/* File */
FILE* fichier = NULL;
fichier = fopen("spectre.txt", "w");

/* Write values in the file */
for(i = 0 ; i < a ; i++)
{
    fprintf(fichier, "%d : %f \n", i, spectre[i]);
}
fclose(fichier);

Sleep(300000);

return 0;

}

Thank’s,
Baptiste.

  • You must to post comments
Best Answer
0
0

No it’s okay, like I said, my value were so low that i had to multiply them by 2×10^8 that’s why i didn’t see them first because my program printed only the first five decimals. Problem solved. Thank’s anyway.
Sorry for my poor english,
Baptiste.

  • You must to post comments
0
0

Ok so I multiplied spectre[i] by 200000000 an my values appears.

  • You must to post comments
0
0

You took a snapshot only 1.5 seconds after the sound started. Is it possible it is fading in and very quiet at that point? You’re supposed to collect a lot of samples and either work out an average or write out data at various points through the sound.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.