blob: a9ede3318383efecb88961860b0df97343203db6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "ad937x_fir.h"
#include <limits>
ad937x_fir::ad937x_fir(int8_t gain, const std::vector<int16_t>& coefficients)
{
_set_gain(gain);
}
ad937x_fir::ad937x_fir(int8_t gain, std::vector<int16_t>&& coefficients)
{
set_coefficients(std::move(coefficients));
_set_gain(gain);
}
mykonosFir_t* ad937x_fir::getFir()
{
return &(_fir);
}
void ad937x_fir::set_coefficients(std::vector<int16_t>&& coefficients)
{
if (coefficients.size() < std::numeric_limits<decltype(mykonosFir_t().numFirCoefs)>::max() ||
coefficients.size() > 0)
{
// TODO: exception
}
fir_coefficients = std::move(coefficients);
_fir.numFirCoefs = static_cast<uint8_t>(fir_coefficients.size());
_fir.coefs = &fir_coefficients[0];
}
void ad937x_fir::_set_gain(int8_t gain)
{
_fir.gain_dB = gain;
}
|