I wrote a simple DSP bitcrush effect, it loads in FMOD Studio, I can see it in the effects. The problem is, if I don’t comment out a piece from my code, it crashes instantly when trying to add the effect:
FMOD_RESULT F_CALLBACK FMOD_BitCrusher_dspcreate(FMOD_DSP_STATE* dsp_state)
{
// THIS IS THE SECTION THAT IS GIVING ME TROUBLES:
BitCrusher* state = (BitCrusher*)FMOD_DSP_ALLOC(
dsp_state,
sizeof(BitCrusher));
state->Init(dsp_state);
dsp_state->plugindata = state;
// END OF SECTION //////////////////////////////////////////
if (!state)
{
return FMOD_ERR_MEMORY;
}
return FMOD_OK;
}
That is how it is in the fmod_distance_filter.cpp example in the api, if I do this, it works:
(this is in the fmod_gain.cpp example)
FMOD_RESULT F_CALLBACK FMOD_BitCrusher_dspcreate(FMOD_DSP_STATE *dsp_state)
{
dsp_state->plugindata = (BitCrusher*)FMOD_DSP_ALLOC(dsp_state, sizeof(BitCrusher));
if (!dsp_state->plugindata)
{
return FMOD_ERR_MEMORY;
}
return FMOD_OK;
}
However, I still can’t call FMOD_DSP_GETSAMPLERATE(dsp_state, &sampleRate); anywhere in my code, except in the dspprocess/dspread methods… Which is my goal, to be able to fetch the current sample rate once when it’s created, and not at every buffer segment…