/**
 * @file filter_demo.c
 * @brief Run a step through a tool-exported Q filter, C99.
 * @copyright SPDX-License-Identifier: MIT
 * @details Place fl_filter.h and fl_q.h in the same include directory.
 */

#include "fl_filter.h"
#include <stdio.h>

/**
 * @brief Print sample index and filtered application value for a unit step.
 * @return Zero after processing 16 samples at the exported sampling rate.
 */
int main(void)
{
    Filter state;
    filter_reset(&state, 0);

    for (unsigned i = 0; i < 16u; ++i)
    {
        const double input = i < 4u ? 0.0 : 1.0;
        const FilterSample x = (FilterSample)fl_q_from_double(input, filter_q);
        const FilterSample y = filter_step(&state, x);

        printf("%u %.17g\n", i, fl_q_to_double(y, filter_q));
    }
    return 0;
}
