zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 8fff8252628bab96fe0a7c3d7b9c853195f32b5c
parent 1d4cf915a1fa9e3a03523c268c779c235500f69b
Author: falkTX <falktx@gmail.com>
Date:   Sun, 13 Dec 2015 17:32:28 +0100

Finalize abstract dpf plugin implementation

Diffstat:
Msrc/Plugin/AbstractFX.hpp | 59+++++++++++++++++++++++++++++++++++++++--------------------
Msrc/Plugin/AlienWah/AlienWah.cpp | 10+++++-----
2 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/src/Plugin/AbstractFX.hpp b/src/Plugin/AbstractFX.hpp @@ -83,16 +83,16 @@ protected: /** Get the plugin author/maker. */ - const char* getMaker() const override + const char* getMaker() const noexcept override { - return ""; + return "ZynAddSubFX Team"; } /** Get the plugin homepage. Optional, returns nothing by default. */ - const char* getHomePage() const override + const char* getHomePage() const noexcept override { return "http://zynaddsubfx.sourceforge.net"; } @@ -100,7 +100,7 @@ protected: /** Get the plugin license (a single line of text or a URL). */ - const char* getLicense() const override + const char* getLicense() const noexcept override { return "GPL v2"; } @@ -108,7 +108,7 @@ protected: /** Get the plugin version, in hexadecimal. */ - uint32_t getVersion() const override + uint32_t getVersion() const noexcept override { // TODO: use config.h or globals.h return d_version(2, 5, 3); @@ -134,13 +134,17 @@ protected: */ void setParameterValue(uint32_t index, float value) override { - /* - TODO: check bounds and round to int without juce + // make sure value is in bounds for uchar conversion + if (value < 0.0f) + value = 0.0f; + else if (value > 127.0f) + value = 127.0f; - const int ivalue(roundToIntAccurate(carla_fixedValue(0.0f, 127.0f, value))); + // safely cast to int + const int ivalue = (int)(value+0.5f); + // ok! effect->changepar(static_cast<int>(index+2), static_cast<uchar>(ivalue)); - */ } /** @@ -174,24 +178,21 @@ protected: */ void run(const float** inputs, float** outputs, uint32_t frames) override { - /* - TODO: Replacement for juce functions - if (outputs[0] != inputs[0]) - FloatVectorOperations::copyWithMultiply(outputs[0], inputs[0], 0.5f, frames); + copyWithMultiply(outputs[0], inputs[0], 0.5f, frames); else - FloatVectorOperations::multiply(outputs[0], 0.5f, frames); + multiply(outputs[0], 0.5f, frames); if (outputs[1] != inputs[1]) - FloatVectorOperations::copyWithMultiply(outputs[1], inputs[1], 0.5f, frames); + copyWithMultiply(outputs[1], inputs[1], 0.5f, frames); else - FloatVectorOperations::multiply(outputs[1], 0.5f, frames); + multiply(outputs[1], 0.5f, frames); - effect->out(Stereo<float*>(inputs[0], inputs[1])); + // FIXME: Make Zyn use const floats + effect->out(Stereo<float*>((float*)inputs[0], (float*)inputs[1])); - FloatVectorOperations::addWithMultiply(outputs[0], efxoutl, 0.5f, frames); - FloatVectorOperations::addWithMultiply(outputs[1], efxoutr, 0.5f, frames); - */ + addWithMultiply(outputs[0], efxoutl, 0.5f, frames); + addWithMultiply(outputs[1], efxoutr, 0.5f, frames); } /* -------------------------------------------------------------------------------------------------------- @@ -280,6 +281,24 @@ private: effect->changepar(1, 64); } + void addWithMultiply(float* dst, const float* src, const float multiplier, const uint32_t frames) noexcept + { + for (uint32_t i=0; i<frames; ++i) + dst[i] += src[i] * multiplier; + } + + void copyWithMultiply(float* dst, const float* src, const float multiplier, const uint32_t frames) noexcept + { + for (uint32_t i=0; i<frames; ++i) + dst[i] = src[i] * multiplier; + } + + void multiply(float* dst, const float multiplier, const uint32_t frames) noexcept + { + for (uint32_t i=0; i<frames; ++i) + dst[i] *= multiplier; + } + DISTRHO_DECLARE_NON_COPY_CLASS(AbstractPluginFX) }; diff --git a/src/Plugin/AlienWah/AlienWah.cpp b/src/Plugin/AlienWah/AlienWah.cpp @@ -43,7 +43,7 @@ protected: Get the plugin label. This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters. */ - const char* getLabel() const override + const char* getLabel() const noexcept override { return "AlienWah"; } @@ -51,7 +51,7 @@ protected: /** Get an extensive comment/description about the plugin. */ - const char* getDescription() const override + const char* getDescription() const noexcept override { // TODO return ""; @@ -61,7 +61,7 @@ protected: Get the plugin unique Id. This value is used by LADSPA, DSSI and VST plugin formats. */ - int64_t getUniqueId() const override + int64_t getUniqueId() const noexcept override { return d_cconst('Z', 'X', 'a', 'w'); } @@ -73,7 +73,7 @@ protected: Initialize the parameter @a index. This function will be called once, shortly after the plugin is created. */ - void initParameter(uint32_t index, Parameter& parameter) override + void initParameter(uint32_t index, Parameter& parameter) noexcept override { parameter.hints = kParameterIsInteger; parameter.name = ""; @@ -153,7 +153,7 @@ protected: Set the name of the program @a index. This function will be called once, shortly after the plugin is created. */ - void initProgramName(uint32_t index, String& programName) override + void initProgramName(uint32_t index, String& programName) noexcept override { switch (index) {