Changes

Jump to navigation Jump to search
Line 749: Line 749:  
   
 
   
 
  #endif
 
  #endif
 +
 +
=====DisthroPluginMain.cpp=====
 +
 +
#include "DistrhoPlugin.hpp"
 +
 +
START_NAMESPACE_DPF
 +
 +
class SimpleGainPlugin : public Plugin {
 +
public:
 +
    SimpleGainPlugin() : Plugin(1, 0, 0) { // 1 parameter, 0 programs, 0 states
 +
        gain = 1.0f; // Default gain (no change)
 +
    }
 +
 +
protected:
 +
    const char* getLabel() const override { return "SimpleGain"; }
 +
    const char* getDescription() const override { return "A simple gain plugin for Zynthian"; }
 +
    const char* getMaker() const override { return "YourName"; }
 +
    const char* getLicense() const override { return "MIT"; }
 +
    uint32_t getVersion() const override { return d_version(1, 0, 0); }
 +
    int64_t getUniqueId() const override { return d_cconst('S', 'G', 'a', 'n'); }
 +
 +
    void initParameter(uint32_t index, Parameter& parameter) override {
 +
        if (index != 0) return;
 +
        parameter.hints = kParameterIsAutomable;
 +
        parameter.name = "Gain";
 +
        parameter.symbol = "gain";
 +
        parameter.unit = "x";
 +
        parameter.ranges.def = 1.0f;
 +
        parameter.ranges.min = 0.0f;
 +
        parameter.ranges.max = 2.0f;
 +
    }
 +
 +
    float getParameterValue(uint32_t index) const override {
 +
        if (index != 0) return 0.0f;
 +
        return gain;
 +
    }
 +
 +
    void setParameterValue(uint32_t index, float value) override {
 +
        if (index != 0) return;
 +
        gain = value;
 +
    }
 +
 +
    void run(const float** inputs, float** outputs, uint32_t frames) override {
 +
        const float* inL = inputs[0];
 +
        const float* inR = inputs[1];
 +
        float* outL = outputs[0];
 +
        float* outR = outputs[1];
 +
 +
        for (uint32_t i = 0; i < frames; ++i) {
 +
            outL[i] = inL[i] * gain;
 +
            outR[i] = inR[i] * gain;
 +
        }
 +
    }
 +
 +
private:
 +
    float gain;
 +
    DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SimpleGainPlugin)
 +
};
 +
 +
Plugin* createPlugin() {
 +
    return new SimpleGainPlugin();
 +
}
 +
 +
END_NAMESPACE_DPF
    
=====makefile=====
 
=====makefile=====
1,112

edits

Navigation menu