Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Preventing underflow in filters in the Synth Book Projects
No permission to create posts
November 24, 2015
11:46 pm
W Pirkle
Forum Posts: 259
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

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.

- Will

Forum Timezone: America/New_York

Most Users Ever Online: 55

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 48

Derek: 46

Peter: 41

Frodson: 40

clau_ste: 39

Gwen: 32

JimmyM: 30

TheSmile: 28

EZB: 24

lppier: 23

Member Stats:

Guest Posters: 1

Members: 525

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 31

Topics: 550

Posts: 2158

Newest Members:

LamebrainEddy, SteveThackery, rawbirdtoe, Bill, hill william, NAUN_SONAR, sufy, Diane, Richard, drvenkman

Moderators: W Pirkle: 259

Administrators: Tom: 67, JD Young: 80, Will Pirkle: 0, W Pirkle: 259