Browse Source

added oscillators, unison, triangle, rectangle, pulse width, auto connect to jack output, and auto connect alsa input and control unison spread with a midi knob and pulse width with another

vampirefrog 3 years ago
parent
commit
114b8b15b3
4 changed files with 476 additions and 238 deletions
  1. 47
    46
      main.c
  2. 125
    62
      synth.c
  3. 45
    2
      synth.h
  4. 259
    128
      tables.inc

+ 47
- 46
main.c View File

@@ -59,37 +59,19 @@ void usage () {
59 59
 );
60 60
 }
61 61
 
62
-void
63
-process_silence (jack_nframes_t nframes)
64
-{
62
+void process_silence (jack_nframes_t nframes) {
65 63
 	sample_t *buffer = (sample_t *) jack_port_get_buffer (output_port, nframes);
66 64
 	memset (buffer, 0, sizeof (jack_default_audio_sample_t) * nframes);
67 65
 }
68 66
 
69
-void
70
-process_audio (jack_nframes_t nframes)
71
-{
72
-
67
+void process_audio (jack_nframes_t nframes) {
73 68
 	sample_t *buffer = (sample_t *) jack_port_get_buffer (output_port, nframes);
74 69
 	for(int i = 0; i < nframes; i++) {
75 70
 		buffer[i] = synth_render_sample(&synth) / 32767.0;
76 71
 	}
77
-	// jack_nframes_t frames_left = nframes;
78
-
79
-	// while (wave_length - offset < frames_left) {
80
-	// 	memcpy (buffer + (nframes - frames_left), wave + offset, sizeof (sample_t) * (wave_length - offset));
81
-	// 	frames_left -= wave_length - offset;
82
-	// 	offset = 0;
83
-	// }
84
-	// if (frames_left > 0) {
85
-	// 	memcpy (buffer + (nframes - frames_left), wave + offset, sizeof (sample_t) * frames_left);
86
-	// 	offset += frames_left;
87
-	// }
88 72
 }
89 73
 
90
-int
91
-process (jack_nframes_t nframes, void *arg)
92
-{
74
+int process (jack_nframes_t nframes, void *arg) {
93 75
 	if (transport_aware) {
94 76
 		jack_position_t pos;
95 77
 
@@ -149,6 +131,8 @@ snd_seq_t *open_seq() {
149 131
 		fprintf(stderr, "Error creating sequencer port.\n");
150 132
 		exit(1);
151 133
 	}
134
+
135
+	snd_seq_connect_from(seq_handle, portid, 32, 0);
152 136
 	return(seq_handle);
153 137
 }
154 138
 
@@ -159,14 +143,23 @@ void midi_action(snd_seq_t *seq_handle) {
159 143
 	do {
160 144
 		snd_seq_event_input(seq_handle, &ev);
161 145
 		switch (ev->type) {
162
-		case SND_SEQ_EVENT_NOTEON:
163
-			printf("Note on %d (%s) %d\n", ev->data.note.note, midi_note_name(ev->data.note.note), ev->data.note.velocity);
164
-			synth_note_on(&synth, ev->data.note.note, ev->data.note.velocity);
165
-			break;
166
-		case SND_SEQ_EVENT_NOTEOFF:
167
-			printf("Note off %d\n", ev->data.note.note);
168
-			synth_note_off(&synth, ev->data.note.note, ev->data.note.velocity);
169
-			break;
146
+			case SND_SEQ_EVENT_NOTEON:
147
+				printf("Note on %d (%s) %d\n", ev->data.note.note, midi_note_name(ev->data.note.note), ev->data.note.velocity);
148
+				synth_note_on(&synth, ev->data.note.note, ev->data.note.velocity);
149
+				break;
150
+			case SND_SEQ_EVENT_NOTEOFF:
151
+				printf("Note off %d\n", ev->data.note.note);
152
+				synth_note_off(&synth, ev->data.note.note, ev->data.note.velocity);
153
+				break;
154
+			case SND_SEQ_EVENT_CONTROLLER:
155
+				printf("CC %d %d\n", ev->data.control.param, ev->data.control.value);
156
+				if(ev->data.control.param == 93) {
157
+					synth_set_pulse_width(&synth, ev->data.control.value);
158
+				}
159
+				if(ev->data.control.param == 74) {
160
+					synth_set_unison_spread(&synth, ev->data.control.value);
161
+				}
162
+				break;
170 163
 		}
171 164
 		snd_seq_free_event(ev);
172 165
 	} while (snd_seq_event_input_pending(seq_handle, 0) > 0);
@@ -176,14 +169,10 @@ void midi_action(snd_seq_t *seq_handle) {
176 169
 int main(int argc, char **argv) {
177 170
 	sample_t scale;
178 171
 	int i, attack_length, decay_length;
179
-	double *amp;
180
-	double max_amp = 0.5;
181 172
 	int option_index;
182 173
 	int opt;
183
-	int got_bpm = 0;
184
-	int attack_percent = 1, decay_percent = 10, dur_arg = 100;
185 174
 	char *client_name = 0;
186
-	char *bpm_string = "bpm";
175
+	char *bpm_string = "synth out";
187 176
 	int verbose = 0;
188 177
 	jack_status_t status;
189 178
 
@@ -219,25 +208,38 @@ int main(int argc, char **argv) {
219 208
 
220 209
 	/* Initial Jack setup, get sample rate */
221 210
 	if (!client_name) {
222
-		client_name = (char *) malloc (9 * sizeof (char));
223
-		strcpy (client_name, "metro");
211
+		client_name = strdup("vampi va");
224 212
 	}
225 213
 	if ((client = jack_client_open (client_name, JackNoStartServer, &status)) == 0) {
226 214
 		fprintf (stderr, "jack server not running?\n");
227 215
 		return 1;
228 216
 	}
229
-	jack_set_process_callback (client, process, 0);
230
-	output_port = jack_port_register (client, bpm_string, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
217
+	jack_set_process_callback(client, process, 0);
218
+	output_port = jack_port_register(client, bpm_string, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
231 219
 
232
-	sr = jack_get_sample_rate (client);
220
+	sr = jack_get_sample_rate(client);
233 221
 
234
-	synth_init(&synth);
235
-	synth.attack = 50;
236
-	synth.decay = 200;
237
-	synth.sustain = 60;
238
-	synth.release = 100;
222
+	if (jack_activate (client)) {
223
+		fprintf (stderr, "cannot activate client");
224
+		exit (1);
225
+	}
226
+
227
+	const char **ports;
228
+	ports = jack_get_ports (client, NULL, NULL, JackPortIsPhysical|JackPortIsInput);
229
+	if (ports == NULL) {
230
+		fprintf(stderr, "no physical capture ports\n");
231
+		exit (1);
232
+	}
239 233
 
240
-	/* setup wave table parameters */
234
+	if (jack_connect (client, jack_port_name (output_port), ports[0])) {
235
+		fprintf (stderr, "cannot connect input ports\n");
236
+	}
237
+
238
+	synth_init(&synth);
239
+	synth.attack = 200;
240
+	synth.decay = 100;
241
+	synth.sustain = 80;
242
+	synth.release = 50;
241 243
 
242 244
 	if (jack_activate (client)) {
243 245
 		fprintf (stderr, "cannot activate client");
@@ -253,7 +255,6 @@ int main(int argc, char **argv) {
253 255
 	pfd = (struct pollfd *)alloca(npfd * sizeof(struct pollfd));
254 256
 	snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN);
255 257
 	while (1) {
256
-		printf("poll\n");
257 258
 		if (poll(pfd, npfd, 100000) > 0) {
258 259
 			midi_action(seq_handle);
259 260
 		}

+ 125
- 62
synth.c View File

@@ -1,28 +1,34 @@
1 1
 #include <stdio.h>
2
+#include <math.h>
2 3
 
3 4
 #include "synth.h"
4 5
 #include "config.h"
5 6
 
6 7
 #include "tables.inc"
7 8
 
9
+// convert from 16.16 frequency to 16.16 period in samples
10
+static fixed freq2period(fixed freq) {
11
+	uint64_t tmp = (uint64_t)SAMPLE_RATE << 32;
12
+	return tmp / freq;
13
+}
14
+
8 15
 void synth_init(struct Synth *synth) {
9 16
 }
10 17
 
11 18
 uint8_t midi_notes[128];
12 19
 void synth_note_on(struct Synth *synth, uint8_t note, uint8_t velocity) {
20
+	printf("synth_note_on note=%d velocity=%d\n", note, velocity);
21
+	// find the first available voice, if any
13 22
 	for(int i = 0; i < SYNTH_NUM_VOICES; i++) {
14 23
 		struct Voice *voice = synth->voices + i;
15 24
 		if(voice->env_state == None) {
16
-			voice->phase = voice->time = 0;
17
-			voice->freq = (uint32_t)(midi_note_freq_table[note & 0x7f] * 256);
25
+			printf("starting voice %d\n", i);
18 26
 			midi_notes[note & 0x7f] = i;
19 27
 			voice->attack = synth->attack;
20 28
 			voice->decay = synth->decay;
21 29
 			voice->sustain = synth->sustain;
22 30
 			voice->release = synth->release;
23
-			voice->volume = velocity;
24
-			voice->env_state = Attack;
25
-			printf("Attack %d\n", synth->attack);
31
+			voice_note_start(voice, note, velocity);
26 32
 			break;
27 33
 		}
28 34
 	}
@@ -30,71 +36,128 @@ void synth_note_on(struct Synth *synth, uint8_t note, uint8_t velocity) {
30 36
 
31 37
 void synth_note_off(struct Synth *synth, uint8_t note, uint8_t velocity) {
32 38
 	(void)velocity;
39
+	printf("synth_note_off note=%d velocity=%d\n", note, velocity);
40
+	printf("stopping voice %d\n", note & 0x7f);
33 41
 	struct Voice *voice = synth->voices + midi_notes[note & 0x7f];
34
-	voice->time = 0;
35
-	voice->env_state = Release;
36
-	printf("Release %d\n", voice->release);
42
+	voice_stop(voice);
37 43
 }
38 44
 
45
+static uint8_t alt = 0;
39 46
 int16_t synth_render_sample(struct Synth *synth) {
40 47
 	int32_t smpl = 0;
41 48
 	for(int i = 0; i < SYNTH_NUM_VOICES; i++) {
42 49
 		struct Voice *v = synth->voices + i;
43
-		if(v->env_state != None) {
44
-
45
-			v->time++;
46
-
47
-			int32_t amplitude = 0; // calculate based on velocity and envelope
48
-			uint32_t ms_time = v->time * 1000 / SAMPLE_RATE;
49
-			switch(v->env_state) {
50
-				case Attack:
51
-					if(v->attack > 0)
52
-						amplitude = v->volume * ms_time / v->attack;
53
-					if(ms_time > v->attack) {
54
-						printf("Decay %d\n", v->decay);
55
-						v->env_state = Decay;
56
-						v->time = 0;
57
-					}
58
-					break;
59
-				case Decay:
60
-					if(v->decay > 0)
61
-						amplitude = (100 * v->volume * (v->decay - ms_time) + v->sustain * v->volume * ms_time) / v->decay / 100;
62
-					if(ms_time > v->decay) {
63
-						printf("Sustain %d\n", v->sustain);
64
-						v->env_state = Sustain;
65
-						v->time = 0;
66
-					}
67
-					break;
68
-				case Sustain:
69
-					amplitude = v->volume * v->sustain / 100;
70
-					break;
71
-				case Release:
72
-					amplitude = v->volume * (v->release - ms_time) * v->sustain / v->release / 100;
73
-					if(ms_time > v->release) {
74
-						v->time = 0;
75
-						v->freq = 0;
76
-						v->env_state = None;
77
-						printf("None\n");
78
-					}
79
-					break;
80
-			}
50
+		smpl += voice_render_sample(v);
51
+		if(smpl > 32767) smpl = 32767;
52
+		if(smpl < -32768) smpl = -32768;
53
+	}
54
+	alt = (alt+1)&1;
55
+	return smpl & 0xffff;
56
+}
81 57
 
82
-			if(v->env_state != None && v->freq) {
83
-				v->phase += (1 << 8);
84
-				uint32_t freq_phase = (SAMPLE_RATE << 16) / v->freq;
85
-				while(v->phase >= freq_phase)
86
-					v->phase -= freq_phase;
87
-				int sine_phase = 256 * v->phase / freq_phase;
88
-				int sine_phase_next = (sine_phase + 1) & 0xff;
89
-				int sine_remainder = v->phase % freq_phase;
90
-				// if(v->env_state == Release) {
91
-				// 	printf("amplitude %d volume=%d time=%d ms_time=%d v->release=%d v->sustain=%d\n", amplitude, v->volume, v->time, ms_time, v->release, v->sustain);
92
-				// }
93
-				smpl += amplitude * sine_table_256[sine_phase] / 255;
94
-			}
95
-			if(smpl > 32767) smpl = 32767;
96
-			if(smpl < -32768) smpl = -32768;
58
+void synth_set_pulse_width(struct Synth *synth, uint8_t w) {
59
+	for(int i = 0; i < SYNTH_NUM_VOICES; i++) {
60
+		for(int j = 0; j < 7; j++)
61
+			synth->voices[i].osc[j].pulse_width = w;
62
+	}
63
+}
64
+
65
+void synth_set_unison_spread(struct Synth *synth, uint8_t w) {
66
+	for(int i = 0; i < SYNTH_NUM_VOICES; i++) {
67
+		for(int j = 0; j < 7; j++)
68
+			synth->voices[i].unison_spread = w;
69
+	}
70
+}
71
+
72
+int16_t oscillator_render_sample(struct Oscillator *osc) {
73
+	osc->phase += 0x10000; // add one sample in fixed
74
+	if(osc->period > 0) // avoid a infinite loop below
75
+		while(osc->phase > osc->period)
76
+			osc->phase -= osc->period;
77
+	uint32_t edge = osc->pulse_width * osc->period / 127;
78
+	if(osc->type == Rectangle) {
79
+		if(osc->phase >= edge)
80
+			return -20000;
81
+		else
82
+			return 20000;
83
+	} else if(osc->type == Triangle) {
84
+		if(osc->phase <= edge) {
85
+			return ((((osc->phase >> 3) << 6) / (edge >> 3)) << 6) - (1 << 11);
86
+		} else {
87
+			return (((((osc->period - osc->phase) >> 3) << 6) / ((osc->period - edge) >> 3)) << 6) - (1 << 11);
97 88
 		}
98 89
 	}
99
-	return smpl & 0xffff;
90
+}
91
+
92
+int16_t voice_render_sample(struct Voice *v) {
93
+	if(v->env_state == None)
94
+		return 0;
95
+
96
+	int32_t amplitude = 0; // calculate based on velocity and envelope
97
+	uint32_t ms_time = v->time * 1000 / SAMPLE_RATE;
98
+	switch(v->env_state) {
99
+		case Attack:
100
+			if(v->attack > 0)
101
+				amplitude = v->volume * ms_time / v->attack;
102
+			if(ms_time > v->attack) {
103
+				v->env_state = Decay;
104
+				v->time = 0;
105
+			}
106
+			break;
107
+		case Decay:
108
+			if(v->decay > 0)
109
+				amplitude = (100 * v->volume * (v->decay - ms_time) + v->sustain * v->volume * ms_time) / v->decay / 100;
110
+			if(ms_time > v->decay) {
111
+				v->env_state = Sustain;
112
+				v->time = 0;
113
+			}
114
+			break;
115
+		case Sustain:
116
+			amplitude = v->volume * v->sustain / 100;
117
+			break;
118
+		case Release:
119
+			if(v->release > 0)
120
+				amplitude = v->volume * (v->release - ms_time) * v->sustain / v->release / 100;
121
+			if(ms_time > v->release) {
122
+				v->time = 0;
123
+				v->env_state = None;
124
+			}
125
+			break;
126
+	}
127
+
128
+	v->time++;
129
+
130
+	if(v->env_state != None) {
131
+		int32_t ret = 0;
132
+		for(int i = 0; i < 7; i++) ret += oscillator_render_sample(&v->osc[i]);
133
+		return amplitude * ret / 32767;
134
+	}
135
+}
136
+
137
+void voice_note_start(struct Voice *voice, uint8_t note, uint8_t velocity) {
138
+	voice->time = 0;
139
+	voice->volume = velocity * 128;
140
+	voice->env_state = Attack;
141
+
142
+	note &= 0x7f;
143
+	voice->osc[0].type = Triangle;
144
+	voice->osc[0].freq = midi_note_freq_fixed[note];
145
+	int freq_below = voice->osc[0].freq - midi_note_freq_fixed[note - 1];
146
+	int freq_above = midi_note_freq_fixed[note + 1] - voice->osc[0].freq;
147
+	voice->osc[0].period = freq2period(voice->osc[0].freq);
148
+	for(int i = 1; i <= 3; i++) {
149
+		voice->osc[i].type = voice->osc[0].type;
150
+		voice->osc[i].freq = voice->osc[0].freq - voice->unison_spread * freq_below * i / 3 / 127;
151
+		voice->osc[i].period = freq2period(voice->osc[i].freq);
152
+	}
153
+	for(int i = 4; i < 7; i++) {
154
+		voice->osc[i].type = voice->osc[0].type;
155
+		voice->osc[i].freq = voice->osc[0].freq + voice->unison_spread * freq_above * (i - 3) / 3 / 127;
156
+		voice->osc[i].period = freq2period(voice->osc[i].freq);
157
+	}
158
+}
159
+
160
+void voice_stop(struct Voice *voice) {
161
+	voice->time = 0;
162
+	voice->env_state = Release;
100 163
 }

+ 45
- 2
synth.h View File

@@ -6,11 +6,44 @@
6 6
 #define SYNTH_NUM_VOICES 64
7 7
 #define TUNING 440
8 8
 
9
+typedef uint32_t fixed;
10
+
11
+struct Oscillator {
12
+	fixed phase; // fixed 16.16
13
+	fixed freq; // fixed 16.16
14
+	fixed period; // period in samples, fixed 16.16
15
+
16
+	enum {
17
+		Rectangle,
18
+		Triangle
19
+	} type;
20
+
21
+	uint8_t pulse_width; // 0 - 127
22
+};
23
+
24
+int16_t oscillator_render_sample(struct Oscillator *osc);
25
+void oscillator_set_freq(fixed freq); // fixed 16.16
26
+
27
+struct Sampler {
28
+	fixed phase; // fixed 16.16
29
+	fixed freq; // fixed 16.16
30
+	fixed period; // period in samples, fixed 16.16
31
+
32
+	uint32_t length;
33
+	uint16_t length_log2; // length = 1 << length_log2;
34
+	int16_t *data;
35
+	enum {
36
+		Nearest,
37
+		Linear
38
+	} interpolation;
39
+};
40
+
41
+int16_t sampler_sample(struct Sampler *sampler);
42
+void sampler_set_freq(fixed freq);
43
+
9 44
 struct Voice {
10
-	uint32_t phase;
11 45
 	uint32_t time;
12 46
 	uint16_t volume;
13
-	uint32_t freq;
14 47
 
15 48
 	// Envelope
16 49
 	enum {
@@ -23,8 +56,16 @@ struct Voice {
23 56
 
24 57
 	uint16_t attack, decay, release; // in ms
25 58
 	uint16_t sustain; // percentage
59
+
60
+	uint8_t unison_spread;
61
+	struct Oscillator osc[7];
26 62
 };
27 63
 
64
+struct Synth;
65
+void voice_note_start(struct Voice *voice, uint8_t note, uint8_t velocity);
66
+void voice_stop(struct Voice *voice);
67
+int16_t voice_render_sample(struct Voice *voice);
68
+
28 69
 struct Synth {
29 70
 	struct Voice voices[SYNTH_NUM_VOICES];
30 71
 	uint16_t attack, decay, sustain, release; // in ms
@@ -34,5 +75,7 @@ void synth_init(struct Synth *synth);
34 75
 void synth_note_on(struct Synth *synth, uint8_t note, uint8_t velocity);
35 76
 void synth_note_off(struct Synth *synth, uint8_t note, uint8_t velocity);
36 77
 int16_t synth_render_sample(struct Synth *synth);
78
+void synth_set_pulse_width(struct Synth *s, uint8_t w);
79
+void synth_set_unison_spread(struct Synth *s, uint8_t w);
37 80
 
38 81
 #endif /* SYNTH_H_ */

+ 259
- 128
tables.inc View File

@@ -258,132 +258,263 @@ static const int16_t sine_table_256[256] = {
258 258
 
259 259
 // http://www.richardbrice.net/midi_notes.htm
260 260
 static const float midi_note_freq_table[128] = {
261
-	8.176,
262
-	8.662,
263
-	9.177,
264
-	9.723,
265
-	10.301,
266
-	10.913,
267
-	11.562,
268
-	12.250,
269
-	12.978,
270
-	13.750,
271
-	14.568,
272
-	15.434,
273
-	16.352,
274
-	17.324,
275
-	18.354,
276
-	19.445,
277
-	20.601,
278
-	21.826,
279
-	23.124,
280
-	24.499,
281
-	25.956,
282
-	27.500, // Lowest note on piano
283
-	29.135,
284
-	30.867,
285
-	32.703,
286
-	34.648,
287
-	36.708,
288
-	38.890,
289
-	41.203,
290
-	43.653,
291
-	46.249,
292
-	48.999,
293
-	51.913,
294
-	55.000,
295
-	58.270,
296
-	61.735,
297
-	65.406,
298
-	69.295,
299
-	73.416,
300
-	77.781,
301
-	82.406,
302
-	87.307,
303
-	92.499,
304
-	97.998,
305
-	103.82,
306
-	110.00,
307
-	116.54,
308
-	123.47,
309
-	130.81,
310
-	138.59,
311
-	146.83,
312
-	155.56,
313
-	164.81,
314
-	174.61,
315
-	184.99,
316
-	195.99,
317
-	207.65,
318
-	220.00,
319
-	233.08,
320
-	246.94,
321
-	261.63, // Middle-C
322
-	277.18,
323
-	293.66,
324
-	311.13,
325
-	329.63,
326
-	349.23,
327
-	369.99,
328
-	391.99,
329
-	415.31,
330
-	440.00,
331
-	466.16,
332
-	489.88,
333
-	523.25,
334
-	554.37,
335
-	587.33,
336
-	622.25,
337
-	659.26,
338
-	698.46,
339
-	739.99,
340
-	783.99,
341
-	830.61,
342
-	880.00,
343
-	932.32,
344
-	987.77,
345
-	1046.5,
346
-	1108.7,
347
-	1174.7,
348
-	1244.5,
349
-	1318.5,
350
-	1396.9,
351
-	1480.0,
352
-	1568.0,
353
-	1661.2,
354
-	1760.0,
355
-	1864.7,
356
-	1975.5,
357
-	2093.0,
358
-	2217.5,
359
-	2349.3,
360
-	2489.0,
361
-	2637.0,
362
-	2793.8,
363
-	2960.0,
364
-	3136.0,
365
-	3322.4,
366
-	3520.0,
367
-	3729.3,
368
-	3951.1,
369
-	4186.0, // Highest note on piano
370
-	4434.9,
371
-	4698.6,
372
-	4978.0,
373
-	5274.0,
374
-	5587.7,
375
-	5919.9,
376
-	6271.9,
377
-	6644.9,
378
-	7040.0,
379
-	7458.6,
380
-	7902.1,
381
-	8372.0,
382
-	8869.8,
383
-	9397.3,
384
-	9956.1,
385
-	10548.1,
386
-	11175.3,
387
-	11839.8,
388
-	12543.9,
261
+	8.1757989156,
262
+	8.661957218,
263
+	9.1770239974,
264
+	9.7227182413,
265
+	10.3008611535,
266
+	10.9133822323,
267
+	11.5623257097,
268
+	12.2498573744,
269
+	12.9782717994,
270
+	13.75,
271
+	14.5676175474,
272
+	15.4338531643,
273
+	16.3515978313,
274
+	17.3239144361,
275
+	18.3540479948,
276
+	19.4454364826,
277
+	20.6017223071,
278
+	21.8267644646,
279
+	23.1246514195,
280
+	24.4997147489,
281
+	25.9565435987,
282
+	27.5,
283
+	29.1352350949,
284
+	30.8677063285,
285
+	32.7031956626,
286
+	34.6478288721,
287
+	36.7080959897,
288
+	38.8908729653,
289
+	41.2034446141,
290
+	43.6535289291,
291
+	46.249302839,
292
+	48.9994294977,
293
+	51.9130871975,
294
+	55,
295
+	58.2704701898,
296
+	61.735412657,
297
+	65.4063913251,
298
+	69.2956577442,
299
+	73.4161919794,
300
+	77.7817459305,
301
+	82.4068892282,
302
+	87.3070578583,
303
+	92.4986056779,
304
+	97.9988589954,
305
+	103.826174395,
306
+	110,
307
+	116.5409403795,
308
+	123.470825314,
309
+	130.8127826503,
310
+	138.5913154884,
311
+	146.8323839587,
312
+	155.563491861,
313
+	164.8137784564,
314
+	174.6141157165,
315
+	184.9972113558,
316
+	195.9977179909,
317
+	207.65234879,
318
+	220,
319
+	233.081880759,
320
+	246.9416506281,
321
+	261.6255653006,
322
+	277.1826309769,
323
+	293.6647679174,
324
+	311.1269837221,
325
+	329.6275569129,
326
+	349.228231433,
327
+	369.9944227116,
328
+	391.9954359818,
329
+	415.3046975799,
330
+	440,
331
+	466.1637615181,
332
+	493.8833012561,
333
+	523.2511306012,
334
+	554.3652619537,
335
+	587.3295358348,
336
+	622.2539674442,
337
+	659.2551138257,
338
+	698.456462866,
339
+	739.9888454233,
340
+	783.9908719635,
341
+	830.6093951599,
342
+	880,
343
+	932.3275230362,
344
+	987.7666025122,
345
+	1046.5022612024,
346
+	1108.7305239075,
347
+	1174.6590716696,
348
+	1244.5079348883,
349
+	1318.5102276515,
350
+	1396.912925732,
351
+	1479.9776908465,
352
+	1567.981743927,
353
+	1661.2187903198,
354
+	1760,
355
+	1864.6550460724,
356
+	1975.5332050245,
357
+	2093.0045224048,
358
+	2217.461047815,
359
+	2349.3181433393,
360
+	2489.0158697767,
361
+	2637.020455303,
362
+	2793.825851464,
363
+	2959.9553816931,
364
+	3135.963487854,
365
+	3322.4375806396,
366
+	3520,
367
+	3729.3100921447,
368
+	3951.066410049,
369
+	4186.0090448096,
370
+	4434.92209563,
371
+	4698.6362866785,
372
+	4978.0317395533,
373
+	5274.0409106059,
374
+	5587.6517029281,
375
+	5919.9107633862,
376
+	6271.926975708,
377
+	6644.8751612791,
378
+	7040,
379
+	7458.6201842894,
380
+	7902.132820098,
381
+	8372.0180896192,
382
+	8869.8441912599,
383
+	9397.2725733571,
384
+	9956.0634791066,
385
+	10548.0818212118,
386
+	11175.3034058561,
387
+	11839.8215267723,
388
+	12543.853951416,
389
+};
390
+
391
+static const uint32_t midi_note_freq_fixed[128] = {
392
+	535809,
393
+	567670,
394
+	601425,
395
+	637188,
396
+	675077,
397
+	715219,
398
+	757749,
399
+	802807,
400
+	850544,
401
+	901120,
402
+	954703,
403
+	1011473,
404
+	1071618,
405
+	1135340,
406
+	1202851,
407
+	1274376,
408
+	1350154,
409
+	1430439,
410
+	1515497,
411
+	1605613,
412
+	1701088,
413
+	1802240,
414
+	1909407,
415
+	2022946,
416
+	2143237,
417
+	2270680,
418
+	2405702,
419
+	2548752,
420
+	2700309,
421
+	2860878,
422
+	3030994,
423
+	3211227,
424
+	3402176,
425
+	3604480,
426
+	3818814,
427
+	4045892,
428
+	4286473,
429
+	4541360,
430
+	4811404,
431
+	5097505,
432
+	5400618,
433
+	5721755,
434
+	6061989,
435
+	6422453,
436
+	6804352,
437
+	7208960,
438
+	7637627,
439
+	8091784,
440
+	8572947,
441
+	9082720,
442
+	9622807,
443
+	10195009,
444
+	10801236,
445
+	11443511,
446
+	12123977,
447
+	12844906,
448
+	13608704,
449
+	14417920,
450
+	15275254,
451
+	16183568,
452
+	17145893,
453
+	18165441,
454
+	19245614,
455
+	20390018,
456
+	21602472,
457
+	22887021,
458
+	24247954,
459
+	25689813,
460
+	27217409,
461
+	28835840,
462
+	30550508,
463
+	32367136,
464
+	34291786,
465
+	36330882,
466
+	38491228,
467
+	40780036,
468
+	43204943,
469
+	45774043,
470
+	48495909,
471
+	51379626,
472
+	54434817,
473
+	57671680,
474
+	61101017,
475
+	64734272,
476
+	68583572,
477
+	72661764,
478
+	76982457,
479
+	81560072,
480
+	86409886,
481
+	91548086,
482
+	96991818,
483
+	102759252,
484
+	108869635,
485
+	115343360,
486
+	122202033,
487
+	129468544,
488
+	137167144,
489
+	145323527,
490
+	153964914,
491
+	163120144,
492
+	172819773,
493
+	183096171,
494
+	193983636,
495
+	205518503,
496
+	217739269,
497
+	230686720,
498
+	244404066,
499
+	258937088,
500
+	274334289,
501
+	290647054,
502
+	307929828,
503
+	326240288,
504
+	345639545,
505
+	366192342,
506
+	387967272,
507
+	411037006,
508
+	435478539,
509
+	461373440,
510
+	488808132,
511
+	517874176,
512
+	548668578,
513
+	581294109,
514
+	615859655,
515
+	652480576,
516
+	691279090,
517
+	732384684,
518
+	775934544,
519
+	822074013,
389 520
 };

Loading…
Cancel
Save