0
0

FSOUND_DSP_GetSpectrum() returns 0 in all of the 512 floats… can anyone help me… when i compile it plays my music but the values printed are 0. ill post the code hereunder:
[code:30w3y3la]
main()
{

float *spectrum;
FSOUND_SAMPLE *lat = 0;
FSOUND_SetBufferSize(100);
if (!FSOUND_Init(44100, 32, FSOUND_INIT_ENABLEOUTPUTFX)){

    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    system("PAUSE");
    return 1;
}

FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), true);
lat = FSOUND_Sample_Load(FSOUND_FREE, "latjavel.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0);
int channel = FSOUND_PlaySound(FSOUND_FREE, lat);
int y;

while(true){
    spectrum = FSOUND_DSP_GetSpectrum();
    if(!spectrum){return 1;}
    for(int xx=0;xx<70;xx++){
        y = (int)spectrum[xx];
            cout << y;
    }
    cout << endl;
}
getch();
return 0;

}[/code:30w3y3la]

using windows2k and dev-cpp

  • You must to post comments
0
0

I think you can’t use FX and Spectrum together like this
You should disable effects.
There is a way you can use the 2 together but I forgot it :roll:

  • You must to post comments
0
0

tested FSOUND_INIT_GLOBALFOCUS aswell, dont work there either! :(

disable effects? how and wich? im kind of anoob so i really dont know!! 😕

  • You must to post comments
0
0

I looked in the documentation and I found your problem 8)

[quote:2ymclgfk]
To use the FSOUND_FX api to do fx on channels requires FSOUND_HW2D or FSOUND_HW3D (and FSOUND_ENABLEFX) flags to work.
You may notice if you do this, you will lose the ability to do FSOUND_DSP_GetSpectrum or any DSP unit will not register, because FSOUND_FX channels play in hardware, and don’t run through the FMOD DSP Engine.

There is a way to do this though. Instead of performing EQ on a channel by channel basis, perform it on the global software mix output.

This means you can’t have per channel control, but if you are just looking for a way to do EQ on your audio for example, then use the following method.

Call FSOUND_SetBufferSize(100); When you call FSOUND_Init with FSOUND_INIT_ENABLEOUTPUTFX (see step 2) you will need a big enough software engine buffer to allow FX to be processed. FMOD defaults to 50 which is too small. This is a limitation of DirectSound and needs to be taken care of.

Use FSOUND_INIT_ENABLEOUTPUTFXin FSOUND_Init. This will ready the software engine output to have the FX api used on it.

Pause the software engine. You always need to pause the source when using FSOUND_FX_Enable (see step 3), so call FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, TRUE);

Call FSOUND_FX_Enable to create all your FX handles (EQ, distortion whatever).

Unpause the software engine. FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, FALSE);

Now you are ready! Create streams and sounds in software mode (FSOUND_NORMAL – don’t use FSOUND_HW2D or FSOUND_HW3D)

Now that all your sounds and streams are in software, you get spectrum analysis back, and also you can use the DSP engine for your own software processing or oscilliscope plotting – with the added benefit of FSOUND_FX processing!
[/quote:2ymclgfk]

  • You must to post comments
0
0

just after my post I saw that you are not using effects so you have some unneeded code

[code:hwiv46a2]
main()
{

float *spectrum; 
FSOUND_SAMPLE *lat = 0; 
FSOUND_SetBufferSize(100); 
if (!FSOUND_Init(44100, 32, 0)){ 

    printf("Error!\n"); 
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); 
    system("PAUSE"); 
    return 1; 
} 

FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), true); 
lat = FSOUND_Sample_Load(FSOUND_FREE, "latjavel.mp3", FSOUND_NORMAL | FSOUND_16BITS, 0, 0); 
int channel = FSOUND_PlaySound(FSOUND_FREE, lat); 
int y; 

while(true){ 
    spectrum = FSOUND_DSP_GetSpectrum(); 
    if(!spectrum){return 1;} 
    for(int xx=0;xx<70;xx++){ 
        y = (int)spectrum[xx]; 
            cout << y; 
    } 
    cout << endl; 
} 
getch(); 
return 0; 

}
[/code:hwiv46a2]

  • You must to post comments
0
0

ur english is ok… mine isnt so good either… i worked w/ this some time but i simply cannot understand… i read what u posted chris and i think i got a better grip of it… but i really dont inderstand the pausing ting… can u help me pls… or any one else…

[code:1rgy4q3h]main()
{
float *spectrum;
FSOUND_SAMPLE *lat = 0;
FSOUND_SetBufferSize(100);
if (!FSOUND_Init(44100, 32, FSOUND_HW2D)){

    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    system("PAUSE");
    return 1;
}
FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), true); 
int y;
FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, true);
FSOUND_FX_Enable(0, FSOUND_FX_PARAMEQ);
FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, false);
lat = FSOUND_Sample_Load(FSOUND_FREE, "latjavel.mp3", FSOUND_NORMAL | FSOUND_16BITS, 0, 0);
int channel = FSOUND_PlaySound(FSOUND_FREE, lat);

while(true){

    spectrum = FSOUND_DSP_GetSpectrum();

    if(!spectrum){return 1;}
    for(int xx=0;xx<70;xx++){
        y = (int)spectrum[xx];    
        cout << y;
    }
    cout << endl;
    if(getch() == 'a'){
        break;
    }
}
return 0;

}[/code:1rgy4q3h]

  • You must to post comments
0
0

Hi Guys!
I have this problem too with Borland C++:

float * spectrum;

FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), true);
spectrum = FSOUND_DSP_GetSpectrum();
Form1->Caption = spectrum[1];

this is alway 0 with all indexes. :( But why? Whats wrong? Please help me!

  • You must to post comments
0
0

it work now!! thank you! :)

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.