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 FM2Oscillator : public Oscillator
25 {
26   public:
27     enum fm2_params
28     {
29         fm2_m1amount = 0,
30         fm2_m1ratio,
31         fm2_m2amount,
32         fm2_m2ratio,
33         fm2_m12offset,
34         fm2_m12phase,
35         fm2_feedback,
36     };
37 
38     FM2Oscillator(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     virtual ~FM2Oscillator();
44     virtual void init_ctrltypes() override;
45     virtual void init_default_values() override;
46     double phase, lastoutput;
47     quadr_osc RM1, RM2;
48     Surge::Oscillator::DriftLFO driftLFO;
49     float fb_val;
50     lag<double> FMdepth, RelModDepth1, RelModDepth2, FeedbackDepth, PhaseOffset;
51     virtual void handleStreamingMismatches(int streamingRevision,
52                                            int currentSynthStreamingRevision) override;
53 };
54