@@ -10,6 +10,12 @@ namespace chowdsp::polyphase_fir
1010#include < stddef.h>
1111#endif
1212
13+ /* *
14+ * Object to hold the filter's persistent state.
15+ *
16+ * Users should not instantiate this object directly,
17+ * it will be provided by the `init()` method.
18+ */
1319struct Polyphase_FIR_State
1420{
1521 float * coeffs {};
@@ -21,16 +27,33 @@ struct Polyphase_FIR_State
2127 int factor {};
2228};
2329
30+ /* * Returns the number of bytes needed to construct the filter state. */
2431size_t persistent_bytes_required (int n_channels, int n_taps, int factor, int max_samples_in, int alignment);
2532
33+ /*
34+ * Initializes the filter and returns a state object.
35+ *
36+ * Note that the number of taps must be greater than or equal to 16.
37+ *
38+ * The `max_samples_in` argument is relative to the "interpolation" mode of the filter.
39+ * For "decimation", the naximum input size if `max_samples_in * factor`.
40+ *
41+ * The returned pointer will be allocated into the provided block of persistent data.
42+ * This means that you should not free the pointer since it will be freed automatically
43+ * when you free the persistent data.
44+ */
2645struct Polyphase_FIR_State * init (int n_channels, int n_taps, int factor, int max_samples_in, void * persistent_data, int alignment);
2746
47+ /* * Loads a set of filter coefficients into the filter */
2848void load_coeffs (struct Polyphase_FIR_State * state, const float * coeffs, int n_taps);
2949
50+ /* * Resets the filter state */
3051void reset (struct Polyphase_FIR_State * state);
3152
53+ /* * Returns the scratch memory required by the filter */
3254size_t scratch_bytes_required (int n_taps, int factor, int max_samples_in, int alignment);
3355
56+ /* * Process data through the "interpolation" mode of the filter */
3457void process_interpolate (struct Polyphase_FIR_State * state,
3558 const float * const * in,
3659 float * const * out,
@@ -39,6 +62,7 @@ void process_interpolate (struct Polyphase_FIR_State* state,
3962 void * scratch_data,
4063 bool use_avx);
4164
65+ /* * Process data through the "decimation" mode of the filter */
4266void process_decimate (struct Polyphase_FIR_State * state,
4367 const float * const * in,
4468 float * const * out,
0 commit comments