fix: validate input index in Mixer and update parameter count in plugin info
This commit is contained in:
parent
386f8b7e54
commit
970cb6049d
4 changed files with 16 additions and 10 deletions
|
|
@ -37,8 +37,10 @@ void Mixer<NumInputs>::mixChannels(const float **inputs, float *out,
|
||||||
|
|
||||||
template <uint32_t NumInputs>
|
template <uint32_t NumInputs>
|
||||||
void Mixer<NumInputs>::setInputGain(uint32_t index, float gain) {
|
void Mixer<NumInputs>::setInputGain(uint32_t index, float gain) {
|
||||||
|
if (isValidInputIndex(index)) {
|
||||||
gains_[index] = gain;
|
gains_[index] = gain;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <uint32_t NumInputs>
|
template <uint32_t NumInputs>
|
||||||
float Mixer<NumInputs>::getInputGain(uint32_t index) const {
|
float Mixer<NumInputs>::getInputGain(uint32_t index) const {
|
||||||
|
|
@ -54,6 +56,8 @@ template <uint32_t NumInputs> bool Mixer<NumInputs>::getNormalise() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint32_t NumInputs>
|
template <uint32_t NumInputs>
|
||||||
bool Mixer<NumInputs>::isValidInputIndex(float index) const {
|
bool Mixer<NumInputs>::isValidInputIndex(uint32_t index) const {
|
||||||
return index >= 0 && index < NumInputs;
|
return index < NumInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class Mixer<2u>;
|
||||||
|
|
@ -19,11 +19,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mixChannels(const float **inputs, float *out, uint32_t frames);
|
void mixChannels(const float **inputs, float *out, uint32_t frames);
|
||||||
bool isValidInputIndex(float index) const;
|
bool isValidInputIndex(uint32_t index) const;
|
||||||
float gains_[NumInputs];
|
float gains_[NumInputs];
|
||||||
bool normalise_;
|
bool normalise_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MIXER_HPP_INCLUDED
|
#endif // MIXER_HPP_INCLUDED
|
||||||
|
|
||||||
template class Mixer<2u>;
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
||||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
||||||
|
|
||||||
#define DISTRHO_PLUGIN_NUM_PARAMETERS 2
|
#define DISTRHO_PLUGIN_NUM_PARAMETERS 5
|
||||||
|
|
||||||
#define DISTRHO_PLUGIN_WANT_PROGRAMS 0
|
#define DISTRHO_PLUGIN_WANT_PROGRAMS 0
|
||||||
#define DISTRHO_PLUGIN_WANT_STATE 0
|
#define DISTRHO_PLUGIN_WANT_STATE 0
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#include "DistrhoPlugin.hpp"
|
#include "DistrhoPlugin.hpp"
|
||||||
#include "DistrhoPluginInfo.h"
|
#include "DistrhoPluginInfo.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "../../core/Clipper.hpp"
|
#include "../../core/Clipper.hpp"
|
||||||
#include "../../core/Filter.hpp"
|
#include "../../core/Filter.hpp"
|
||||||
#include "../../core/Gain.hpp"
|
#include "../../core/Gain.hpp"
|
||||||
|
|
@ -121,7 +123,9 @@ protected:
|
||||||
gain_.setGain(value);
|
gain_.setGain(value);
|
||||||
break;
|
break;
|
||||||
case kParamClipMode:
|
case kParamClipMode:
|
||||||
clipper_.setMode((Clipper::ClipperMode)value);
|
value = std::fmin(std::fmax(value, 0.0f),
|
||||||
|
static_cast<float>(Clipper::kClipperModeCount - 1));
|
||||||
|
clipper_.setMode(static_cast<Clipper::ClipperMode>(std::lround(value)));
|
||||||
break;
|
break;
|
||||||
case kParamFilter:
|
case kParamFilter:
|
||||||
filter_.setCutOff(value);
|
filter_.setCutOff(value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue