Try this:
IPlugEffect.h
#pragma once
#include "IPlug_include_in_plug_hdr.h"
const int kNumPrograms = 10;
enum EParams
{
kGain = 0,
kVol,
kNumParams
};
using namespace iplug;
using namespace igraphics;
class IPlugEffect final : public Plugin
{
public:
IPlugEffect(const InstanceInfo& info);
#if IPLUG_DSP // http://bit.ly/2S64BDd
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
#endif
};
IPlugEffect.cpp
#include "IPlugEffect.h"
#include "IPlug_include_in_plug_src.h"
#include "IControls.h"
IPlugEffect::IPlugEffect(const InstanceInfo& info)
: Plugin(info, MakeConfig(kNumParams, kNumPrograms))
{
GetParam(kGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
GetParam(kVol)->InitDouble("Volume", 50., 0., 100.0, 0.01, "%");
MakeDefaultPreset("Default");
MakePreset("1", 20.0, 34.62720);
MakePreset("2", 30.0, 4.62720);
MakePreset("3", 40.0, 24.62720);
MakePreset("4", 50.0, 14.62720);
MakePreset("5", 60.0, 55.62720);
MakePreset("6", 70.0, 27.62720);
MakePreset("7", 76.0, 27.62720);
MakePreset("8", 80.0, 85.62720);
MakePreset("9", 88.0, 56.62720);
MakePreset("10", 90.0, 77.62720);
#if IPLUG_EDITOR // http://bit.ly/2S64BDd
mMakeGraphicsFunc = [&]() {
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, 1.);
};
mLayoutFunc = [&](IGraphics* pGraphics) {
pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
pGraphics->AttachPanelBackground(COLOR_GRAY);
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
const IRECT b = pGraphics->GetBounds();
pGraphics->AttachControl(new ITextControl(b.GetMidVPadded(50), "Hello iPlug 2!", IText(50)));
pGraphics->AttachControl(new IVKnobControl(b.GetCentredInside(100).GetVShifted(-100), kGain));
pGraphics->AttachControl(new IVKnobControl(b.GetCentredInside(100).GetVShifted(100), kVol));
};
#endif
}
#if IPLUG_DSP
void IPlugEffect::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
{
const double gain = GetParam(kGain)->Value() / 100.;
const int nChans = NOutChansConnected();
for (int s = 0; s < nFrames; s++) {
for (int c = 0; c < nChans; c++) {
outputs[c][s] = inputs[c][s] * gain;
}
}
}
#endif
When testing, bring the second knob to 0% and save the file. When loading the file, it can be seen that the risk handles are not in the zero position.