3 #include <libraries/math_neon/math_neon.h>
7 const float sq2 = sqrtf_neon(2.0f);
17 #define max(a, b) (((a) > (b) ? a : b))
24 static void createHannWindow(
Channel &ch) {
32 createHannWindow(_window);
39 _freq[i] = ((float)i) * fs / ((float)
BLOCKSIZE);
47 _wbd[i] = channel[i] * _window[i];
48 _signal_squared[i] = _wbd[i] * _wbd[i];
51 _fft_computed =
false;
52 _delta_computed =
false;
60 for (
us i = 0; i < _wbd.size(); i++) {
61 peak = (_signal_squared[i] > peak) ? _signal_squared[i] : peak;
63 return 10 * log10f_neon(peak);
68 return 10 * log10f_neon(_ms);
75 kurtosis += _signal_squared[i] * _signal_squared[i];
85 void Features::compute_ms() {
90 ms += _signal_squared[i];
96 void Features::compute_fft() {
112 float curpeak = 0.0f;
116 _Ssq[i] = fft.fdr(i) * fft.fdr(i) + fft.fdi(i) * fft.fdi(i);
118 _fc += _Ssq[i] * _freq[i];
119 if (curpeak < _Ssq[i]) {
125 _idx_peak = idx_peak;
127 _fft_computed =
true;
131 return _freq[_idx_peak];
134 void Features::compute_delta() {
138 _absdelta[i] = fabsf_neon(_wbd[i + 1] - _wbd[i]);
141 _delta_computed =
true;
148 if (_absdelta[i] > wampl)
151 return (
float)wamp_ctr;
158 if (_wbd[i] * _wbd[i + 1] < 0 && _absdelta[i] > zcl) {
162 return (
float)zc_ctr;
168 tmp += _signal_squared[i] * (*_rawdata)[i];
175 tmp += _signal_squared[i] * _signal_squared[i] * (*_rawdata)[i];
183 float num = _Ssq_tot * _fc * _fc;
186 denom += _Ssq[i] * (_freq[i] - _fc) * (_freq[i] - _fc);