blob: 3b0b23868f82603a3c2d73b37ce84d0948dacd38 (
plain) (
blame)
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
|
#ifndef SYNTH_ENGINE_H
#define SYNTH_ENGINE_H
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <portaudio.h>
#include "synth_common.h"
#include "notes.h"
#include "filter.h"
#include "adsr.h"
#include "control.h"
#include "osc.h"
#include "pa_ringbuffer.h"
#ifndef M_PI
#define M_PI (3.14159265)
#endif
#define RING_SIZE 65536
typedef struct lfo_t {
float freq;
float amp;
unsigned long long elapsed;
} lfo_t;
typedef struct midi_note_t {
float freq;
int channel;
PaTime noteOn;
PaTime noteOff;
float velocity; // normalized
float wvt_index;
float lfo_index;
unsigned long long elapsed;
unsigned long long noteOffSample;
adsr_t * adsr;
int active;
} midi_note_t;
typedef struct {
int spectrum_enabled;
int wave_enabled;
int adsr_enabled;
int adsr_graph_enabled;
int osc_enabled;
int freeze;
int rate_divider;
float *wave_buffer_data;
PaUtilRingBuffer wave_buffer;
float *fft_buffer_data;
PaUtilRingBuffer fft_buffer;
float *tmp_buffer;
float *wave_viz_buffer;
float *fft_input_buffer;
float *fft_output_buffer;
float *fft_smooth_buffer;
int tmp_index;
} synth_viz;
typedef struct {
PaStream *stream;
int wvt_pos;
cc_t * ccs[128];
int cci;
cc_t cc_pitch;
cc_t cc_cutoff;
cc_t cc_resonance;
cc_t cc_lfo_freq;
cc_t cc_lfo_amp;
cc_t cc_adsr_a;
cc_t cc_adsr_peak;
cc_t cc_adsr_d;
cc_t cc_adsr_s;
cc_t cc_adsr_r;
cc_t cc_gain;
float x;
midi_note_t midi_note[MIDI_NOTES];
midi_note_t * midi_active[MIDI_NOTES];
int midi_active_n;
adsr_t adsr;
lfo_t lfo;
int octave;
int delay;
float * del;
int deli;
cc_t cc_del_time;
cc_t cc_del_feedback;
unsigned long long counter;
int filter;
int clamp;
int modifiers[16];
int modi;
float (*gen[7]) (float freq, midi_note_t * midi_note, float x, unsigned int sample_rate);
int geni;
BWLowPass* fff;
BWBandStop* fff2;
int active;
int sound_active;
synth_viz viz;
} synth_t;
synth_t * init_synth();
void free_synth(synth_t * synth);
#endif /* SYNTH_ENGINE_H */
|