aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/fftease/src/cross~.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/fftease/src/cross~.cpp')
-rw-r--r--externals/grill/fftease/src/cross~.cpp58
1 files changed, 50 insertions, 8 deletions
diff --git a/externals/grill/fftease/src/cross~.cpp b/externals/grill/fftease/src/cross~.cpp
index e794d761..9b56d6e4 100644
--- a/externals/grill/fftease/src/cross~.cpp
+++ b/externals/grill/fftease/src/cross~.cpp
@@ -15,21 +15,39 @@ WARRANTIES, see the file, "license.txt," in this distribution.
class cross:
public fftease
{
- FLEXT_HEADER(cross,fftease)
+ FLEXT_HEADER_S(cross,fftease,setup)
public:
cross();
protected:
+ F *amps;
+ BL memory;
+
+ virtual V Set();
+ virtual V Clear();
+ virtual V Delete();
+
virtual V Transform(I _N2,S *const *in);
+
+private:
+ static V setup(t_classid c);
+
+ FLEXT_ATTRVAR_B(memory)
};
FLEXT_LIB_DSP("fftease, cross~",cross)
+V cross::setup(t_classid c)
+{
+ FLEXT_CADDATTR_VAR1(c,"memorize",memory);
+}
+
cross::cross():
- fftease(2,F_STEREO|F_BALANCED|F_BITSHUFFLE|F_CONVERT)
+ fftease(2,F_STEREO|F_BALANCED|F_BITSHUFFLE|F_NOPH2),
+ memory(true)
{
AddInSignal("Messages and driver signal");
AddInSignal("Filter signal");
@@ -37,14 +55,38 @@ cross::cross():
AddOutSignal("Transformed signal");
}
-V cross::Transform(I _N2,S *const *in)
+V cross::Clear()
+{
+ amps = NULL;
+ fftease::Clear();
+}
+
+V cross::Delete()
+{
+ fftease::Delete();
+ if(amps) delete[] amps;
+}
+
+V cross::Set()
+{
+ fftease::Set();
+ const I _N2 = get_N()/2;
+ amps = new F[_N2];
+ ZeroMem(amps,_N2*sizeof(*amps));
+}
+
+V cross::Transform(I _N,S *const *in)
{
// filled only once per signal vector!!
register const F threshie = *in[0];
+ F *amp = amps;
+
+ for (I i = 0; i <= _N; i += 2,amp++)
+ if( _channel2[i] > threshie )
+ *amp = _channel1[i] *= _channel2[i];
+ else if(memory)
+ // retrieve previous value
+ _channel1[i] = *amp;
- const I _N = _N2*2;
- for (I i = 0; i <= _N; i += 2) {
- // modulate amp2 with amp1 (if over threshold)
- if(_channel1[i] > threshie ) _channel2[i] *= _channel1[i];
- }
}
+