#ifndef SYNTH_ENGINE_H #define SYNTH_ENGINE_H #include #include #include #include #include "notes.h" #include "filter.h" #define SAMPLE_RATE (44100) //#define SAMPLE_RATE (48000) #define FRAMES_PER_BUFFER (210) #define WIDTH 1024 #define HEIGHT 600 #ifndef M_PI #define M_PI (3.14159265) #endif typedef struct { float a; float peak; float d; float s; float r; unsigned long long elapsed; } adsr_t; typedef struct { float freq; PaTime noteOn; PaTime noteOff; int key; unsigned long long elapsed; } note_t; typedef struct { int sample_rate_divider; float wave[1000200]; int wi; } viz_t; typedef struct { PaStream *stream; float freq_offset; float gain; float x; note_t n; adsr_t adsr; int octave; int poly; int multi; int filter; int clamp; float (*gen[4]) (float freq, unsigned long long phase, float x, unsigned int sample_rate); int geni; float cutoff; float resonance; BWLowPass* fff; BWBandStop* fff2; int active; viz_t viz; } synth_t; float adsr_amplitude(void *synthData, unsigned long long elapsed); float make_sample(unsigned long long phase, void *synthData, unsigned int sample_rate, int viz); void init_synth(synth_t * synth); void free_synth(synth_t * synth); int sound_gen(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *synthData); #endif /* SYNTH_ENGINE_H */