forked from interstar/WaveFlavours
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaveflavour.h
81 lines (59 loc) · 1.81 KB
/
waveflavour.h
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
#include "maximilian.h"
#ifndef TABLE_LEN
#define TABLE_LEN 512
#define GENEROUS_TABLE_LEN 514
#define SIN -100
#define RAMP -99
#define SQUARE -98
class PhaseCounter {
public :
float x, oldX, dx, max;
void start(float d, float m);
int next();
bool flipped();
bool wrapped();
};
class WaveTable {
public :
int len;
double wave[GENEROUS_TABLE_LEN];
int iRev;
PhaseCounter revTrigger;
int iInv;
PhaseCounter invTrigger;
void startCommon();
void startRamp();
void startSin(float a);
void startSquare();
void setReverseParams(int dRev, int fRev);
void setInvertParams(int dInv, int fInv);
void invert();
void reverse();
void swap(WaveTable* other, int c);
};
class Voice {
public :
WaveTable* table;
PhaseCounter p[10], offsetter;
int pitchOffsets[10];
float volume;
int noVoices,note,globalPitchOffset;
void start(WaveTable* table, int noVoices, int* pitchOffsets, float freq);
void setPitch(int note);
double next();
};
class Instrument {
// Voice plus its wavetables
public:
WaveTable table1, table2;
Voice voice;
maxiEnv env;
PhaseCounter swapTrigger;
int swapIndex;
float envAttack, envRelease, envSustain;
void start(int waveform1, int waveform2, int noVoices, int* pitchOffsets);
void setParams(int revInc, int reverse, int invInc, int invert, int swapInc, int swap, float dPhase, int globalPitchOffset);
void setEnv(float attack, float release, float sustain);
double next(int pitch, int trigger);
};
#endif