1 | #ifndef _LWENVELOPE_H_
|
---|
2 | #define _LWENVELOPE_H_
|
---|
3 |
|
---|
4 | #include "lwo.h"
|
---|
5 |
|
---|
6 | #include <iostream>
|
---|
7 |
|
---|
8 | class lwKey
|
---|
9 | {
|
---|
10 | public:
|
---|
11 | lwKey(float ntime, float nvalue) : time(ntime), value(nvalue) {}
|
---|
12 | float time;
|
---|
13 | float value;
|
---|
14 | unsigned int shape; /* ID_TCB, ID_BEZ2, etc. */
|
---|
15 | float tension;
|
---|
16 | float continuity;
|
---|
17 | float bias;
|
---|
18 | float param[ 4 ];
|
---|
19 | };
|
---|
20 |
|
---|
21 | typedef vector<lwKey*> vkeys;
|
---|
22 |
|
---|
23 | inline bool operator < (const lwKey &k1, const lwKey &k2)
|
---|
24 | {
|
---|
25 | return k1.time < k2.time;
|
---|
26 | }
|
---|
27 |
|
---|
28 | #define BEH_RESET 0
|
---|
29 | #define BEH_CONSTANT 1
|
---|
30 | #define BEH_REPEAT 2
|
---|
31 | #define BEH_OSCILLATE 3
|
---|
32 | #define BEH_OFFSET 4
|
---|
33 | #define BEH_LINEAR 5
|
---|
34 |
|
---|
35 | class lwEnvelope
|
---|
36 | {
|
---|
37 | float range( float v, float lo, float hi, int *i );
|
---|
38 | void hermite( float t, float *h1, float *h2, float *h3, float *h4 );
|
---|
39 | float bezier( float x0, float x1, float x2, float x3, float t );
|
---|
40 | float bez2_time( float x0, float x1, float x2, float x3, float time, float *t0, float *t1 );
|
---|
41 | float bez2( lwKey *key0, lwKey *key1, float time );
|
---|
42 | float outgoing( unsigned int key0, unsigned int key1 );
|
---|
43 | float incoming( unsigned int key0, unsigned int key1 );
|
---|
44 |
|
---|
45 | public:
|
---|
46 | lwEnvelope()
|
---|
47 | {
|
---|
48 | name = 0;
|
---|
49 | }
|
---|
50 |
|
---|
51 | ~lwEnvelope()
|
---|
52 | {
|
---|
53 | if (name) free(name);
|
---|
54 | unsigned int i;
|
---|
55 | for (i=0; i<keys.size(); delete keys[i++]);
|
---|
56 | for (i=0; i<cfilters.size(); delete cfilters[i++]);
|
---|
57 | }
|
---|
58 |
|
---|
59 | float evaluate( float time );
|
---|
60 | lwKey *addKey( float time, float value );
|
---|
61 |
|
---|
62 | int index;
|
---|
63 | int type;
|
---|
64 | char *name;
|
---|
65 | vkeys keys; /* linked list of keys */
|
---|
66 | int behavior[ 2 ]; /* pre and post (extrapolation) */
|
---|
67 | vplugins cfilters; /* linked list of channel filters */
|
---|
68 | int ncfilters;
|
---|
69 | };
|
---|
70 |
|
---|
71 | typedef vector<lwEnvelope*> venvelopes;
|
---|
72 |
|
---|
73 | #endif // _LWENVELOPE_H_
|
---|
74 |
|
---|