Code: Select all
bool signChanged = ((illast <= 0 && il > 0) || (illast > 0 && il <= 0)) && samples > 10;
Example pseudo code that ignores 50 samples at 10Hz and below, and ignores 10 samples at 50Hz and above. Frequency vs. ignored samples between 10Hz and 50Hz are kind of linear. (not tested)
Code: Select all
s32fp ignoreSamples = MIN(MAX(60 - FP_TOINT(Param::Get(Param::fstat)), 10), 50);
EdgeType edge = CalcRms(il1, Param::Get(Param::il1), currentMax[0], rms, samples[0], il1PrevRms, ignoreSamples);
static bool CalcRms(s32fp il, s32fp illast, s32fp& max, s32fp& rms, int& samples, s32fp prevRms, uint8_t ignoredSamples)
{
const s32fp oneOverSqrt2 = FP_FROMFLT(0.707106781187);
bool signChanged = ((illast <= 0 && il > 0) || (illast > 0 && il <= 0)) && samples > ignoredSamples;
...