-
Notifications
You must be signed in to change notification settings - Fork 2
/
grids_resouces.ino
483 lines (466 loc) · 24.4 KB
/
grids_resouces.ino
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
/*
all of the below (without comments) is a direct copy-and-paste from
https://github.com/pichenettes/eurorack/tree/master/grids
resources.cc and further down also: pattern_generator.cc
*/
#ifndef prog_uint8_t
#define prog_uint8_t uint8_t
#endif
const prog_uint8_t node_0[] PROGMEM = {
255, 0, 0, 0, 0, 0, 145, 0,
0, 0, 0, 0, 218, 0, 0, 0,
72, 0, 36, 0, 182, 0, 0, 0,
109, 0, 0, 0, 72, 0, 0, 0,
36, 0, 109, 0, 0, 0, 8, 0,
255, 0, 0, 0, 0, 0, 72, 0,
0, 0, 182, 0, 0, 0, 36, 0,
218, 0, 0, 0, 145, 0, 0, 0,
170, 0, 113, 0, 255, 0, 56, 0,
170, 0, 141, 0, 198, 0, 56, 0,
170, 0, 113, 0, 226, 0, 28, 0,
170, 0, 113, 0, 198, 0, 85, 0,
};
const prog_uint8_t node_1[] PROGMEM = {
229, 0, 25, 0, 102, 0, 25, 0,
204, 0, 25, 0, 76, 0, 8, 0,
255, 0, 8, 0, 51, 0, 25, 0,
178, 0, 25, 0, 153, 0, 127, 0,
28, 0, 198, 0, 56, 0, 56, 0,
226, 0, 28, 0, 141, 0, 28, 0,
28, 0, 170, 0, 28, 0, 28, 0,
255, 0, 113, 0, 85, 0, 85, 0,
159, 0, 159, 0, 255, 0, 63, 0,
159, 0, 159, 0, 191, 0, 31, 0,
159, 0, 127, 0, 255, 0, 31, 0,
159, 0, 127, 0, 223, 0, 95, 0,
};
const prog_uint8_t node_2[] PROGMEM = {
255, 0, 0, 0, 127, 0, 0, 0,
0, 0, 102, 0, 0, 0, 229, 0,
0, 0, 178, 0, 204, 0, 0, 0,
76, 0, 51, 0, 153, 0, 25, 0,
0, 0, 127, 0, 0, 0, 0, 0,
255, 0, 191, 0, 31, 0, 63, 0,
0, 0, 95, 0, 0, 0, 0, 0,
223, 0, 0, 0, 31, 0, 159, 0,
255, 0, 85, 0, 148, 0, 85, 0,
127, 0, 85, 0, 106, 0, 63, 0,
212, 0, 170, 0, 191, 0, 170, 0,
85, 0, 42, 0, 233, 0, 21, 0,
};
const prog_uint8_t node_3[] PROGMEM = {
255, 0, 212, 0, 63, 0, 0, 0,
106, 0, 148, 0, 85, 0, 127, 0,
191, 0, 21, 0, 233, 0, 0, 0,
21, 0, 170, 0, 0, 0, 42, 0,
0, 0, 0, 0, 141, 0, 113, 0,
255, 0, 198, 0, 0, 0, 56, 0,
0, 0, 85, 0, 56, 0, 28, 0,
226, 0, 28, 0, 170, 0, 56, 0,
255, 0, 231, 0, 255, 0, 208, 0,
139, 0, 92, 0, 115, 0, 92, 0,
185, 0, 69, 0, 46, 0, 46, 0,
162, 0, 23, 0, 208, 0, 46, 0,
};
const prog_uint8_t node_4[] PROGMEM = {
255, 0, 31, 0, 63, 0, 63, 0,
127, 0, 95, 0, 191, 0, 63, 0,
223, 0, 31, 0, 159, 0, 63, 0,
31, 0, 63, 0, 95, 0, 31, 0,
8, 0, 0, 0, 95, 0, 63, 0,
255, 0, 0, 0, 127, 0, 0, 0,
8, 0, 0, 0, 159, 0, 63, 0,
255, 0, 223, 0, 191, 0, 31, 0,
76, 0, 25, 0, 255, 0, 127, 0,
153, 0, 51, 0, 204, 0, 102, 0,
76, 0, 51, 0, 229, 0, 127, 0,
153, 0, 51, 0, 178, 0, 102, 0,
};
const prog_uint8_t node_5[] PROGMEM = {
255, 0, 51, 0, 25, 0, 76, 0,
0, 0, 0, 0, 102, 0, 0, 0,
204, 0, 229, 0, 0, 0, 178, 0,
0, 0, 153, 0, 127, 0, 8, 0,
178, 0, 127, 0, 153, 0, 204, 0,
255, 0, 0, 0, 25, 0, 76, 0,
102, 0, 51, 0, 0, 0, 0, 0,
229, 0, 25, 0, 25, 0, 204, 0,
178, 0, 102, 0, 255, 0, 76, 0,
127, 0, 76, 0, 229, 0, 76, 0,
153, 0, 102, 0, 255, 0, 25, 0,
127, 0, 51, 0, 204, 0, 51, 0,
};
const prog_uint8_t node_6[] PROGMEM = {
255, 0, 0, 0, 223, 0, 0, 0,
31, 0, 8, 0, 127, 0, 0, 0,
95, 0, 0, 0, 159, 0, 0, 0,
95, 0, 63, 0, 191, 0, 0, 0,
51, 0, 204, 0, 0, 0, 102, 0,
255, 0, 127, 0, 8, 0, 178, 0,
25, 0, 229, 0, 0, 0, 76, 0,
204, 0, 153, 0, 51, 0, 25, 0,
255, 0, 226, 0, 255, 0, 255, 0,
198, 0, 28, 0, 141, 0, 56, 0,
170, 0, 56, 0, 85, 0, 28, 0,
170, 0, 28, 0, 113, 0, 56, 0,
};
const prog_uint8_t node_7[] PROGMEM = {
223, 0, 0, 0, 63, 0, 0, 0,
95, 0, 0, 0, 223, 0, 31, 0,
255, 0, 0, 0, 159, 0, 0, 0,
127, 0, 31, 0, 191, 0, 31, 0,
0, 0, 0, 0, 109, 0, 0, 0,
218, 0, 0, 0, 182, 0, 72, 0,
8, 0, 36, 0, 145, 0, 36, 0,
255, 0, 8, 0, 182, 0, 72, 0,
255, 0, 72, 0, 218, 0, 36, 0,
218, 0, 0, 0, 145, 0, 0, 0,
255, 0, 36, 0, 182, 0, 36, 0,
182, 0, 0, 0, 109, 0, 0, 0,
};
const prog_uint8_t node_8[] PROGMEM = {
255, 0, 0, 0, 218, 0, 0, 0,
36, 0, 0, 0, 218, 0, 0, 0,
182, 0, 109, 0, 255, 0, 0, 0,
0, 0, 0, 0, 145, 0, 72, 0,
159, 0, 0, 0, 31, 0, 127, 0,
255, 0, 31, 0, 0, 0, 95, 0,
8, 0, 0, 0, 191, 0, 31, 0,
255, 0, 31, 0, 223, 0, 63, 0,
255, 0, 31, 0, 63, 0, 31, 0,
95, 0, 31, 0, 63, 0, 127, 0,
159, 0, 31, 0, 63, 0, 31, 0,
223, 0, 223, 0, 191, 0, 191, 0,
};
const prog_uint8_t node_9[] PROGMEM = {
226, 0, 28, 0, 28, 0, 141, 0,
8, 0, 8, 0, 255, 0, 8, 0,
113, 0, 28, 0, 198, 0, 85, 0,
56, 0, 198, 0, 170, 0, 28, 0,
8, 0, 95, 0, 8, 0, 8, 0,
255, 0, 63, 0, 31, 0, 223, 0,
8, 0, 31, 0, 191, 0, 8, 0,
255, 0, 127, 0, 127, 0, 159, 0,
115, 0, 46, 0, 255, 0, 185, 0,
139, 0, 23, 0, 208, 0, 115, 0,
231, 0, 69, 0, 255, 0, 162, 0,
139, 0, 115, 0, 231, 0, 92, 0,
};
const prog_uint8_t node_10[] PROGMEM = {
145, 0, 0, 0, 0, 0, 109, 0,
0, 0, 0, 0, 255, 0, 109, 0,
72, 0, 218, 0, 0, 0, 0, 0,
36, 0, 0, 0, 182, 0, 0, 0,
0, 0, 127, 0, 159, 0, 127, 0,
159, 0, 191, 0, 223, 0, 63, 0,
255, 0, 95, 0, 31, 0, 95, 0,
31, 0, 8, 0, 63, 0, 8, 0,
255, 0, 0, 0, 145, 0, 0, 0,
182, 0, 109, 0, 109, 0, 109, 0,
218, 0, 0, 0, 72, 0, 0, 0,
182, 0, 72, 0, 182, 0, 36, 0,
};
const prog_uint8_t node_11[] PROGMEM = {
255, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
255, 0, 0, 0, 218, 0, 72, 36,
0, 0, 182, 0, 0, 0, 145, 109,
0, 0, 127, 0, 0, 0, 42, 0,
212, 0, 0, 212, 0, 0, 212, 0,
0, 0, 0, 0, 42, 0, 0, 0,
255, 0, 0, 0, 170, 170, 127, 85,
145, 0, 109, 109, 218, 109, 72, 0,
145, 0, 72, 0, 218, 0, 109, 0,
182, 0, 109, 0, 255, 0, 72, 0,
182, 109, 36, 109, 255, 109, 109, 0,
};
const prog_uint8_t node_12[] PROGMEM = {
255, 0, 0, 0, 255, 0, 191, 0,
0, 0, 0, 0, 95, 0, 63, 0,
31, 0, 0, 0, 223, 0, 223, 0,
0, 0, 8, 0, 159, 0, 127, 0,
0, 0, 85, 0, 56, 0, 28, 0,
255, 0, 28, 0, 0, 0, 226, 0,
0, 0, 170, 0, 56, 0, 113, 0,
198, 0, 0, 0, 113, 0, 141, 0,
255, 0, 42, 0, 233, 0, 63, 0,
212, 0, 85, 0, 191, 0, 106, 0,
191, 0, 21, 0, 170, 0, 8, 0,
170, 0, 127, 0, 148, 0, 148, 0,
};
const prog_uint8_t node_13[] PROGMEM = {
255, 0, 0, 0, 0, 0, 63, 0,
191, 0, 95, 0, 31, 0, 223, 0,
255, 0, 63, 0, 95, 0, 63, 0,
159, 0, 0, 0, 0, 0, 127, 0,
72, 0, 0, 0, 0, 0, 0, 0,
255, 0, 0, 0, 0, 0, 0, 0,
72, 0, 72, 0, 36, 0, 8, 0,
218, 0, 182, 0, 145, 0, 109, 0,
255, 0, 162, 0, 231, 0, 162, 0,
231, 0, 115, 0, 208, 0, 139, 0,
185, 0, 92, 0, 185, 0, 46, 0,
162, 0, 69, 0, 162, 0, 23, 0,
};
const prog_uint8_t node_14[] PROGMEM = {
255, 0, 0, 0, 51, 0, 0, 0,
0, 0, 0, 0, 102, 0, 0, 0,
204, 0, 0, 0, 153, 0, 0, 0,
0, 0, 0, 0, 51, 0, 0, 0,
0, 0, 0, 0, 8, 0, 36, 0,
255, 0, 0, 0, 182, 0, 8, 0,
0, 0, 0, 0, 72, 0, 109, 0,
145, 0, 0, 0, 255, 0, 218, 0,
212, 0, 8, 0, 170, 0, 0, 0,
127, 0, 0, 0, 85, 0, 8, 0,
255, 0, 8, 0, 170, 0, 0, 0,
127, 0, 0, 0, 42, 0, 8, 0,
};
const prog_uint8_t node_15[] PROGMEM = {
255, 0, 0, 0, 0, 0, 0, 0,
36, 0, 0, 0, 182, 0, 0, 0,
218, 0, 0, 0, 0, 0, 0, 0,
72, 0, 0, 0, 145, 0, 109, 0,
36, 0, 36, 0, 0, 0, 0, 0,
255, 0, 0, 0, 182, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 109,
218, 0, 0, 0, 145, 0, 72, 72,
255, 0, 28, 0, 226, 0, 56, 0,
198, 0, 0, 0, 0, 0, 28, 28,
170, 0, 0, 0, 141, 0, 0, 0,
113, 0, 0, 0, 85, 85, 85, 85,
};
const prog_uint8_t node_16[] PROGMEM = {
255, 0, 0, 0, 0, 0, 95, 0,
0, 0, 127, 0, 0, 0, 0, 0,
223, 0, 95, 0, 63, 0, 31, 0,
191, 0, 0, 0, 159, 0, 0, 0,
0, 0, 31, 0, 255, 0, 0, 0,
0, 0, 95, 0, 223, 0, 0, 0,
0, 0, 63, 0, 191, 0, 0, 0,
0, 0, 0, 0, 159, 0, 127, 0,
141, 0, 28, 0, 28, 0, 28, 0,
113, 0, 8, 0, 8, 0, 8, 0,
255, 0, 0, 0, 226, 0, 0, 0,
198, 0, 56, 0, 170, 0, 85, 0,
};
const prog_uint8_t node_17[] PROGMEM = {
255, 0, 0, 0, 8, 0, 0, 0,
182, 0, 0, 0, 72, 0, 0, 0,
218, 0, 0, 0, 36, 0, 0, 0,
145, 0, 0, 0, 109, 0, 0, 0,
0, 0, 51, 25, 76, 25, 25, 0,
153, 0, 0, 0, 127, 102, 178, 0,
204, 0, 0, 0, 0, 0, 255, 0,
0, 0, 102, 0, 229, 0, 76, 0,
113, 0, 0, 0, 141, 0, 85, 0,
0, 0, 0, 0, 170, 0, 0, 0,
56, 28, 255, 0, 0, 0, 0, 0,
198, 0, 0, 0, 226, 0, 0, 0,
};
const prog_uint8_t node_18[] PROGMEM = {
255, 0, 8, 0, 28, 0, 28, 0,
198, 0, 56, 0, 56, 0, 85, 0,
255, 0, 85, 0, 113, 0, 113, 0,
226, 0, 141, 0, 170, 0, 141, 0,
0, 0, 0, 0, 0, 0, 0, 0,
255, 0, 0, 0, 127, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
63, 0, 0, 0, 191, 0, 0, 0,
255, 0, 0, 0, 255, 0, 127, 0,
0, 0, 85, 0, 0, 0, 212, 0,
0, 0, 212, 0, 42, 0, 170, 0,
0, 0, 127, 0, 0, 0, 0, 0,
};
const prog_uint8_t node_19[] PROGMEM = {
255, 0, 0, 0, 0, 0, 218, 0,
182, 0, 0, 0, 0, 0, 145, 0,
145, 0, 36, 0, 0, 0, 109, 0,
109, 0, 0, 0, 72, 0, 36, 0,
0, 0, 0, 0, 109, 0, 8, 0,
72, 0, 0, 0, 255, 0, 182, 0,
0, 0, 0, 0, 145, 0, 8, 0,
36, 0, 8, 0, 218, 0, 182, 0,
255, 0, 0, 0, 0, 0, 226, 0,
85, 0, 0, 0, 141, 0, 0, 0,
0, 0, 0, 0, 170, 0, 56, 0,
198, 0, 0, 0, 113, 0, 28, 0,
};
const prog_uint8_t node_20[] PROGMEM = {
255, 0, 0, 0, 113, 0, 0, 0,
198, 0, 56, 0, 85, 0, 28, 0,
255, 0, 0, 0, 226, 0, 0, 0,
170, 0, 0, 0, 141, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
255, 0, 145, 0, 109, 0, 218, 0,
36, 0, 182, 0, 72, 0, 72, 0,
255, 0, 0, 0, 0, 0, 109, 0,
36, 0, 36, 0, 145, 0, 0, 0,
72, 0, 72, 0, 182, 0, 0, 0,
72, 0, 72, 0, 218, 0, 0, 0,
109, 0, 109, 0, 255, 0, 0, 0,
};
const prog_uint8_t node_21[] PROGMEM = {
255, 0, 0, 0, 218, 0, 0, 0,
145, 0, 0, 0, 36, 0, 0, 0,
218, 0, 0, 0, 36, 0, 0, 0,
182, 0, 72, 0, 0, 0, 109, 0,
0, 0, 0, 0, 8, 0, 0, 0,
255, 0, 85, 0, 212, 0, 42, 0,
0, 0, 0, 0, 8, 0, 0, 0,
85, 0, 170, 0, 127, 0, 42, 0,
109, 0, 109, 0, 255, 0, 0, 0,
72, 0, 72, 0, 218, 0, 0, 0,
145, 0, 182, 0, 255, 0, 0, 0,
36, 0, 36, 0, 218, 0, 8, 0,
};
const prog_uint8_t node_22[] PROGMEM = {
255, 0, 0, 0, 42, 0, 0, 0,
212, 0, 0, 0, 8, 0, 212, 0,
170, 0, 0, 0, 85, 0, 0, 0,
212, 0, 8, 0, 127, 0, 8, 0,
255, 0, 85, 0, 0, 0, 0, 0,
226, 0, 85, 0, 0, 0, 198, 0,
0, 0, 141, 0, 56, 0, 0, 0,
170, 0, 28, 0, 0, 0, 113, 0,
113, 0, 56, 0, 255, 0, 0, 0,
85, 0, 56, 0, 226, 0, 0, 0,
0, 0, 170, 0, 0, 0, 141, 0,
28, 0, 28, 0, 198, 0, 28, 0,
};
const prog_uint8_t node_23[] PROGMEM = {
255, 0, 0, 0, 229, 0, 0, 0,
204, 0, 204, 0, 0, 0, 76, 0,
178, 0, 153, 0, 51, 0, 178, 0,
178, 0, 127, 0, 102, 51, 51, 25,
0, 0, 0, 0, 0, 0, 0, 31,
0, 0, 0, 0, 255, 0, 0, 31,
0, 0, 8, 0, 0, 0, 191, 159,
127, 95, 95, 0, 223, 0, 63, 0,
255, 0, 255, 0, 204, 204, 204, 204,
0, 0, 51, 51, 51, 51, 0, 0,
204, 0, 204, 0, 153, 153, 153, 153,
153, 0, 0, 0, 102, 102, 102, 102,
};
const prog_uint8_t node_24[] PROGMEM = {
170, 0, 0, 0, 0, 255, 0, 0,
198, 0, 0, 0, 0, 28, 0, 0,
141, 0, 0, 0, 0, 226, 0, 0,
56, 0, 0, 113, 0, 85, 0, 0,
255, 0, 0, 0, 0, 113, 0, 0,
85, 0, 0, 0, 0, 226, 0, 0,
141, 0, 0, 8, 0, 170, 56, 56,
198, 0, 0, 56, 0, 141, 28, 0,
255, 0, 0, 0, 0, 191, 0, 0,
159, 0, 0, 0, 0, 223, 0, 0,
95, 0, 0, 0, 0, 63, 0, 0,
127, 0, 0, 0, 0, 31, 0, 0,
};
const prog_uint8_t* const node_table[] = {
node_0,
node_1,
node_2,
node_3,
node_4,
node_5,
node_6,
node_7,
node_8,
node_9,
node_10,
node_11,
node_12,
node_13,
node_14,
node_15,
node_16,
node_17,
node_18,
node_19,
node_20,
node_21,
node_22,
node_23,
node_24,
};
// pattern_generator.cc
static const prog_uint8_t* drum_map[5][5] = {
{ node_10, node_8, node_0, node_9, node_11 },
{ node_15, node_7, node_13, node_12, node_6 },
{ node_18, node_14, node_4, node_5, node_3 },
{ node_23, node_16, node_21, node_1, node_2 },
{ node_24, node_19, node_17, node_20, node_22 },
};
/*
uint8_t PatternGenerator::ReadDrumMap(
uint8_t step,
uint8_t instrument,
uint8_t x,
uint8_t y) {
uint8_t i = x >> 6;
uint8_t j = y >> 6;
const prog_uint8_t* a_map = drum_map[i][j];
const prog_uint8_t* b_map = drum_map[i + 1][j];
const prog_uint8_t* c_map = drum_map[i][j + 1];
const prog_uint8_t* d_map = drum_map[i + 1][j + 1];
uint8_t offset = (instrument * kStepsPerPattern) + step;
uint8_t a = pgm_read_byte(a_map + offset);
uint8_t b = pgm_read_byte(b_map + offset);
uint8_t c = pgm_read_byte(c_map + offset);
uint8_t d = pgm_read_byte(d_map + offset);
return U8Mix(U8Mix(a, b, x << 2), U8Mix(c, d, x << 2), y << 2);
}
*/
/*
all of the above (without comments) is a direct copy-and-paste from
https://github.com/pichenettes/eurorack/tree/master/grids
resources.cc and further down also: pattern_generator.cc
*/
/*
In september 2013 Olivier helped me understand the above function: ReadDrumMap:
http://www.mutable-instruments.net/forum/discussion/3863/understanding-code-grids-u8mix-and-bitshift-in-pattern_generator-cc
U8Mix returns x * b + (255 – x) * a >> 8
(it ‘crossfades’ between a and b where x sets the position of the crossfader, with a slight loss of 255/256.0).
It internally calculates the 16-bit result as you’ve noticed but drops the lowest byte.
// avril \ op.h:
// static inline uint8_t U8Mix(uint8_t a, uint8_t b, uint8_t balance) {
// return a * (255 - balance) + b * balance >> 8;}
The drum map is 5 x 5 – which means that that each axis is divided into 4 zones.
If a coordinate (say x) has a range of 8-bit, x >> 6 will give you the zone index ; and x << 2 will give you the relative position within the zone.
*/
//
// I was unable to combine
// the use of bitshifting in ReadDrumMap()
// with my use of variable types.
// So I decided to rewrite the code into my simple speak.
//
void readMIdrumMAP(){
FaderX = analogRead(XPin);
FaderY = analogRead(YPin);
// Fader is a 10bit value
unsigned int i = FaderX / 256; // zone-index (2bit)
unsigned int j = FaderY / 256;
unsigned int xx = FaderX % 256; // relative position within a zone (8bit)
unsigned int yy = FaderY % 256;
unsigned int xx_inv= 255-xx;
unsigned int yy_inv= 255-yy;
// retrieve the 4 nodes surrounding the selected zone
const prog_uint8_t* a_map = drum_map[i][j];
const prog_uint8_t* b_map = drum_map[i + 1][j];
const prog_uint8_t* c_map = drum_map[i][j + 1];
const prog_uint8_t* d_map = drum_map[i + 1][j + 1];
// for each drum
for (int z=0; z<3; z++){
// calculate position in each node
unsigned int offset = (z * 32) + stepNr;
// retrieve value from each node
unsigned int a = pgm_read_byte(a_map + offset); // 8bit
unsigned int b = pgm_read_byte(b_map + offset);
unsigned int c = pgm_read_byte(c_map + offset);
unsigned int d = pgm_read_byte(d_map + offset);
// calculate Density
unsigned int ab = (xx*b + xx_inv*a) >>8; // 16bit but 8bits shifted, so effectively only 8bit
unsigned int cd = ( xx * d + xx_inv * c ) >>8;
DrumDens[z]= ( yy * cd + yy_inv * ab ) >> 8 ; // 16bit but 8bits shifted, so effectively only 8bit
}
}