Skip to content

Instantly share code, notes, and snippets.

@olilarkin
Created September 26, 2022 20:43
Show Gist options
  • Save olilarkin/83ff5652e66fea2e76f020b2a5f1f68a to your computer and use it in GitHub Desktop.
Save olilarkin/83ff5652e66fea2e76f020b2a5f1f68a to your computer and use it in GitHub Desktop.
IBMeterControl example
#include "IPlugEffect.h"
#include "IPlug_include_in_plug_src.h"
#include "IControls.h"
int kCtrlTagMeter = 0;
IPlugEffect::IPlugEffect(const InstanceInfo& info)
: Plugin(info, MakeConfig(kNumParams, kNumPresets))
{
GetParam(kGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
mMakeGraphicsFunc = [&]() {
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, GetScaleForScreen(PLUG_WIDTH, PLUG_HEIGHT));
};
mLayoutFunc = [&](IGraphics* pGraphics) {
pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
pGraphics->AttachPanelBackground(COLOR_GRAY);
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
auto meterBmp = pGraphics->LoadBitmap(METER_FN, 63);
pGraphics->AttachControl(new IBMeterControl(100,100, meterBmp), kCtrlTagMeter);
};
}
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;
}
}
mSender.ProcessBlock(outputs, nFrames, kCtrlTagMeter);
}
#pragma once
#include "IPlug_include_in_plug_hdr.h"
#include "ISender.h"
const int kNumPresets = 1;
enum EParams
{
kGain = 0,
kNumParams
};
using namespace iplug;
using namespace igraphics;
class IPlugEffect final : public Plugin
{
public:
IPlugEffect(const InstanceInfo& info);
void OnIdle() override
{
mSender.TransmitData(*this);
}
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
IPeakAvgSender<1> mSender;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment