From d9c287d4336721d773c8a4c01588f0b7c8be984d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 16 Jan 2003 04:36:48 +0000 Subject: "" svn path=/trunk/; revision=340 --- externals/grill/fftease/src/ether~.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'externals/grill/fftease/src/ether~.cpp') diff --git a/externals/grill/fftease/src/ether~.cpp b/externals/grill/fftease/src/ether~.cpp index e04efaec..836349f3 100644 --- a/externals/grill/fftease/src/ether~.cpp +++ b/externals/grill/fftease/src/ether~.cpp @@ -46,7 +46,7 @@ V ether::setup(t_classid c) ether::ether(I argc,const t_atom *argv): - fftease(2,true,true,true), + fftease(2,F_STEREO|F_BITSHUFFLE), _qual(false),_threshMult(0),_invert(false) { /* parse and set object's options given */ @@ -58,7 +58,7 @@ ether::ether(I argc,const t_atom *argv): } _mult = _qual?4:2; - _window = _qual; + if(_qual) _flags |= F_WINDOW; AddInSignal("Messages and input signal"); AddInSignal("Reference signal"); @@ -72,36 +72,32 @@ V ether::Transform(I _N2,S *const *in) if (threshMult == 0. ) threshMult = 1; for (I i = 0; i <= _N2; i++ ) { - int even = i<<1,odd = even + 1; + const I even = i*2,odd = even + 1; - /* convert to polar coordinates from complex values */ + // convert to polar coordinates from complex values register F a,b; a = ( i == _N2 ? _buffer1[1] : _buffer1[even] ); b = ( i == 0 || i == _N2 ? 0. : _buffer1[odd] ); - _channel1[even] = hypot( a, b ); - _channel1[odd] = -atan2( b, a ); + F amp1 = hypot( a, b ); + F phase1 = -atan2( b, a ); a = ( i == _N2 ? _buffer2[1] : _buffer2[even] ); b = ( i == 0 || i == _N2 ? 0. : _buffer2[odd] ); - _channel2[even] = hypot( a, b ); - _channel2[odd] = -atan2( b, a ); + F amp2 = hypot( a, b ); + F phase2 = -atan2( b, a ); - /* use simple threshold for inverse compositing */ + // use simple threshold for inverse compositing - if(_invert?(_channel1[even] > _channel2[even]*threshMult):(_channel1[even] < _channel2[even]*threshMult) ) - _channel1[even] = _channel2[even]; + if(_invert?(amp1 > amp2*threshMult):(amp1 < amp2*threshMult) ) amp1 = amp2; + if (phase1 == 0. ) phase1 = phase2; - if (_channel1[odd] == 0. ) _channel1[odd] = _channel2[odd]; - - /* convert back to complex form, read for the inverse fft */ - _buffer1[even] = _channel1[even] * cos( _channel1[odd] ); - - if (i != _N2 ) - _buffer1[odd] = -_channel1[even] * sin( _channel1[odd] ); + // convert back to complex form, read for the inverse fft + _buffer1[even] = amp1 * cos(phase1); + if(i != _N2) _buffer1[odd] = -amp1 * sin(phase1); } } -- cgit v1.2.1