-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzMorsEngine.h
219 lines (173 loc) · 6.12 KB
/
zMorsEngine.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#ifndef zMorsEngine_h
#define zMorsEngine_h
#include <ArduinoJson.h>
#include "Arduino.h"
#include "zmModule.h"
#include "zmModuleFilter.h"
#include "zmModuleVCA.h"
#include "zmModuleMIX.h"
#include "zmModuleAD.h"
#include "zmModuleNoise.h"
#include "zmModuleOsc.h"
#include "zmModuleSeq.h"
#include "zmModuleIn.h"
#include "zmModuleOut.h"
class zMorsEngine {
public:
float bus[BUS_COUNT];
zmModule * modules[20] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
zmModuleIn * mIN ;
zmModuleOsc * mOsc1 ;
zmModuleOsc * mOsc2 ;
zmModuleNoise * mNoise ;
zmModuleMix * mMix;
zmModuleFilter * mFilter;
zmModuleVCA * mVCA ;
zmModuleSeq * mSeq ;
zmModuleOut * mOut ;
zmModuleAD * mEnv1 ;
public:
zMorsEngine() {
// create engine
mIN = new zmModuleIn();
mOsc1 = new zmModuleOsc();
mOsc2 = new zmModuleOsc();
mNoise = new zmModuleNoise();
mMix = new zmModuleMix();
mFilter = new zmModuleFilter();
mVCA = new zmModuleVCA();
mSeq = new zmModuleSeq();
mOut = new zmModuleOut();
mEnv1 = new zmModuleAD();
// wishlist
// 3. osc
// 2. env
// 2 offset/leveler
// trigger 8 x 4 gen (bin Muster as parm)
mOsc1->title="Osc1";
mOsc2->title="Osc2";
modules[0] = mIN;
modules[1] = mOsc1;
modules[2] = mOsc2;
modules[3] = mNoise;
modules[4] = mMix;
modules[5] = mFilter;
modules[6] = mEnv1;
modules[7] = mVCA;
modules[8] = mSeq;
modules[9] = mOut;
resetModules();
patch4();
mOut->portMap[PORT_OUT_R] = mOut->portMap[PORT_OUT_L];
};
void resetModules(){
for(int i =0 ; i< 10 ; i++){
modules[i]->resetModule();
}
}
void patch1() {
// BassLine
// Patch CV Sequencer
mOsc1->portMap[PORT_OSC_OUT_SAW] = mFilter->portMap[PORT_FILTER_IN] = 1;
mFilter->portMap[PORT_FILTER_OUT] = mOut->portMap[PORT_OUT_L] = mOut->portMap[PORT_OUT_R] = 2;
mOsc2->portMap[PORT_OSC_OUT_SQR] = mSeq->portMap[PORT_SEQ_CLK] = mEnv1 ->portMap[PORT_AD_TR] = 3;
mSeq->portMap[PORT_SEQ_OUT] = mFilter->portMap[PORT_FILTER_FRQ] = 4;
// Connect AD env and set osc amp to 0 (add by env)
mEnv1 ->portMap[PORT_AD_OUT] = mOsc1->portMap[PORT_OSC_AMP] = 5;
mOsc1->parameterMap[1] = 0.0;
mOsc2->parameterMap[0] = 0.0003;
mFilter->parameterMap[0] = 0.0003;
mFilter->parameterMap[1] = 0.1;
mSeq->parameterMap[0] = 0.2;
mSeq->parameterMap[1] = 0.1;
mSeq->parameterMap[2] = 0.0;
mSeq->parameterMap[3] = 0.0;
mSeq->parameterMap[4] = 0.5;
mSeq->parameterMap[5] = 0.3;
mSeq->parameterMap[6] = 0.9;
mSeq->parameterMap[7] = 0.1;
};
void patch2() {
// HiHats Seq
// Patch CV Sequencer
mNoise->portMap[PORT_NOISE_OUT] = mFilter->portMap[PORT_FILTER_IN] = 1;
mFilter->portMap[PORT_FILTER_OUT] = mOut->portMap[PORT_OUT_L] = mOut->portMap[PORT_OUT_R] = 2;
mOsc2->portMap[PORT_OSC_OUT_SQR] = mSeq->portMap[PORT_SEQ_CLK] = mEnv1 ->portMap[PORT_AD_TR] = 3;
mSeq->portMap[PORT_SEQ_OUT] = mFilter->portMap[PORT_FILTER_FRQ] = 4;
// Connect AD env and set osc amp to 0 (add by env)
mEnv1 ->portMap[PORT_AD_OUT] = mNoise->portMap[PORT_NOISE_AMP] = 5;
mOsc1->parameterMap[1] = 0.0;
mOsc2->parameterMap[0] = 0.0005;
mFilter->parameterMap[0] = 0.0003;
mFilter->parameterMap[1] = 0.1;
mSeq->parameterMap[0] = 0.4;
mSeq->parameterMap[1] = 0.0;
mSeq->parameterMap[2] = 0.3;
mSeq->parameterMap[3] = 0.0;
mSeq->parameterMap[4] = 0.5;
mSeq->parameterMap[5] = 0.0;
mSeq->parameterMap[6] = 1.1;
mSeq->parameterMap[7] = 0.8;
};
void patch3() {
// HiHats Seq
// Patch CV Sequencer
// Patch CV Sequencer
mOsc1->portMap[PORT_OSC_OUT_SIN] = mOut->portMap[PORT_OUT_L] = mOut->portMap[PORT_OUT_R] = 1;
mOsc2->portMap[PORT_OSC_OUT_SQR] = mSeq->portMap[PORT_SEQ_CLK] = mEnv1 ->portMap[PORT_AD_TR] = 3;
mEnv1->portMap[PORT_AD_OUT] = mOsc1->portMap[PORT_OSC_FRQ] = mOsc1->portMap[PORT_OSC_AMP] = 4;
// Connect AD env and set osc amp to 0 (add by env)
mSeq->portMap[PORT_SEQ_OUT] =0;
mOsc1->parameterMap[0] = 0.0020; // frq
mOsc1->parameterMap[1] = 1.0; // amp
mOsc1->parameterMap[3] = 0.016; // fm deep
mOsc2->parameterMap[0] = 0.00005;
mEnv1->parameterMap[0] = 0.000001;
mEnv1->parameterMap[1] = 0.48;
};
void patch4() {
// FM Kick
mOsc1->portMap[PORT_OSC_OUT_SIN] = mOut->portMap[PORT_OUT_L] = mOut->portMap[PORT_OUT_R] = 1;
mOsc2->portMap[PORT_OSC_OUT_SIN] = mOsc1->portMap[PORT_OSC_FRQ] = 2;
mEnv1->portMap[PORT_AD_OUT] = mOsc2->portMap[PORT_OSC_AMP] = 3;
// Connect AD env and set osc amp to 0 (add by env)
mSeq->portMap[PORT_SEQ_OUT] =0;
mOsc1->parameterMap[0] = 0.0020; // frq
mOsc1->parameterMap[1] = 1.0; // amp
mOsc1->parameterMap[3] = 0.016; // fm deep
mOsc2->parameterMap[0] = 0.00005;
mEnv1->parameterMap[0] = 0.000001;
mEnv1->parameterMap[1] = 0.48;
};
String patch2Json(){
/*
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["version"] = 1.0;
JsonArray& data = root.createNestedArray("modules");
//data.add()
*/
return String("");
};
// Render all Modules
void loop() {
for (int i = 0 ; i < 10 ; i ++) {
if (modules[i] == NULL) {
return;
}
modules[i]->genSample(&bus[0]);
bus[0] = 0.0; // Bus 0 hat keine Verbindung
}
};
// compute lineCount
int lineCount() {
int cnt = 0;
for (int i = 0 ; i < 10 ; i++) {
if (modules[i] != NULL) {
cnt += modules[i]->lineCount();
}
}
return cnt;
}
};
#endif