2 Copyright (C) 2003-2008 Fons Adriaensen <fons@kokkinizita.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "ardour/mtdm.h"
40 for (i
= 0, F
= _freq
; i
< 5; i
++, F
++) {
48 MTDM::process (size_t len
, float *ip
, float *op
)
51 float vip
, vop
, a
, c
, s
;
58 for (i
= 0, F
= _freq
; i
< 5; i
++, F
++)
60 a
= 2 * (float) M_PI
* (F
->p
& 65535) / 65536.0;
71 for (i
= 0, F
= _freq
; i
< 5; i
++, F
++)
73 F
->xf
+= 1e-3f
* (F
->xa
- F
->xf
+ 1e-20);
74 F
->yf
+= 1e-3f
* (F
->ya
- F
->yf
+ 1e-20);
91 if (hypot (F
->xf
, F
->yf
) < 0.01) {
95 d
= atan2 (F
->yf
, F
->xf
) / (2 * M_PI
);
109 for (i
= 0; i
< 4; i
++) {
111 p
= atan2 (F
->yf
, F
->xf
) / (2 * M_PI
) - d
* F
->f
/ f0
;
117 k
= (int)(floor (p
+ 0.5));