1 /* 2 * ZamPhono 3 * Copyright (C) 2016 Damien Zammit <damien@zamaudio.com> 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation; either version 2 of 8 * the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 */ 15 16 #ifndef ZAMPHONOPLUGIN_HPP_INCLUDED 17 #define ZAMPHONOPLUGIN_HPP_INCLUDED 18 19 #include "DistrhoPlugin.hpp" 20 #include <complex> 21 22 START_NAMESPACE_DISTRHO 23 24 // ----------------------------------------------------------------------- 25 26 class ZamPhonoPlugin : public Plugin 27 { 28 public: 29 enum Parameters 30 { 31 paramToggle = 0, 32 paramType, 33 paramCount 34 }; 35 36 ZamPhonoPlugin(); 37 38 protected: 39 // ------------------------------------------------------------------- 40 // Information 41 getLabel() const42 const char* getLabel() const noexcept override 43 { 44 return "ZamPhono"; 45 } 46 getMaker() const47 const char* getMaker() const noexcept override 48 { 49 return "Damien Zammit"; 50 } 51 getLicense() const52 const char* getLicense() const noexcept override 53 { 54 return "GPL v2+"; 55 } 56 getVersion() const57 uint32_t getVersion() const noexcept override 58 { 59 return d_version(3, 14, 0); 60 } 61 getUniqueId() const62 int64_t getUniqueId() const noexcept override 63 { 64 return d_cconst('Z', 'M', 'P', 'H'); 65 } 66 67 // ------------------------------------------------------------------- 68 // Init 69 70 void initParameter(uint32_t index, Parameter& parameter) ; 71 void initProgramName(uint32_t index, String& programName) ; 72 73 // ------------------------------------------------------------------- 74 // Internal data 75 76 float getParameterValue(uint32_t index) const override; 77 void setParameterValue(uint32_t index, float value) override; 78 void loadProgram(uint32_t index) override; 79 80 // ------------------------------------------------------------------- 81 // Process 82 void aweight(float); 83 84 static inline double sanitize_denormal(double v)85 sanitize_denormal(double v) { 86 if(!std::isnormal(v)) 87 return 0.f; 88 return v; 89 } 90 91 static inline double from_dB(double gdb)92 from_dB(double gdb) { 93 return (exp(0.05*gdb*log(10.0))); 94 } 95 96 static inline double to_dB(double g)97 to_dB(double g) { 98 return (20.0*log10(g)); 99 } 100 101 void activate() override; 102 void run(const float** inputs, float** outputs, uint32_t frames) override; 103 void emphasis(float srate); 104 double run_filter(double in); 105 void brickwall(float fc, float srate); 106 void clearbrickwall(void); 107 double run_brickwall(double in); 108 109 double zn1, zn2, zd1, zd2; 110 double b0, b1, b2; 111 double a1, a2; 112 double state[4]; 113 double A0, A1, A2, B0, B1, B2; 114 115 // ------------------------------------------------------------------- 116 117 private: 118 float type, inv, typeold, invold; 119 }; 120 121 // ----------------------------------------------------------------------- 122 123 END_NAMESPACE_DISTRHO 124 125 #endif // ZAMPHONO_HPP_INCLUDED 126