forked from ch-nry/nozoid_nozori
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm84_ADD.ino
152 lines (133 loc) · 4.52 KB
/
m84_ADD.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
// --------------------------------------------------------------------------
// This file is part of the NOZORI firmware.
//
// NOZORI firmware is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// NOZORI firmware is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with NOZORI firmware. If not, see <http://www.gnu.org/licenses/>.
// --------------------------------------------------------------------------
// sinus oscillator with a diferents harmonics
// Pot 1 : FQ
// Pot 2 : Mod Fq (or fine if nothing is connected on the modulation)
// Pot 3 : FQ H1
// Pot 4 : GAIN H1
// Pot 5 : FQ H2
// Pot 6 : MOD H2
// Pot 7 : FQ H3
// Pot 8 : MOD H3
// IN 1 : 1V/Oct
// IN 2 : MOD FQ
// Selecteur3 : FQ range
// OUT 1 : OUT
// OUT 2 : OUT without fundamental
uint32_t VCO_Add1_phase, VCO_Add2_phase, VCO_Add3_phase, VCO_Add4_phase, VCO_Add5_phase, VCO_Add6_phase;
inline void VCO_Add_init_() {
VCO1_phase = 0;
VCO_Add1_phase = 0;
VCO_Add2_phase = 0;
VCO_Add3_phase = 0;
VCO_Add4_phase = 0;
VCO_Add5_phase = 0;
VCO_Add6_phase = 0;
}
inline void VCO_Add_loop_() {
int32_t tmpS;
uint32_t macro_tmp;
filter16_nozori_84
test_connect_loop_84();
// Fq principale
macro_fq_in
macro_1VOct_IN1
macro_FqMod_fine_IN2(pot2);
// Calcule des increments
macro_fq2increment
increment_0 = increment1;
switch(get_toggle()) {
case 0 : // Harmonics
increment_1 = min(0x19999999, increment1 * 2); // 20KHz max
increment_2 = min(0x19999999, increment1 * 3);
increment_3 = min(0x19999999, increment1 * 4);
increment_4 = min(0x19999999, increment1 * 5);
increment_5 = min(0x19999999, increment1 * 6);
increment_6 = min(0x19999999, increment1 * 7);
break;
case 1 : // major
increment_1 = (increment1 / 8) * 9; // 2nd major, +2
increment_2 = (increment1 / 4) * 5; // 3rd major, +4
increment_3 = (increment1 / 3) * 4; // 4th, +5
increment_4 = (increment1 / 2) * 3; // 5th, +7
increment_5 = (increment1 / 3) * 5; // 6th major, +9
increment_6 = (increment1 / 8) * 15; // 7th major, +11
break;
case 2 : // minor
increment_1 = (increment1 / 8) * 9; // 2nd major, +2
increment_2 = (increment1 / 5) * 6; // 3rd minor, +3
increment_3 = (increment1 / 3) * 4; // 4th, +5
increment_4 = (increment1 / 2) * 3; // 5th, +7
increment_5 = (increment1 / 5) * 8; // 6 minor, +8
increment_6 = (increment1 / 9) * 16; // 7 minor, +10
break;
}
if (IN1_connect < 60) led2(audio_inL >> 23); else set_led2(0);
if (IN2_connect < 60) led4(audio_inR >> 23); else set_led4(0);
}
inline void VCO_Add_audio_() {
int32_t outS, tmpS, macro_tmp, outS2;
uint32_t out, out2;
// Oscillateur principal
VCO1_phase += increment_0<<3;
tmpS = fast_sin(VCO1_phase)^0x80000000;
outS = tmpS>>3;
outS2=0;
// Harmonique 1
VCO_Add1_phase += increment_1 <<3;
tmpS = fast_sin(VCO_Add1_phase)^0x80000000;
tmpS >>= 17;
tmpS *= CV_filter16_out[index_filter_pot3];
outS2 += tmpS>>2;
// Harmonique 2
VCO_Add2_phase += increment_2<<3;
tmpS = fast_sin(VCO_Add2_phase)^0x80000000;
tmpS >>= 17;
tmpS *= CV_filter16_out[index_filter_pot4];
outS2 += tmpS>>2;
// Harmonique 3
VCO_Add3_phase += increment_3<<3;
tmpS = fast_sin(VCO_Add3_phase)^0x80000000;
tmpS >>= 17;
tmpS *= CV_filter16_out[index_filter_pot5];
outS2 += tmpS>>2;
// Harmonique 4
VCO_Add4_phase += increment_4 <<3;
tmpS = fast_sin(VCO_Add4_phase)^0x80000000;
tmpS >>= 17;
tmpS *= CV_filter16_out[index_filter_pot6];
outS2 += tmpS>>2;
// Harmonique 5
VCO_Add5_phase += increment_5<<3;
tmpS = fast_sin(VCO_Add5_phase)^0x80000000;
tmpS >>= 17;
tmpS *= CV_filter16_out[index_filter_pot7];
outS2 += tmpS>>2;
// Harmonique 6
VCO_Add6_phase += increment_6<<3;
tmpS = fast_sin(VCO_Add6_phase)^0x80000000;
tmpS >>= 17;
tmpS *= CV_filter16_out[index_filter_pot8];
outS2 += tmpS>>2;
outS += outS2;
outS += outS >> 3;
outS2 += outS2 >> 2;
out = outS ^0x80000000;
out2 = outS2 ^0x80000000;
audio_outL = out;
audio_outR = out2;
}