Last active
March 6, 2021 20:05
-
-
Save olilarkin/5fddce683cf31e75ad93855f55841c76 to your computer and use it in GitHub Desktop.
Basic VU meter hookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "IPlugEffect.h" | |
#include "IPlug_include_in_plug_src.h" | |
#include "IControls.h" | |
constexpr int kNumVUFrames = 100; | |
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); | |
}; | |
mLayoutFunc = [&](IGraphics* pGraphics) { | |
pGraphics->AttachPanelBackground(COLOR_GRAY); | |
pGraphics->AttachControl(new IBitmapControl(100, 100, pGraphics->LoadBitmap(VU2X_FN, kNumVUFrames)), kCtrlTagVUMeter); | |
}; | |
} | |
void IPlugEffect::OnIdle() | |
{ | |
SendControlValueFromDelegate(kCtrlTagVUMeter, mLevel.load()); | |
} | |
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]; | |
} | |
} | |
mLevel.store(outputs[0][0]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "IPlug_include_in_plug_hdr.h" | |
const int kNumPresets = 1; | |
constexpr int kCtrlTagVUMeter = 0; | |
enum EParams | |
{ | |
kGain = 0, | |
kNumParams | |
}; | |
using namespace iplug; | |
using namespace igraphics; | |
class IPlugEffect final : public Plugin | |
{ | |
public: | |
IPlugEffect(const InstanceInfo& info); | |
void OnIdle() override; | |
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override; | |
std::atomic<float> mLevel; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment