January 28, 2017
If you have the FX book and use the doBiquad( ) function you know that there is a check for underflow prior to writing the z^-1 value into the register:
// underflow check
if(yn > 0.0 && yn < FLT_MIN_PLUS) yn = 0;
if(yn FLT_MIN_MINUS) yn = 0;
The limits are defined in pluginconstants.h
However, the Synth Book filters use doubles instead. One of my students noticed that when filtering one-shot samples using CSampleOscillator and the CMoogLadderFilter, the CPU meter would spike at the end of the sample event. Very small values were left in the z^-1 registers, and after the sound effect, but prior to the end of the sample, some number of 0-valued samples caused the underflow issue (underflowing is documented in the FX book).
You can do the same kind of check to prevent underflow in these double-based filters with the double-version of min and max positive values, but you need to #define them (NOT in pluginconstants.h but somewhere else):
#define DBL_MIN_PLUS 2.2250738585072014e-308 /* min positive value */
#define DBL_MIN_MINUS -2.2250738585072014e-308 /* min negative value */
Then you can use the same logic code to test the values that will be written into the z^-1 registers before writing them. You will need to modify the code slightly to deal with the specific variable (yn above) that you are examining.
With the Synth Book projects we don't see this issue because we are never streaming 0's into the filters - the note off events stop the voice/filters. However, with one-shot samples that have long trailing 0's this can be an issue. Thanks to Evan Shenkman for finding this.
Most Users Ever Online: 36
Currently Online: W Pirkle
Currently Browsing this Page:
Guest Posters: 1
Newest Members:certvalue111, sobhana s, sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc
Moderators: W Pirkle: 140
Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 140