NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

TemplateProject.cpp (2460B)


      1 // clang-format off
      2 // Need to import these two in this order.
      3 #include "TemplateProject.h"
      4 #include "IPlug_include_in_plug_src.h"
      5 // clang-format on
      6 
      7 #if IPLUG_EDITOR
      8   #include "IControls.h"
      9 #endif
     10 
     11 TemplateProject::TemplateProject(const InstanceInfo& info)
     12 : Plugin(info, MakeConfig(kNumParams, kNumPresets))
     13 {
     14   GetParam(kParamGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
     15 
     16 #if IPLUG_EDITOR // http://bit.ly/2S64BDd
     17   mMakeGraphicsFunc = [&]() { return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS); };
     18 
     19   mLayoutFunc = [&](IGraphics* pGraphics) {
     20     const IRECT bounds = pGraphics->GetBounds();
     21     const IRECT innerBounds = bounds.GetPadded(-10.f);
     22     const IRECT sliderBounds = innerBounds.GetFromLeft(150).GetMidVPadded(100);
     23     const IRECT versionBounds = innerBounds.GetFromTRHC(300, 20);
     24     const IRECT titleBounds = innerBounds.GetCentredInside(200, 50);
     25 
     26     if (pGraphics->NControls())
     27     {
     28       pGraphics->GetBackgroundControl()->SetTargetAndDrawRECTs(bounds);
     29       pGraphics->GetControlWithTag(kCtrlTagSlider)->SetTargetAndDrawRECTs(sliderBounds);
     30       pGraphics->GetControlWithTag(kCtrlTagTitle)->SetTargetAndDrawRECTs(titleBounds);
     31       pGraphics->GetControlWithTag(kCtrlTagVersionNumber)->SetTargetAndDrawRECTs(versionBounds);
     32       return;
     33     }
     34 
     35     pGraphics->SetLayoutOnResize(true);
     36     pGraphics->AttachCornerResizer(EUIResizerMode::Size, true);
     37     pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
     38     pGraphics->AttachPanelBackground(COLOR_LIGHT_GRAY);
     39     pGraphics->AttachControl(new IVSliderControl(sliderBounds, kParamGain), kCtrlTagSlider);
     40     pGraphics->AttachControl(new ITextControl(titleBounds, "TemplateProject", IText(30)), kCtrlTagTitle);
     41     WDL_String buildInfoStr;
     42     GetBuildInfoStr(buildInfoStr, __DATE__, __TIME__);
     43     pGraphics->AttachControl(
     44       new ITextControl(versionBounds, buildInfoStr.Get(), DEFAULT_TEXT.WithAlign(EAlign::Far)), kCtrlTagVersionNumber);
     45   };
     46 #endif
     47 }
     48 
     49 #if IPLUG_EDITOR
     50 void TemplateProject::OnParentWindowResize(int width, int height)
     51 {
     52   if (GetUI())
     53     GetUI()->Resize(width, height, 1.f, false);
     54 }
     55 #endif
     56 
     57 #if IPLUG_DSP
     58 void TemplateProject::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
     59 {
     60   const int nChans = NOutChansConnected();
     61   const double gain = GetParam(kParamGain)->Value() / 100.;
     62 
     63   for (int s = 0; s < nFrames; s++)
     64   {
     65     for (int c = 0; c < nChans; c++)
     66     {
     67       outputs[c][s] = inputs[c][s] * gain;
     68     }
     69   }
     70 }
     71 #endif