aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/fftease/src/taint~.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-01-18 04:35:33 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-01-18 04:35:33 +0000
commit9ff5ccdea43ff2a954c1a400516dc6858e188e9c (patch)
tree6098867a573275a38bf000a382752bf115af0765 /externals/grill/fftease/src/taint~.cpp
parent478eeca99ee6f5bad3063700fbcc9d8913c770ae (diff)
""
svn path=/trunk/; revision=344
Diffstat (limited to 'externals/grill/fftease/src/taint~.cpp')
-rw-r--r--externals/grill/fftease/src/taint~.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/externals/grill/fftease/src/taint~.cpp b/externals/grill/fftease/src/taint~.cpp
index 675ced1a..18b7c076 100644
--- a/externals/grill/fftease/src/taint~.cpp
+++ b/externals/grill/fftease/src/taint~.cpp
@@ -24,7 +24,7 @@ protected:
virtual V Transform(I n,S *const *in);
- V ms_thresh(F thr) { _threshold = (F)pow(10.,(_threshdB = thr)*.05); }
+ V ms_thresh(F thr) { _threshold = FromdB(_threshdB = thr); }
F _threshold,_threshdB;
BL _invert;
@@ -48,7 +48,7 @@ V taint::setup(t_classid c)
taint::taint(I argc,const t_atom *argv):
- fftease(4,F_STEREO|F_WINDOW|F_BITSHUFFLE|F_CONVERT),
+ fftease(4,F_STEREO|F_BALANCED|F_BITSHUFFLE|F_CONVERT),
_threshdB(-10),_invert(false)
{
/* parse and set object's options given */
@@ -76,22 +76,25 @@ taint::taint(I argc,const t_atom *argv):
V taint::Transform(I _N2,S *const *in)
{
- for (I i = 0; i <= _N2; i++ ) {
- const I even = i*2, odd = even + 1;
-
- const F magnitude = _channel2[even];
+ const I _N = _N2*2;
+ register const F thr = _threshold;
+
+ if(_invert) {
+ // use threshold for inverse filtering to avoid division by zero
+ for (I i = 0; i <= _N; i += 2) {
+ const F magnitude = _channel2[i];
- if(_invert) {
- // use threshold for inverse filtering to avoid division by zero
- if ( magnitude < _threshold )
- _channel1[even] = 0;
+ if ( magnitude < thr )
+ _channel1[i] = 0;
else
- _channel1[even] /= magnitude;
+ _channel1[i] /= magnitude;
}
- else {
- // simple multiplication of magnitudes
- if (magnitude > _threshold)
- _channel1[even] *= magnitude;
+ }
+ else {
+ // simple multiplication of magnitudes
+ for (I i = 0; i <= _N; i += 2) {
+ const F magnitude = _channel2[i];
+ if (magnitude > thr) _channel1[i] *= magnitude;
}
}
}