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: 7 нояб. 2016 г. 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_GATE_H_ 23 #define PLUGINS_GATE_H_ 24 25 #include <metadata/plugins.h> 26 27 #include <core/plugin.h> 28 #include <core/util/Bypass.h> 29 #include <core/util/Sidechain.h> 30 #include <core/util/MeterGraph.h> 31 #include <core/util/Delay.h> 32 #include <core/dynamics/Gate.h> 33 34 namespace lsp 35 { 36 class gate_base: public plugin_t 37 { 38 protected: 39 enum c_mode_t 40 { 41 GM_MONO, 42 GM_STEREO, 43 GM_LR, 44 GM_MS 45 }; 46 47 enum sc_source_t 48 { 49 SCT_INTERNAL, 50 SCT_EXTERNAL 51 }; 52 53 enum sc_graph_t 54 { 55 G_IN, 56 G_SC, 57 G_ENV, 58 G_GAIN, 59 G_OUT, 60 61 G_TOTAL 62 }; 63 64 enum sc_meter_t 65 { 66 M_IN, 67 M_SC, 68 M_ENV, 69 M_GAIN, 70 M_CURVE, 71 M_OUT, 72 73 M_TOTAL 74 }; 75 76 enum sync_t 77 { 78 S_CURVE = 1 << 0, 79 S_HYST = 1 << 1, 80 81 S_ALL = S_CURVE | S_HYST 82 }; 83 84 typedef struct channel_t 85 { 86 Bypass sBypass; // Bypass 87 Sidechain sSC; // Sidechain module 88 Equalizer sSCEq; // Sidechain equalizer 89 Gate sGate; // Gate module 90 Delay sDelay; // Lookahead delay 91 Delay sCompDelay; // Lookahead delay 92 Delay sDryDelay; // Dry delay 93 MeterGraph sGraph[G_TOTAL]; // Input meter graph 94 95 float *vIn; // Input data 96 float *vOut; // Output data 97 float *vSc; // Sidechain data 98 float *vEnv; // Envelope data 99 float *vGain; // Gain reduction data 100 bool bScListen; // Listen sidechain 101 size_t nSync; // Synchronization flags 102 size_t nScType; // Sidechain mode 103 float fMakeup; // Makeup gain 104 float fDryGain; // Dry gain 105 float fWetGain; // Wet gain 106 float fDotIn; // Dot input gain 107 float fDotOut; // Dot output gain 108 109 IPort *pIn; // Input port 110 IPort *pOut; // Output port 111 IPort *pSC; // Sidechain port 112 113 IPort *pGraph[G_TOTAL]; // History graphs 114 IPort *pMeter[M_TOTAL]; // Meters 115 116 IPort *pScType; // Sidechain location 117 IPort *pScMode; // Sidechain mode 118 IPort *pScLookahead; // Sidechain lookahead 119 IPort *pScListen; // Sidechain listen 120 IPort *pScSource; // Sidechain source 121 IPort *pScReactivity; // Sidechain reactivity 122 IPort *pScPreamp; // Sidechain pre-amplification 123 IPort *pScHpfMode; // Sidechain high-pass filter mode 124 IPort *pScHpfFreq; // Sidechain high-pass filter frequency 125 IPort *pScLpfMode; // Sidechain low-pass filter mode 126 IPort *pScLpfFreq; // Sidechain low-pass filter frequency 127 128 IPort *pHyst; // Hysteresis flag 129 IPort *pThresh[2]; // Threshold 130 IPort *pZone[2]; // Reduction zone 131 IPort *pAttack; // Attack time 132 IPort *pRelease; // Release time 133 IPort *pReduction; // Reduction 134 IPort *pMakeup; // Makeup 135 136 IPort *pDryGain; // Dry gain 137 IPort *pWetGain; // Wet gain 138 IPort *pCurve[2]; // Curve graphs 139 IPort *pZoneStart[2]; // Zone start 140 IPort *pHystStart; // Hysteresis start 141 } channel_t; 142 143 protected: 144 size_t nMode; // Gate mode 145 bool bSidechain; // External side chain 146 channel_t *vChannels; // Gate channels 147 float *vCurve; // Gate curve 148 float *vTime; // Time points buffer 149 bool bPause; // Pause button 150 bool bClear; // Clear button 151 bool bMSListen; // Mid/Side listen 152 float fInGain; // Input gain 153 bool bUISync; // UI sync 154 float_buffer_t *pIDisplay; // Inline display buffer 155 156 IPort *pBypass; // Bypass port 157 IPort *pInGain; // Input gain 158 IPort *pOutGain; // Output gain 159 IPort *pPause; // Pause gain 160 IPort *pClear; // Cleanup gain 161 IPort *pMSListen; // Mid/Side listen 162 163 uint8_t *pData; // Gate data 164 165 public: 166 gate_base(const plugin_metadata_t &metadata, bool sc, size_t mode); 167 virtual ~gate_base(); 168 169 public: 170 virtual void init(IWrapper *wrapper); 171 virtual void destroy(); 172 173 virtual void update_settings(); 174 virtual void update_sample_rate(long sr); 175 virtual void ui_activated(); 176 177 virtual void process(size_t samples); 178 virtual bool inline_display(ICanvas *cv, size_t width, size_t height); 179 }; 180 181 class gate_mono: public gate_base, public gate_mono_metadata 182 { 183 public: 184 gate_mono(); 185 }; 186 187 class gate_stereo: public gate_base, public gate_stereo_metadata 188 { 189 public: 190 gate_stereo(); 191 }; 192 193 class gate_lr: public gate_base, public gate_lr_metadata 194 { 195 public: 196 gate_lr(); 197 }; 198 199 class gate_ms: public gate_base, public gate_ms_metadata 200 { 201 public: 202 gate_ms(); 203 }; 204 205 class sc_gate_mono: public gate_base, public sc_gate_mono_metadata 206 { 207 public: 208 sc_gate_mono(); 209 }; 210 211 class sc_gate_stereo: public gate_base, public sc_gate_stereo_metadata 212 { 213 public: 214 sc_gate_stereo(); 215 }; 216 217 class sc_gate_lr: public gate_base, public sc_gate_lr_metadata 218 { 219 public: 220 sc_gate_lr(); 221 }; 222 223 class sc_gate_ms: public gate_base, public sc_gate_ms_metadata 224 { 225 public: 226 sc_gate_ms(); 227 }; 228 229 } 230 231 #endif /* PLUGINS_GATE_H_ */ 232