2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //third party Phase Vocoder UGens
24 #include "FFT_UGens.h"
29 void PV_ConformalMap_Ctor(PV_Unit
*unit
);
30 void PV_ConformalMap_next(PV_Unit
*unit
, int inNumSamples
);
34 void PV_ConformalMap_Ctor(PV_Unit
*unit
)
36 SETCALC(PV_ConformalMap_next
);
41 void PV_ConformalMap_next(PV_Unit
*unit
, int inNumSamples
)
45 SCComplexBuf
*p
= ToComplexApx(buf
);
47 float real2
= ZIN0(1);
48 float imag2
= ZIN0(2);
50 for (int i
=0; i
<numbins
; ++i
) {
51 float real1
= p
->bin
[i
].real
;
52 float imag1
= p
->bin
[i
].imag
;
54 //apply conformal map z-> z-a/(1-za*) where z is the existing complex number in the bin and a is defined by inputs 1 and 2
55 float numr
= real1
-real2
;
56 float numi
= imag1
-imag2
;
57 float denomr
= 1.f
- (real1
*real2
+imag1
*imag2
);
58 float denomi
= (real1
*imag2
- real2
*imag1
);
60 numr
= numr
*denomr
+numi
*denomi
;
61 numi
= numi
*denomr
-numr
*denomi
;
64 denomr
= denomr
*denomr
+denomi
*denomi
;
66 //avoid possible divide by zero
67 if(denomr
<0.001f
) denomr
=0.001f
;
70 p
->bin
[i
].real
= numr
*denomr
;
71 p
->bin
[i
].imag
= numi
*denomr
;
77 #define DefinePVUnit(name) \
78 (*ft->fDefineUnit)(#name, sizeof(PV_Unit), (UnitCtorFunc)&name##_Ctor, 0, 0);
81 //void initPV_ThirdParty(InterfaceTable *it);
82 void initPV_ThirdParty(InterfaceTable
*it
)
84 DefinePVUnit(PV_ConformalMap
);