Epple-II/src/filterchroma.cpp
2019-01-27 14:36:25 -05:00

44 lines
1.4 KiB
C++

/*
epple2
Copyright (C) 2008 by Christopher A. Mosher <cmosher01@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY, without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filterchroma.h"
/*
Generated by the utility at http://www-users.cs.york.ac.uk/~fisher/mkfilter
3rd order low-pass Butterworth filter at 1500000 Hz.
(sample rate 14318182 Hz)
*/
#define GAIN 4.910093226e+01
FilterChroma::FilterChroma() {
xv[0]=xv[1]=xv[2]=xv[3]=0;
yv[0]=yv[1]=yv[2]=yv[3]=0;
}
FilterChroma::~FilterChroma() {
}
float FilterChroma::next(const float v) {
xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3];
xv[3] = v / GAIN;
yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3];
yv[3] = (xv[0] + xv[3]) + 3 * (xv[1] + xv[2])
+ ( 0.2608994296 * yv[0]) + ( -1.1262209208 * yv[1])
+ ( 1.7023917944 * yv[2]);
return yv[3];
}