Medium
A one-pole audio filter's cost after its input goes silent
This feedback filter runs once per audio sample, compiled for x86-64 with scalar SSE and the default MXCSR settings (no flush-to-zero, no denormals-are-zero). While music is playing it costs a few cycles per sample. The input then goes digitally silent, all zeros. Within a few milliseconds, process starts taking well over 10x longer per sample, and it stays that slow for as long as the input remains silent. Why?
main.cpp
float y = 0.0f;
void process(const float* in, float* out, size_t n) {
for (size_t i = 0; i < n; ++i) {
y = in[i] + 0.7f * y;
out[i] = y;
}
}41 of 47 in Computer Architecture