I get no errors, added extra FMOD_RESULT checks and nothing fails. No other DSP are added to the channel, and the DSP count is 1 before and after I call removeDSP. The memory usage just keeps going up as more and more sound effects are played. What am I missing? Thanks!
Was able to somewhat solve it. When the channel finished playing and the callback was called the channel dsp count was 1. However when I checked the DSP in the channel the DSP at index 0 was FMOD_DSP_TYPE_FADER.
So for some reason add fadepoint or delay overwrites the FMOD_DSP_TYPE_PITCHSHIFT I had placed at index 0?
Solved it by saving the pitchshift DSP in an external map linked to the channel, and fetching and releasing the DSP from the map when the channel finished. No more memory leak for now but not sure whats going on internally with adddsp/index.
I haven’t been able to reproduce this issue, and am finding that addDSP, getDSP and removeDSP are all behaving as expected in the latest version of FMOD. I can’t determine what the relationship to fade points would be either. Can you please tell me what version of FMOD you are using?
Stashing your dsp pointer in a map seems reasonable.
If the FMOD system adds more dsps to the channel (e.g. FMOD_DSP_TYPE_FADER), that will affect the indices of everything in the dsp chain i.e. each time a DSP is added at index 0, it pushes everything else in the DSP chain down the list. Hope that makes sense.
Only strange thing with pushing the DSP down the list. This is the code I run when the channel is finished, but it only returned numDSPs = 1 (the Fader). This is before I release the PitchShift via the external map.
// Release any dsp
// Get the number of DSPs attached to the channel
int numDSPs = 0;
FMOD_RESULT result = channel->getNumDSPs(&numDSPs);
// Iterate over all DSPs and release them
for (int i = 0; i < numDSPs; ++i) {
FMOD::DSP* dsp = nullptr;
channel->getDSP(i, &dsp);
if (dsp != nullptr) {
channel->removeDSP(dsp);
dsp->release();
}
}