#ifndef SYNTH #define SYNTH #include #include #include #include "../include/spsc_queue.hpp" #include "../include/command.hpp" #include "../include/voice.hpp" #include "../include/stereo_sample.hpp" #include "../include/lfo.hpp" class Synth { public: Synth(){ pitch_bend_range = 2.0; pitch_semitones = 0.0; pitch_multiplier = 1.0; vibrato_depth_ = 0.0; mod_wheel = 0; stolen_voices = 0; } StereoSample generate(); void generate_buffer(double* array, int size); void set_mod_wheel(uint8_t value); void pitch_bend(uint16_t value); double pitch_to_semitones(uint16_t value); double semitones_to_multiplier(double semitones); double mod_wheel_to_depth(uint8_t value); bool note_on(uint8_t note, uint8_t velocity); bool note_off(uint8_t note); private: Voice* find_free_voice(); Voice* find_quietest_voice(); SpscQueue queue; Lfo lfo; double pitch_bend_range; double pitch_semitones; double pitch_multiplier; double vibrato_depth_; uint8_t mod_wheel; uint64_t stolen_voices; std::array voices; }; #endif