Skip to content

Commit

Permalink
Using WDL VerbEngine (buggy now)
Browse files Browse the repository at this point in the history
  • Loading branch information
BLumia committed Sep 10, 2016
1 parent 8049405 commit fe9d983
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
48 changes: 48 additions & 0 deletions Synthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ enum EParams
mFilterSustain,
mFilterRelease,
mFilterEnvelopeAmount,
mVerbRoomSize,
mVerbDamp,
mVerbWidth,
mVerbDry,
mVerbWet,
kNumParams
};

Expand Down Expand Up @@ -206,6 +211,13 @@ Synthesis::Synthesis(IPlugInstanceInfo instanceInfo)
filterEnvAdsrVisualization->setColor(IColor(100, 25, 121, 173));
pGraphics->AttachControl(filterEnvAdsrVisualization);

// Reverb
GetParam(mVerbRoomSize)->InitDouble("Room Size", 0.5, 0.3, 0.99, 0.001);
GetParam(mVerbDamp)->InitDouble("Dampening", 0.5, 0., 1., 0.001);
GetParam(mVerbWidth)->InitDouble("Width", 1., -1., 1., 0.001);
GetParam(mVerbDry)->InitDouble("Dry", 1., 0., 1., 0.001);
GetParam(mVerbWet)->InitDouble("Wet", 0.5, 0., 1., 0.001);

AttachGraphics(pGraphics);

CreatePresets();
Expand All @@ -227,6 +239,14 @@ Synthesis::~Synthesis() {}
void Synthesis::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
// Mutex is already locked for us.
/*
if (mDry == 0. && mWet == 1.)
{
// Process the entire sample block at once (more efficient?).
mVerbEngine.ProcessSampleBlock(inputs[0], inputs[1], outputs[0], outputs[1], nFrames);
return;
}
*/

double *leftOutput = outputs[0];
double *rightOutput = outputs[1];
Expand All @@ -236,6 +256,15 @@ void Synthesis::ProcessDoubleReplacing(double** inputs, double** outputs, int nF
mMIDIReceiver.advance();

leftOutput[i] = rightOutput[i] = voiceManager.nextSample();

// Verb
mVerbEngine.ProcessSample(leftOutput, rightOutput);
// Mix dry/wet
/* FIXME: wtf bug idk
if (i == nFrames - 1) break;
*leftOutput++ = mWet * *leftOutput;
*rightOutput++ = mWet * *rightOutput;
*/
}

mMIDIReceiver.Flush(nFrames);
Expand All @@ -250,6 +279,7 @@ void Synthesis::Reset()
TRACE;
IMutexLock lock(this);
voiceManager.setSampleRate(GetSampleRate());
mVerbEngine.SetSampleRate(GetSampleRate());
}

void Synthesis::OnParamChange(int paramIdx)
Expand Down Expand Up @@ -317,6 +347,24 @@ void Synthesis::OnParamChange(int paramIdx)
case mFilterEnvelopeAmount:
voiceManager.setFilterAmountForEachVoice(GetParam(paramIdx)->Value());
break;

case mVerbRoomSize:
mVerbEngine.SetRoomSize(GetParam(paramIdx)->Value());
mVerbEngine.Reset();
break;
case mVerbDamp:
mVerbEngine.SetDampening(GetParam(paramIdx)->Value());
mVerbEngine.Reset();
break;
case mVerbWidth:
mVerbEngine.SetWidth(GetParam(paramIdx)->Value());
break;
case mVerbDry:
mDry = GetParam(paramIdx)->Value();
break;
case mVerbWet:
mWet = GetParam(paramIdx)->Value();
break;
}
}

Expand Down
3 changes: 3 additions & 0 deletions Synthesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "MIDIReceiver.h"
#include "ADSRVisualizationControl.h"
#include "VoiceManager.h"
#include "../verbengine.h"

class Synthesis : public IPlug
{
Expand All @@ -26,6 +27,8 @@ class Synthesis : public IPlug
int lastVirtualKeyboardNoteNumber;

private:
WDL_ReverbEngine mVerbEngine;
double mDry, mWet;
double mFrequency;
void CreatePresets();
VoiceManager voiceManager;
Expand Down
2 changes: 1 addition & 1 deletion resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ instrument determined by PLUG _IS _INST

// GUI default dimensions
#define GUI_WIDTH 665
#define GUI_HEIGHT 253
#define GUI_HEIGHT 324

// on MSVC, you must define SA_API in the resource editor preprocessor macros as well as the c++ ones
#if defined(SA_API) && !defined(OS_IOS)
Expand Down
Binary file modified resources/img/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fe9d983

Please sign in to comment.