make helper funcs inline; drop std::span for algo
parent
660d967ec0
commit
f211f96288
@ -1,13 +1,23 @@
|
|||||||
Sample *process_data(Samples samples)
|
/**
|
||||||
|
* 6_iir_test.cpp
|
||||||
|
* Written by Clyne Sullivan.
|
||||||
|
*
|
||||||
|
* Implements a simple infinite impulse response (IIR) filter using an alpha
|
||||||
|
* parameter.
|
||||||
|
* To build upon this example, try setting `alpha` with a parameter knob:
|
||||||
|
* alpha = param1() / 4095.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
Sample* process_data(Samples samples)
|
||||||
{
|
{
|
||||||
constexpr float alpha = 0.7;
|
constexpr float alpha = 0.7;
|
||||||
|
|
||||||
static Sample prev = 2048;
|
static Sample prev = 2048;
|
||||||
|
|
||||||
samples[0] = (1 - alpha) * samples[0] + alpha * prev;
|
samples[0] = (1 - alpha) * samples[0] + alpha * prev;
|
||||||
for (unsigned int i = 1; i < samples.size(); i++)
|
for (unsigned int i = 1; i < SIZE; i++)
|
||||||
samples[i] = (1 - alpha) * samples[i] + alpha * samples[i - 1];
|
samples[i] = (1 - alpha) * samples[i] + alpha * samples[i - 1];
|
||||||
prev = samples[samples.size() - 1];
|
prev = samples[SIZE - 1];
|
||||||
|
|
||||||
return samples.data();
|
return samples;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue