#ifndef SYNTH_ENGINE_H #define SYNTH_ENGINE_H #include #include #include #include #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 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; 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_d; cc_t cc_adsr_s; cc_t cc_adsr_r; float 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; float del_time; float 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; synth_viz viz; osc_t * osctri; } synth_t; synth_t * init_synth(); void free_synth(synth_t * synth); #endif /* SYNTH_ENGINE_H */