IIRCoefficients copying


#1

Hi There, 

I'm trying to grab the coefficients from an IIRFilter object to use for calculating magnitudes to plot the frequency response of the filter. The filter works fine, passes audio and does exactly what it should do.

The class offers a function getCoefficients(), which should return an IIRCoefficients object containing the Filters coefficient object.

The function gets called, but I get a exc_bad_access error when assigning them to the new IIRCoefficents object. 

I've tried pretty much every concievable way to get this working, with no joy. I've tried assigning to a float array, pointers etc.

 

For example. I create the new IIRCoefficient object like this :

IIRCoefficients filterCoefs = eqHP.getCoefficients();

but I get the exc error called on memcpy function below:

IIRCoefficients::IIRCoefficients (const IIRCoefficients& other) noexcept

{

    memcpy (coefficients, other.coefficients, sizeof (coefficients));

}

Has anyone come across this ? and if so could you be so kind as to share the correct way of doing this.

 

Cheers


#2

Presumably your "eqHP" object is a dangling or null pointer?


#3

Thats what I would have thought, however the object passes audio and does it job to spec, updates its coefficents, filters the audio etc..  until I request the coefficents from it and try to copy them into the new object.

I'll keep debugging but if theres any ideas, greatfully accepted.. 

 


#4

Well, there's definitely nothing wrong with the basics of the IIRCoefficients class, so if there's a memory error it can only be because you're calling methods on an pointer to an object that doesn't exist. Check your threading - perhaps another thread has just deleted the object before you call this.


#5

You were right about that threading. I restructured and its working fine. Thanks for the support.