1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Stefano Tronci <stefano.tronci@protonmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 20 Mar 2017 7 * 8 * lsp-plugins is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * any later version. 12 * 13 * lsp-plugins is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef PLUGINS_OSCILLATOR_H_ 23 #define PLUGINS_OSCILLATOR_H_ 24 25 #include <core/plugin.h> 26 #include <metadata/plugins.h> 27 #include <core/util/Bypass.h> 28 #include <core/util/Oscillator.h> 29 30 namespace lsp 31 { 32 class oscillator_mono: public plugin_t, public oscillator_mono_metadata 33 { 34 protected: 35 Oscillator sOsc; 36 Bypass sBypass; 37 size_t nMode; 38 bool bMeshSync; 39 bool bBypass; 40 41 float *vBuffer; 42 float *vTime; 43 float *vDisplaySamples; 44 uint8_t *pData; 45 float_buffer_t *pIDisplay; // Inline display buffer 46 47 IPort *pIn; 48 IPort *pOut; 49 IPort *pBypass; 50 IPort *pFrequency; 51 IPort *pGain; 52 IPort *pDCOffset; 53 IPort *pDCRefSc; 54 IPort *pInitPhase; 55 IPort *pModeSc; 56 IPort *pOversamplerModeSc; 57 IPort *pFuncSc; 58 IPort *pSquaredSinusoidInv; 59 IPort *pParabolicInv; 60 IPort *pRectangularDutyRatio; 61 IPort *pSawtoothWidth; 62 IPort *pTrapezoidRaiseRatio; 63 IPort *pTrapezoidFallRatio; 64 IPort *pPulsePosWidthRatio; 65 IPort *pPulseNegWidthRatio; 66 IPort *pParabolicWidth; 67 IPort *pOutputMesh; 68 69 protected: 70 static fg_function_t get_function(size_t function); 71 static dc_reference_t get_dc_reference(size_t reference); 72 static over_mode_t get_oversampling_mode(size_t mode); 73 74 public: 75 explicit oscillator_mono(); 76 virtual ~oscillator_mono(); 77 78 public: 79 virtual void init(IWrapper *wrapper); 80 virtual void process(size_t samples); 81 virtual void update_settings(); 82 virtual void update_sample_rate(long sr); 83 virtual void destroy(); 84 virtual bool inline_display(ICanvas *cv, size_t width, size_t height); 85 virtual void ui_activated(); 86 virtual void dump(IStateDumper *v) const; 87 }; 88 } 89 90 #endif /* PLUGINS_OSCILLATOR_H_ */ 91