Switch to cmake

This commit is contained in:
Roland Rabien 2023-08-23 08:45:23 -07:00
commit 1a375b0ad5
19 changed files with 1083 additions and 1007 deletions

View file

@ -2,69 +2,69 @@
#include "PluginEditor.h"
#include "WavetableVoice.h"
using namespace gin;
static String waveTextFunction (const Parameter&, float v)
static juce::String waveTextFunction (const gin::Parameter&, float v)
{
switch ((Wave)int (v))
switch ((gin::Wave)int (v))
{
case Wave::sine: return "Sine";
case Wave::triangle: return "Triangle";
case Wave::sawUp: return "Saw (Up)";
case Wave::sawDown: return "Saw (Down)";
case Wave::pulse: return "Pulse";
case Wave::square: return "Square";
case Wave::noise: return "Noise";
case gin::Wave::silence: return "Off";
case gin::Wave::sine: return "Sine";
case gin::Wave::triangle: return "Triangle";
case gin::Wave::sawUp: return "Saw (Up)";
case gin::Wave::sawDown: return "Saw (Down)";
case gin::Wave::pulse: return "Pulse";
case gin::Wave::square: return "Square";
case gin::Wave::noise: return "Noise";
case gin::Wave::wavetable:
default:
jassertfalse;
return {};
}
}
static String lfoTextFunction (const Parameter&, float v)
static juce::String lfoTextFunction (const gin::Parameter&, float v)
{
switch ((LFO::WaveShape)int (v))
switch ((gin::LFO::WaveShape)int (v))
{
case LFO::WaveShape::none: return "None";
case LFO::WaveShape::sine: return "Sine";
case LFO::WaveShape::triangle: return "Triangle";
case LFO::WaveShape::sawUp: return "Saw Up";
case LFO::WaveShape::sawDown: return "Saw Down";
case LFO::WaveShape::square: return "Square";
case LFO::WaveShape::squarePos: return "Square+";
case LFO::WaveShape::sampleAndHold: return "S&H";
case LFO::WaveShape::noise: return "Noise";
case LFO::WaveShape::stepUp3: return "Step Up 3";
case LFO::WaveShape::stepUp4: return "Step Up 4";
case LFO::WaveShape::stepup8: return "Step Up 8";
case LFO::WaveShape::stepDown3: return "Step Down 3";
case LFO::WaveShape::stepDown4: return "Step Down 4";
case LFO::WaveShape::stepDown8: return "Step Down 8";
case LFO::WaveShape::pyramid3: return "Pyramid 3";
case LFO::WaveShape::pyramid5: return "Pyramid 5";
case LFO::WaveShape::pyramid9: return "Pyramid 9";
case gin::LFO::WaveShape::none: return "None";
case gin::LFO::WaveShape::sine: return "Sine";
case gin::LFO::WaveShape::triangle: return "Triangle";
case gin::LFO::WaveShape::sawUp: return "Saw Up";
case gin::LFO::WaveShape::sawDown: return "Saw Down";
case gin::LFO::WaveShape::square: return "Square";
case gin::LFO::WaveShape::squarePos: return "Square+";
case gin::LFO::WaveShape::sampleAndHold: return "S&H";
case gin::LFO::WaveShape::noise: return "Noise";
case gin::LFO::WaveShape::stepUp3: return "Step Up 3";
case gin::LFO::WaveShape::stepUp4: return "Step Up 4";
case gin::LFO::WaveShape::stepup8: return "Step Up 8";
case gin::LFO::WaveShape::stepDown3: return "Step Down 3";
case gin::LFO::WaveShape::stepDown4: return "Step Down 4";
case gin::LFO::WaveShape::stepDown8: return "Step Down 8";
case gin::LFO::WaveShape::pyramid3: return "Pyramid 3";
case gin::LFO::WaveShape::pyramid5: return "Pyramid 5";
case gin::LFO::WaveShape::pyramid9: return "Pyramid 9";
default:
jassertfalse;
return {};
}
}
static String enableTextFunction (const Parameter&, float v)
static juce::String enableTextFunction (const gin::Parameter&, float v)
{
return v > 0.0f ? "On" : "Off";
}
static String durationTextFunction (const Parameter&, float v)
static juce::String durationTextFunction (const gin::Parameter&, float v)
{
return NoteDuration::getNoteDurations()[size_t (v)].getName();
return gin::NoteDuration::getNoteDurations()[size_t (v)].getName();
}
static String distortionAmountTextFunction (const Parameter&, float v)
static juce::String distortionAmountTextFunction (const gin::Parameter&, float v)
{
return String (v * 5.0f - 1.0f, 1);
return juce::String (v * 5.0f - 1.0f, 1);
}
static String filterTextFunction (const Parameter&, float v)
static juce::String filterTextFunction (const gin::Parameter&, float v)
{
switch (int (v))
{
@ -82,12 +82,12 @@ static String filterTextFunction (const Parameter&, float v)
}
}
static String freqTextFunction (const Parameter&, float v)
static juce::String freqTextFunction (const gin::Parameter&, float v)
{
return String (int (getMidiNoteInHertz (v)));
return juce::String (int (gin::getMidiNoteInHertz (v)));
}
static String glideModeTextFunction (const Parameter&, float v)
static juce::String glideModeTextFunction (const gin::Parameter&, float v)
{
switch (int (v))
{
@ -100,33 +100,13 @@ static String glideModeTextFunction (const Parameter&, float v)
}
}
//==============================================================================
void WavetableAudioProcessor::WTParams::setup (WavetableAudioProcessor& p, int idx)
{
String id = "wt" + String (idx + 1);
String nm = "WT" + String (idx + 1) + " ";
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, idx == 0 ? 1.0f : 0.0f, 0.0f);
table = p.addExtParam (id + "table", nm + "Table", "Table", "", { 0.0, 1.0, 0.0, 1.0 }, 0.0f, 0.0f);
voices = p.addIntParam (id + "unison", nm + "Unison", "Unison", "", { 1.0, 8.0, 1.0, 1.0 }, 1.0, 0.0f);
voicesTrns = p.addExtParam (id + "unisontrns", nm + "Unison Trns", "LTrans", "st", { -36.0, 36.0, 1.0, 1.0 }, 0.0, 0.0f);
tune = p.addExtParam (id + "tune", nm + "Tune", "Tune", "st", { -36.0, 36.0, 1.0, 1.0 }, 0.0, 0.0f);
finetune = p.addExtParam (id + "finetune", nm + "Fine Tune", "Fine", "ct", { -100.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f);
level = p.addExtParam (id + "level", nm + "Level", "Level", "db", { -100.0, 0.0, 1.0, 4.0 }, 0.0, 0.0f);
detune = p.addExtParam (id + "detune", nm + "Detune", "Detune", "", { 0.0, 0.5, 0.0, 1.0 }, 0.0, 0.0f);
spread = p.addExtParam (id + "spread", nm + "Spread", "Spread", "%", { -100.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f);
pan = p.addExtParam (id + "pan", nm + "Pan", "Pan", "", { -1.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f);
level->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
}
//==============================================================================
void WavetableAudioProcessor::OSCParams::setup (WavetableAudioProcessor& p, int idx)
{
String id = "osc" + String (idx + 1);
String nm = "OSC" + String (idx + 1) + " ";
juce::String id = "osc" + juce::String (idx + 1);
juce::String nm = "OSC" + juce::String (idx + 1) + " ";
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f);
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, idx == 0 ? 1.0f : 0.0f, 0.0f);
wave = p.addIntParam (id + "wave", nm + "Wave", "Wave", "", { 1.0, 7.0, 1.0, 1.0 }, 1.0, 0.0f, waveTextFunction);
voices = p.addIntParam (id + "unison", nm + "Unison", "Unison", "", { 1.0, 8.0, 1.0, 1.0 }, 1.0, 0.0f);
voicesTrns = p.addExtParam (id + "unisontrns", nm + "Unison Trns", "LTrans", "st", { -36.0, 36.0, 1.0, 1.0 }, 0.0, 0.0f);
@ -138,16 +118,16 @@ void WavetableAudioProcessor::OSCParams::setup (WavetableAudioProcessor& p, int
spread = p.addExtParam (id + "spread", nm + "Spread", "Spread", "%", { -100.0, 100.0, 0.0, 1.0 }, 0.0, 0.0f);
pan = p.addExtParam (id + "pan", nm + "Pan", "Pan", "", { -1.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f);
level->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
level->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
}
//==============================================================================
void WavetableAudioProcessor::FilterParams::setup (WavetableAudioProcessor& p, int idx)
{
String id = "flt" + String (idx + 1);
String nm = "FLT" + String (idx + 1) + " ";
juce::String id = "flt" + juce::String (idx + 1);
juce::String nm = "FLT" + juce::String (idx + 1) + " ";
float maxFreq = float (getMidiNoteFromHertz (20000.0));
float maxFreq = float (gin::getMidiNoteFromHertz (20000.0));
enable = p.addIntParam (id + "enable", nm + "Enable", "", "", { 0.0, 1.0, 1.0, 1.0 }, idx == 0 ? 1.0f : 0.0f, 0.0f);
type = p.addIntParam (id + "type", nm + "Type", "Type", "", { 0.0, 7.0, 1.0, 1.0 }, 0.0, 0.0f, filterTextFunction);
@ -169,8 +149,8 @@ void WavetableAudioProcessor::FilterParams::setup (WavetableAudioProcessor& p, i
//==============================================================================
void WavetableAudioProcessor::EnvParams::setup (WavetableAudioProcessor& p, int idx)
{
String id = "env" + String (idx + 1);
String nm = "ENV" + String (idx + 1) + " ";
juce::String id = "env" + juce::String (idx + 1);
juce::String nm = "ENV" + juce::String (idx + 1) + " ";
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0, 0.0f, enableTextFunction);
attack = p.addExtParam (id + "attack", nm + "Attack", "A", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f);
@ -184,10 +164,10 @@ void WavetableAudioProcessor::EnvParams::setup (WavetableAudioProcessor& p, int
//==============================================================================
void WavetableAudioProcessor::LFOParams::setup (WavetableAudioProcessor& p, int idx)
{
String id = "lfo" + String (idx + 1);
String nm = "LFO" + String (idx + 1) + " ";
juce::String id = "lfo" + juce::String (idx + 1);
juce::String nm = "LFO" + juce::String (idx + 1) + " ";
auto notes = NoteDuration::getNoteDurations();
auto notes = gin::NoteDuration::getNoteDurations();
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction);
sync = p.addIntParam (id + "sync", nm + "Sync", "Sync", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0, 0.0f, enableTextFunction);
@ -204,10 +184,10 @@ void WavetableAudioProcessor::LFOParams::setup (WavetableAudioProcessor& p, int
//==============================================================================
void WavetableAudioProcessor::StepLFOParams::setup (WavetableAudioProcessor& p)
{
String id = "slfo";
String nm = "Step LFO";
juce::String id = "slfo";
juce::String nm = "Step LFO";
auto notes = NoteDuration::getNoteDurations();
auto notes = gin::NoteDuration::getNoteDurations();
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction);
beat = p.addIntParam (id + "beat", nm + "Beat", "Beat", "", { 0.0, float (notes.size() - 1), 1.0, 1.0 }, 13.0, 0.0f, durationTextFunction);
@ -215,7 +195,7 @@ void WavetableAudioProcessor::StepLFOParams::setup (WavetableAudioProcessor& p)
for (int i = 0; i < 32; i++)
{
auto num = String (i + 1);
auto num = juce::String (i + 1);
level[i] = p.addIntParam (id + "step" + num, nm + "Step " + num, "", "", { -1.0, 1.0, 0.0, 1.0f }, 0.0f, 0.0f);
}
}
@ -223,20 +203,20 @@ void WavetableAudioProcessor::StepLFOParams::setup (WavetableAudioProcessor& p)
//==============================================================================
void WavetableAudioProcessor::GateParams::setup (WavetableAudioProcessor& p)
{
String id = "gate";
String nm = "Gate";
juce::String id = "gate";
juce::String nm = "Gate";
auto notes = NoteDuration::getNoteDurations();
auto notes = gin::NoteDuration::getNoteDurations();
enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction);
beat = p.addIntParam (id + "beat", nm + "Beat", "Beat", "", { 0.0, float (notes.size() - 1), 1.0, 1.0 }, 7.0, 0.0f, durationTextFunction);
length = p.addIntParam (id + "length", nm + "Length", "Length", "", { 2.0, 32.0, 1.0, 1.0f }, 8.0f, 0.0f);
attack = p.addExtParam (id + "attack", nm + "Attack", "A", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f);
release = p.addExtParam (id + "release", nm + "Release", "R", "s", { 0.0, 60.0, 0.0, 0.2f }, 0.1f, 0.0f);
attack = p.addExtParam (id + "attack", nm + "Attack", "A", "s", { 0.0, 1.0, 0.0, 0.2f }, 0.1f, 0.0f);
release = p.addExtParam (id + "release", nm + "Release", "R", "s", { 0.0, 1.0, 0.0, 0.2f }, 0.1f, 0.0f);
for (int i = 0; i < 32; i++)
{
auto num = String (i + 1);
auto num = juce::String (i + 1);
l[i] = p.addIntParam (id + "l" + num, nm + "L " + num, "", "", { 0.0, 1.0, 1.0, 1.0f }, (i % 2 == 0 || i % 5 == 0) ? 1.0f : 0.0f, 0.0f);
r[i] = p.addIntParam (id + "r" + num, nm + "R " + num, "", "", { 0.0, 1.0, 1.0, 1.0f }, (i % 2 == 0 || i % 5 == 0) ? 1.0f : 0.0f, 0.0f);
}
@ -266,7 +246,7 @@ void WavetableAudioProcessor::GlobalParams::setup (WavetableAudioProcessor& p)
voices = p.addIntParam ("voices", "Voices", "", "", { 2.0, 40.0, 1.0, 1.0 }, 40.0f, 0.0f);
mpe = p.addIntParam ("mpe", "MPE", "", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction);
level->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
level->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
}
//==============================================================================
@ -296,11 +276,11 @@ void WavetableAudioProcessor::DistortionParams::setup (WavetableAudioProcessor&
//==============================================================================
void WavetableAudioProcessor::EQParams::setup (WavetableAudioProcessor& p)
{
float maxFreq = float (getMidiNoteFromHertz (20000.0));
float d1 = float (getMidiNoteFromHertz (80.0));
float d2 = float (getMidiNoteFromHertz (3000.0));
float d3 = float (getMidiNoteFromHertz (5000.0));
float d4 = float (getMidiNoteFromHertz (17000.0));
float maxFreq = float (gin::getMidiNoteFromHertz (20000.0));
float d1 = float (gin::getMidiNoteFromHertz (80.0));
float d2 = float (gin::getMidiNoteFromHertz (3000.0));
float d3 = float (gin::getMidiNoteFromHertz (5000.0));
float d4 = float (gin::getMidiNoteFromHertz (17000.0));
enable = p.addIntParam ("eqEnable", "Enable", "", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction);
@ -320,15 +300,15 @@ void WavetableAudioProcessor::EQParams::setup (WavetableAudioProcessor& p)
hiQ = p.addExtParam ("eqHiQ", "Hi Q", "Q", "", { 0.025f, 40.0f, 0.0, 0.2f }, 1.0f, 0.0f);
hiGain = p.addExtParam ("eqHiGain", "Hi Gain", "Gain", "dB", { -20.0f, 20.0f, 0.0, 1.0 }, 0.0f, 0.0f);
loFreq->conversionFunction = [] (float in) { return getMidiNoteInHertz (in); };
mid1Freq->conversionFunction = [] (float in) { return getMidiNoteInHertz (in); };
mid2Freq->conversionFunction = [] (float in) { return getMidiNoteInHertz (in); };
hiFreq->conversionFunction = [] (float in) { return getMidiNoteInHertz (in); };
loFreq->conversionFunction = [] (float in) { return gin::getMidiNoteInHertz (in); };
mid1Freq->conversionFunction = [] (float in) { return gin::getMidiNoteInHertz (in); };
mid2Freq->conversionFunction = [] (float in) { return gin::getMidiNoteInHertz (in); };
hiFreq->conversionFunction = [] (float in) { return gin::getMidiNoteInHertz (in); };
loGain->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
mid1Gain->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
mid2Gain->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
hiGain->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
loGain->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
mid1Gain->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
mid2Gain->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
hiGain->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
}
//==============================================================================
@ -344,7 +324,7 @@ void WavetableAudioProcessor::CompressorParams::setup (WavetableAudioProcessor&
attack->conversionFunction = [] (float in) { return in / 1000.0f; };
release->conversionFunction = [] (float in) { return in / 1000.0f; };
gain->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
gain->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
}
//==============================================================================
@ -352,7 +332,7 @@ void WavetableAudioProcessor::DelayParams::setup (WavetableAudioProcessor& p)
{
enable = p.addIntParam ("dlEnable", "Enable", "", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f, enableTextFunction);
float mxd = float (NoteDuration::getNoteDurations().size()) - 1.0f;
float mxd = float (gin::NoteDuration::getNoteDurations().size()) - 1.0f;
sync = p.addExtParam ("dlSync", "Sync", "", "", { 0.0f, 1.0f, 1.0f, 1.0f}, 0.0f, 0.0f, enableTextFunction);
time = p.addExtParam ("dlTime", "Delay", "", "", { 0.0f, 120.0f, 0.0f, 0.3f}, 1.0f, 0.0f);
@ -361,10 +341,10 @@ void WavetableAudioProcessor::DelayParams::setup (WavetableAudioProcessor& p)
cf = p.addExtParam ("dlCf", "CF", "", "dB", {-100.0f, 0.0f, 0.0f, 5.0f}, -100.0f, 0.1f);
mix = p.addExtParam ("dlMix", "Mix", "", "%", { 0.0f, 100.0f, 0.0f, 1.0f}, 0.5f, 0.1f);
delay = p.addIntParam ("dlDelay", "Delay", "", "", { 0.0f, 120.0f, 0.0f, 1.0f}, 1.0f, {0.2f, SmoothingType::eased});
delay = p.addIntParam ("dlDelay", "Delay", "", "", { 0.0f, 120.0f, 0.0f, 1.0f}, 1.0f, {0.2f, gin::SmoothingType::eased});
fb->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
cf->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
fb->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
cf->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
mix->conversionFunction = [] (float in) { return in / 100.0f; };
}
@ -392,30 +372,27 @@ void WavetableAudioProcessor::LimiterParams::setup (WavetableAudioProcessor& p)
attack->conversionFunction = [] (float in) { return in / 1000.0f; };
release->conversionFunction = [] (float in) { return in / 1000.0f; };
gain->conversionFunction = [] (float in) { return Decibels::decibelsToGain (in); };
gain->conversionFunction = [] (float in) { return juce::Decibels::decibelsToGain (in); };
}
//==============================================================================
WavetableAudioProcessor::WavetableAudioProcessor()
{
formatManager->registerBasicFormats();
lf = std::make_unique<gin::CopperLookAndFeel>();
enableLegacyMode();
setVoiceStealingEnabled (true);
for (int i = 0; i < numElementsInArray (wtParams); i++)
wtParams[i].setup (*this, i);
for (int i = 0; i < numElementsInArray (oscParams); i++)
for (int i = 0; i < juce::numElementsInArray (oscParams); i++)
oscParams[i].setup (*this, i);
for (int i = 0; i < numElementsInArray (filterParams); i++)
for (int i = 0; i < juce::numElementsInArray (filterParams); i++)
filterParams[i].setup (*this, i);
for (int i = 0; i < numElementsInArray (envParams); i++)
for (int i = 0; i < juce::numElementsInArray (envParams); i++)
envParams[i].setup (*this, i);
for (int i = 0; i < numElementsInArray (lfoParams); i++)
for (int i = 0; i < juce::numElementsInArray (lfoParams); i++)
lfoParams[i].setup (*this, i);
stepLfoParams.setup (*this);
@ -443,9 +420,6 @@ WavetableAudioProcessor::WavetableAudioProcessor()
}
setupModMatrix();
MemoryBlock mb (BinaryData::WINDOW_S_WAV, BinaryData::WINDOW_S_WAVSize);
updateWavetable (0, mb, 256);
}
WavetableAudioProcessor::~WavetableAudioProcessor()
@ -476,27 +450,27 @@ void WavetableAudioProcessor::setupModMatrix()
for (int i = 0; i <= 119; i++)
{
String name = MidiMessage::getControllerName (i);
juce::String name = juce::MidiMessage::getControllerName (i);
if (name.isEmpty())
modSrcCC.add (modMatrix.addMonoModSource (String::formatted ("cc%d", i), String::formatted ("CC %d", i), false));
modSrcCC.add (modMatrix.addMonoModSource (juce::String::formatted ("cc%d", i), juce::String::formatted ("CC %d", i), false));
else
modSrcCC.add (modMatrix.addMonoModSource (String::formatted ("cc%d", i), String::formatted ("CC %d ", i) + name, false));
modSrcCC.add (modMatrix.addMonoModSource (juce::String::formatted ("cc%d", i), juce::String::formatted ("CC %d ", i) + name, false));
}
for (int i = 0; i < Cfg::numLFOs; i++)
modSrcMonoLFO.add (modMatrix.addMonoModSource (String::formatted ("mlfo%d", i + 1), String::formatted ("LFO %d (Mono)", i + 1), true));
modSrcMonoLFO.add (modMatrix.addMonoModSource (juce::String::formatted ("mlfo%d", i + 1), juce::String::formatted ("LFO %d (Mono)", i + 1), true));
for (int i = 0; i < Cfg::numLFOs; i++)
modSrcLFO.add (modMatrix.addPolyModSource (String::formatted ("lfo%d", i + 1), String::formatted ("LFO %d", i + 1), true));
modSrcLFO.add (modMatrix.addPolyModSource (juce::String::formatted ("lfo%d", i + 1), juce::String::formatted ("LFO %d", i + 1), true));
modSrcMonoStep = modMatrix.addMonoModSource ("mstep", "Step LFO (Mono)", true);
modSrcStep = modMatrix.addPolyModSource ("step", "Step LFO", true);
for (int i = 0; i < Cfg::numFilters; i++)
modSrcFilter.add (modMatrix.addPolyModSource (String::formatted ("fenv%d", i + 1), String::formatted ("Filter Envelope %d", i + 1), false));
modSrcFilter.add (modMatrix.addPolyModSource (juce::String::formatted ("fenv%d", i + 1), juce::String::formatted ("Filter Envelope %d", i + 1), false));
for (int i = 0; i < Cfg::numENVs; i++)
modSrcEnv.add (modMatrix.addPolyModSource (String::formatted ("env%d", i + 1), String::formatted ("Envelope %d", i + 1), false));
modSrcEnv.add (modMatrix.addPolyModSource (juce::String::formatted ("env%d", i + 1), juce::String::formatted ("Envelope %d", i + 1), false));
auto firstMonoParam = globalParams.mono;
bool polyParam = true;
@ -565,9 +539,9 @@ void WavetableAudioProcessor::releaseResources()
{
}
void WavetableAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi)
void WavetableAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midi)
{
ScopedNoDenormals noDenormals;
juce::ScopedNoDenormals noDenormals;
startBlock();
setMPE (globalParams.mpe->isOn());
@ -594,8 +568,8 @@ void WavetableAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuff
renderNextBlock (buffer, midi, pos, thisBlock);
auto slice = sliceBuffer (buffer, pos, thisBlock);
applyEffects (slice);
auto bufferSlice = gin::sliceBuffer (buffer, pos, thisBlock);
applyEffects (bufferSlice);
modMatrix.finishBlock (thisBlock);
@ -609,9 +583,9 @@ void WavetableAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuff
endBlock (buffer.getNumSamples());
}
Array<float> WavetableAudioProcessor::getLiveFilterCutoff (int i)
juce::Array<float> WavetableAudioProcessor::getLiveFilterCutoff (int i)
{
Array<float> values;
juce::Array<float> values;
for (auto v : voices)
{
@ -624,7 +598,7 @@ Array<float> WavetableAudioProcessor::getLiveFilterCutoff (int i)
return values;
}
void WavetableAudioProcessor::applyEffects (AudioSampleBuffer& buffer)
void WavetableAudioProcessor::applyEffects (juce::AudioSampleBuffer& buffer)
{
// Apply gate
if (gateParams.enable->isOn())
@ -669,15 +643,15 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
{
if (lfoParams[i].enable->isOn())
{
LFO::Parameters params;
gin::LFO::Parameters params;
float freq = 0;
if (lfoParams[i].sync->getProcValue() > 0.0f)
freq = 1.0f / NoteDuration::getNoteDurations()[size_t (lfoParams[i].beat->getProcValue())].toSeconds (playhead);
freq = 1.0f / gin::NoteDuration::getNoteDurations()[size_t (lfoParams[i].beat->getProcValue())].toSeconds (playhead);
else
freq = modMatrix.getValue (lfoParams[i].rate);
params.waveShape = (LFO::WaveShape) int (lfoParams[i].wave->getProcValue());
params.waveShape = (gin::LFO::WaveShape) int (lfoParams[i].wave->getProcValue());
params.frequency = freq;
params.phase = modMatrix.getValue (lfoParams[i].phase);
params.offset = modMatrix.getValue (lfoParams[i].offset);
@ -699,7 +673,7 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
// Update Mono Step LFO
if (stepLfoParams.enable->isOn())
{
float freq = 1.0f / NoteDuration::getNoteDurations()[size_t (stepLfoParams.beat->getProcValue())].toSeconds (playhead);
float freq = 1.0f / gin::NoteDuration::getNoteDurations()[size_t (stepLfoParams.beat->getProcValue())].toSeconds (playhead);
modStepLFO.setFreq (freq);
@ -720,7 +694,7 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
// Update Gate
if (gateParams.enable->isOn())
{
float freq = 1.0f / NoteDuration::getNoteDurations()[size_t (gateParams.beat->getProcValue())].toSeconds (playhead);
float freq = 1.0f / gin::NoteDuration::getNoteDurations()[size_t (gateParams.beat->getProcValue())].toSeconds (playhead);
int n = int (gateParams.length->getProcValue());
@ -757,22 +731,22 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
// Update EQ
if (eqParams.enable->isOn())
{
eq.setParams (0, EQ::lowshelf,
eq.setParams (0, gin::EQ::lowshelf,
modMatrix.getValue (eqParams.loFreq),
modMatrix.getValue (eqParams.loQ),
modMatrix.getValue (eqParams.loGain));
eq.setParams (1, EQ::peak,
eq.setParams (1, gin::EQ::peak,
modMatrix.getValue (eqParams.mid1Freq),
modMatrix.getValue (eqParams.mid1Q),
modMatrix.getValue (eqParams.mid1Gain));
eq.setParams (2, EQ::peak,
eq.setParams (2, gin::EQ::peak,
modMatrix.getValue (eqParams.mid2Freq),
modMatrix.getValue (eqParams.mid2Q),
modMatrix.getValue (eqParams.mid2Gain));
eq.setParams (3, EQ::highshelf,
eq.setParams (3, gin::EQ::highshelf,
modMatrix.getValue (eqParams.hiFreq),
modMatrix.getValue (eqParams.hiQ),
modMatrix.getValue (eqParams.hiGain));
@ -784,6 +758,7 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
compressor.setInputGain (1.0f);
compressor.setOutputGain (modMatrix.getValue (compressorParams.gain));
compressor.setParams (modMatrix.getValue (compressorParams.attack),
0,
modMatrix.getValue (compressorParams.release),
modMatrix.getValue (compressorParams.threshold),
modMatrix.getValue (compressorParams.ratio),
@ -795,7 +770,7 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
{
if (delayParams.sync->isOn())
{
auto& duration = NoteDuration::getNoteDurations()[(size_t)delayParams.beat->getUserValueInt()];
auto& duration = gin::NoteDuration::getNoteDurations()[(size_t)delayParams.beat->getUserValueInt()];
delayParams.delay->setUserValue (duration.toSeconds (getPlayHead()));
}
else
@ -813,10 +788,10 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
// Update Reverb
if (reverbParams.enable->isOn())
{
Reverb::Parameters p;
juce::Reverb::Parameters p;
auto mix = modMatrix.getValue (reverbParams.mix);
WetDryMix wetDry (mix);
gin::WetDryMix wetDry (mix);
p.damping = modMatrix.getValue (reverbParams.damping);
p.freezeMode = modMatrix.getValue (reverbParams.freezeMode);
@ -834,6 +809,7 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
limiter.setInputGain (1.0f);
limiter.setOutputGain (modMatrix.getValue (limiterParams.gain));
limiter.setParams (modMatrix.getValue (limiterParams.attack),
0,
modMatrix.getValue (limiterParams.release),
modMatrix.getValue (limiterParams.threshold),
100, 6);
@ -843,7 +819,7 @@ void WavetableAudioProcessor::updateParams (int newBlockSize)
outputGain.setGain (modMatrix.getValue (globalParams.level));
}
void WavetableAudioProcessor::handleMidiEvent (const MidiMessage& m)
void WavetableAudioProcessor::handleMidiEvent (const juce::MidiMessage& m)
{
MPESynthesiser::handleMidiEvent (m);
@ -856,36 +832,20 @@ void WavetableAudioProcessor::handleController ([[maybe_unused]] int ch, int num
modMatrix.setMonoValue (modSrcCC[num], val / 127.0f);
}
void WavetableAudioProcessor::updateWavetable (int idx, MemoryBlock& src, int tableSize)
{
if (auto reader = std::unique_ptr<AudioFormatReader> (formatManager->createReaderFor (std::make_unique<MemoryInputStream> (src, false))))
{
AudioSampleBuffer buffer;
buffer.setSize (1, int (reader->lengthInSamples));
reader->read (&buffer, 0, int (reader->lengthInSamples), 0, true, false);
loadWavetables (waveTables[idx], buffer, reader->sampleRate, tableSize);
for (auto v : voices)
if (auto wtv = dynamic_cast<WavetableVoice*>(v))
wtv->setWavetable (idx, waveTables[idx]);
}
}
//==============================================================================
bool WavetableAudioProcessor::hasEditor() const
{
return true;
}
AudioProcessorEditor* WavetableAudioProcessor::createEditor()
juce::AudioProcessorEditor* WavetableAudioProcessor::createEditor()
{
return new WavetableAudioProcessorEditor (*this);
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new WavetableAudioProcessor();
}