Skip to content

Commit

Permalink
Adding value filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed May 26, 2024
1 parent fa5ddfe commit 58ac4c1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pixelperfectengine/src/pixelperfectengine/audio/base/filter.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,23 @@ public struct IIRBank {
}
}
}
}
public struct CtrlValFilter {
__m128 filterLine = __m128(0);
__m128 filterCoeff = __m128([1.0, 0.0, 0.0, 0.0]);
pragma (inline, true)
float output(float targetVal) @nogc @safe pure nothrow {
filterLine[0] = targetVal;
filterLine *= filterCoeff;
filterLine[0] = filterLine[1] + filterLine[2] + filterLine[3];
filterLine = cast(__m128)_mm_slli_si128!(4)(cast(__m128i)filterLine);
return filterLine[1];
}
__m128 calculateFilterCoeff(float amount) @nogc @safe pure nothrow {
filterCoeff[0] = 1.0 - amount;
filterCoeff[1] = amount / 3.0;
filterCoeff[2] = filterCoeff[1];
filterCoeff[3] = filterCoeff[1];
return filterCoeff;
}
}

0 comments on commit 58ac4c1

Please sign in to comment.