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.