1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
FFTease - A set of Live Spectral Processors
Originally written by Eric Lyon and Christopher Penrose for the Max/MSP platform
Copyright (c)Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
#include "main.h"
class cross:
public 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("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_NOPH2),
memory(true)
{
AddInSignal("Messages and driver signal");
AddInSignal("Filter signal");
AddInSignal("Threshold signal for cross synthesis");
AddOutSignal("Transformed signal");
}
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;
}
|