0

I'm using FMOD. how to use DSP getParameter function in C? when I used followed code, program shut down. I don't know what's wrong with my code. of course, I've implement DSP setParameter function. Now I have trouble at getParameter function. If someone knows this issuse, please give me a hint.

Here is my code I've tried before:

float Java_com_chocolate_player_equalizer_EQ_cGetEQCenter(JNIEnv *env, jobject thiz, 
int band)
{
    FMOD_RESULT result = FMOD_OK;
    FMOD_BOOL active = 0;

    if(!active){
        result = FMOD_System_AddDSP(gSystem, gDSPParameq[band], 0);
    }
    float * freq;
    char * valueStr = "";
    int valueStrLength = 16;

    result = FMOD_DSP_GetParameter(gDSPParameq[band], FMOD_DSP_PARAMEQ_CENTER, freq,
        valueStr, valueStrLength);

    return *freq;
}
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
choijuho
  • 75
  • 1
  • 1
  • 8

1 Answers1

0

The issue is that the FMOD function wants to write to the pointer you passed it (ie freq) but you have not given it any memory to write to, just an uninitialized value.

This would be better off as a 'float freq' instead, and then you use &freq inside your fmod function call.

You've also done the same thing with valueStr. You said the length is 16 but you only gave it memory for 0 bytes (""). Use char valueStr[16] instead. You dont do anything with it by the way, so why pass anything. Just use 0,0 for the last 2 parameters of the function.

You will also have to adjust and use return freq, rather than return *freq;