1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3   Copyright (C) 2019 Jean Pierre Cimalando
4 
5   Adapted from vco-plugins source code
6 */
7 /*
8   Copyright (C) 2003 Fons Adriaensen
9 
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License as published by
12   the Free Software Foundation; either version 2 of the License, or
13   (at your option) any later version.
14 
15   This program is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU General Public License for more details.
19 
20   You should have received a copy of the GNU General Public License
21   along with this program; if not, write to the Free Software
22   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24 
25 #pragma once
26 
27 class OscillatorBlepRect {
28 public:
29     void init(double sampleRate);
30     void clear();
31     void process(float *outp, const float *freq, const float *sync, const float *wavm, unsigned len);
32     void process(float *outp, const float *freq, const float *sync, unsigned len);
33     void process(float *outp, const float *freq, unsigned len);
34     void process(float *outp, float freq, unsigned len);
35 
36 private:
37     enum { NPHASE = 8, NCOEFF = 12, FILLEN = 256 };
38 
39     float   _fsam;
40     float   _p, _w, _b, _x, _y, _z, _d;
41     float   _f [FILLEN + NCOEFF];
42     int     _j, _k;
43 
44     float _filt = 1.0;
45     float _wave = 0.0;
46     float _wmod = 0.0;
47 };
48