1 /* 2 ** Surge Synthesizer is Free and Open Source Software 3 ** 4 ** Surge is made available under the Gnu General Public License, v3.0 5 ** https://www.gnu.org/licenses/gpl-3.0.en.html 6 ** 7 ** Copyright 2004-2020 by various individuals as described by the Git transaction log 8 ** 9 ** All source at: https://github.com/surge-synthesizer/surge.git 10 ** 11 ** Surge was a commercial product from 2004-2018, with Copyright and ownership 12 ** in that period held by Claes Johanson at Vember Audio. Claes made Surge 13 ** open source in September 2018. 14 */ 15 16 #pragma once 17 18 #include "OscillatorBase.h" 19 #include "DspUtilities.h" 20 #include <vt_dsp/lipol.h> 21 #include "BiquadFilter.h" 22 #include "OscillatorCommonFunctions.h" 23 24 class SineOscillator : public Oscillator 25 { 26 public: 27 enum sine_params 28 { 29 sine_shape, 30 sine_feedback, 31 sine_FMmode, 32 sine_lowcut, 33 sine_highcut, 34 sine_unison_detune, 35 sine_unison_voices, 36 }; 37 38 SineOscillator(SurgeStorage *storage, OscillatorStorage *oscdata, pdata *localcopy); 39 virtual void init(float pitch, bool is_display = false, 40 bool nonzero_init_drift = true) override; 41 virtual void process_block(float pitch, float drift = 0.f, bool stereo = false, bool FM = false, 42 float FMdepth = 0.f) override; 43 template <int mode, bool stereo, bool FM> 44 void process_block_internal(float pitch, float drift, float FMdepth); 45 46 template <int mode> 47 void process_block_legacy(float pitch, float drift = 0.f, bool stereo = false, bool FM = false, 48 float FMdepth = 0.f); 49 virtual ~SineOscillator(); 50 virtual void init_ctrltypes() override; 51 virtual void init_default_values() override; 52 53 quadr_osc sine[MAX_UNISON]; 54 double phase[MAX_UNISON]; 55 Surge::Oscillator::DriftLFO driftLFO[MAX_UNISON]; 56 Surge::Oscillator::CharacterFilter<float> charFilt; 57 float fb_val; 58 float playingramp[MAX_UNISON], dplaying; 59 lag<double> FMdepth; 60 lag<double> FB; 61 void prepare_unison(int voices); 62 int n_unison; 63 float out_attenuation, out_attenuation_inv, detune_bias, detune_offset; 64 float panL alignas(16)[MAX_UNISON], panR alignas(16)[MAX_UNISON]; 65 66 int id_mode, id_fb, id_fmlegacy, id_detune; 67 float lastvalue alignas(16)[MAX_UNISON]; 68 bool firstblock = true; 69 70 BiquadFilter lp, hp; 71 void applyFilter(); 72 valueFromSinAndCos(float svalue,float cvalue)73 inline float valueFromSinAndCos(float svalue, float cvalue) 74 { 75 return valueFromSinAndCos(svalue, cvalue, localcopy[id_mode].i); 76 } 77 static float valueFromSinAndCos(float svalue, float cvalue, int mode); 78 79 virtual void handleStreamingMismatches(int streamingRevision, 80 int currentSynthStreamingRevision) override; 81 }; 82