1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 4 июл. 2020 г. 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_SURGE_FILTER_H_ 23 #define PLUGINS_SURGE_FILTER_H_ 24 25 #include <core/plugin.h> 26 #include <core/util/Blink.h> 27 #include <core/util/Bypass.h> 28 #include <core/util/Depopper.h> 29 #include <core/util/MeterGraph.h> 30 #include <core/util/Delay.h> 31 32 #include <metadata/plugins.h> 33 34 namespace lsp 35 { 36 class surge_filter_base: public plugin_t, public surge_filter_base_metadata 37 { 38 protected: 39 typedef struct channel_t 40 { 41 float *vIn; // Input buffer 42 float *vOut; // Output buffer 43 float *vBuffer; // Buffer for processing 44 Bypass sBypass; // Bypass 45 Delay sDelay; // Delay for latency compensation 46 Delay sDryDelay; // Dry delay 47 MeterGraph sIn; // Input metering graph 48 MeterGraph sOut; // Output metering graph 49 bool bInVisible; // Input signal visibility flag 50 bool bOutVisible; // Output signal visibility flag 51 52 IPort *pIn; // Input port 53 IPort *pOut; // Output port 54 IPort *pInVisible; // Input visibility 55 IPort *pOutVisible; // Output visibility 56 IPort *pMeterIn; // Input Meter 57 IPort *pMeterOut; // Output Meter 58 } channel_t; 59 60 protected: 61 size_t nChannels; // Number of channels 62 channel_t *vChannels; // Array of channels 63 float *vBuffer; // Buffer for processing 64 float *vEnv; // Envelope 65 float *vTimePoints; // Time points 66 float fGainIn; // Input gain 67 float fGainOut; // Output gain 68 bool bGainVisible; // Gain visible 69 bool bEnvVisible; // Envelope visible 70 uint8_t *pData; // Allocated data 71 float_buffer_t *pIDisplay; // Inline display buffer 72 73 MeterGraph sGain; // Gain metering graph 74 MeterGraph sEnv; // Envelop metering graph 75 Blink sActive; // Activity indicator 76 Depopper sDepopper; // Depopper module 77 78 IPort *pModeIn; // Mode for fade in 79 IPort *pModeOut; // Mode for fade out 80 IPort *pGainIn; // Input gain 81 IPort *pGainOut; // Output gain 82 IPort *pThreshOn; // Threshold 83 IPort *pThreshOff; // Threshold 84 IPort *pRmsLen; // RMS estimation length 85 IPort *pFadeIn; // Fade in time 86 IPort *pFadeOut; // Fade out time 87 IPort *pFadeInDelay; // Fade in time 88 IPort *pFadeOutDelay; // Fade out time 89 IPort *pActive; // Active flag 90 IPort *pBypass; // Bypass port 91 IPort *pMeshIn; // Input mesh 92 IPort *pMeshOut; // Output mesh 93 IPort *pMeshGain; // Gain mesh 94 IPort *pMeshEnv; // Envelope mesh 95 IPort *pGainVisible; // Gain mesh visibility 96 IPort *pEnvVisible; // Envelope mesh visibility 97 IPort *pGainMeter; // Gain reduction meter 98 IPort *pEnvMeter; // Envelope meter 99 100 public: 101 explicit surge_filter_base(size_t channels, const plugin_metadata_t &meta); 102 virtual ~surge_filter_base(); 103 104 virtual void init(IWrapper *wrapper); 105 virtual void destroy(); 106 107 public: 108 virtual void update_sample_rate(long sr); 109 virtual void update_settings(); 110 virtual void process(size_t samples); 111 virtual bool inline_display(ICanvas *cv, size_t width, size_t height); 112 virtual void dump(IStateDumper *v) const; 113 }; 114 115 class surge_filter_mono: public surge_filter_base, public surge_filter_mono_metadata 116 { 117 public: 118 explicit surge_filter_mono(); 119 }; 120 121 class surge_filter_stereo: public surge_filter_base, public surge_filter_stereo_metadata 122 { 123 public: 124 explicit surge_filter_stereo(); 125 }; 126 } 127 128 #endif /* PLUGINS_SURGE_FILTER_H_ */ 129