-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzmModule.h
96 lines (71 loc) · 2.42 KB
/
zmModule.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
#ifndef zMorsModule_h
#define zMorsModule_h
#define BUS_COUNT 32
#define RANGE(vmin,v,vmax) ( (isnan(v)) ? 0.0 : min(max(v,vmin),vmax) )
/******************************************************/
class zmModule {
public:
float sampleRate = 40000.0;
unsigned int portMap[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float parameterMap[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float parameterDefaults[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
String parameterName[10];
String portName[10];
String title = "unKnown";
zmModule() {
// analogReadResolution(12);
// analogWriteResolution(10);
};
virtual void genSample(float * bus) {};
int portCount() {
for (int i = 0 ; i < 10 ; i++) {
if (portName[i].length() == 0)
return i;
}
return 10;
}
int parameterCount() {
for (int i = 0 ; i < 10 ; i++) {
if (parameterName[i].length() == 0)
return i;
}
return 10;
}
void resetModule() {
for (int i = 0 ; i < 10 ; i++) {
portMap[i] = 0;
}
for (int i = 0 ; i < 10 ; i++) {
parameterMap[i] = parameterDefaults[i];
}
};
int lineCount() {
return portCount() + 1 + parameterCount(); // ports+title+parameter
}
};
/******************************************************/
// here we try some "analog mocho sauce" :-) by selfmade vactrol
// TODO: try use different Condensators via OpenCollector Output ?!?!?!
// TODO: try prefilter PWM Out
#define PORT_VACTROL_PW_LED 0 // it the LED via PW
#define PORT_VACTROL_PW_IN 1 // its Audio RC hardware input via PW
#define PORT_VACTROL_RETURN 2 // its from ADC
#define PIN_VACTROL_LED 3
#define PIN_VACTROL_IN 4
class zmModuleVactrol : public zmModule {
public:
zmModuleVactrol() {
title = "Vactrol";
analogWriteResolution(12);
analogWriteFrequency(PIN_VACTROL_LED, 375000); // FTM1
analogWriteFrequency(PIN_VACTROL_IN, 375000);
portName[PORT_VACTROL_PW_LED] = "Led";
portName[PORT_VACTROL_PW_IN] = "input";
portName[PORT_VACTROL_RETURN] = "output";
}
void genSample(float * bus) {
analogWrite(PIN_VACTROL_LED, 2048.0 * (bus[portMap[PORT_VACTROL_PW_LED]] + 1.0) );
analogWrite(PIN_VACTROL_IN, 2048.0 * (bus[portMap[PORT_VACTROL_PW_IN]] + 1.0) );
};
};
#endif