feat(params): add parameters, macros, RAVE controls and resources
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
#include "RAVEButton.h"
|
||||
|
||||
namespace serum
|
||||
{
|
||||
|
||||
void RaveController::resetSnapshot()
|
||||
{
|
||||
snapshot.clear();
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
void RaveController::snapshotParam (const juce::String& id, juce::AudioProcessorValueTreeState& apvts)
|
||||
{
|
||||
if (auto* p = apvts.getParameter (id))
|
||||
snapshot.emplace_back (id, p->getValue());
|
||||
}
|
||||
|
||||
void RaveController::setParam (const juce::String& id, float value, juce::AudioProcessorValueTreeState& apvts)
|
||||
{
|
||||
if (auto* p = apvts.getParameter (id))
|
||||
p->setValueNotifyingHost (juce::jlimit (0.0f, 1.0f, value));
|
||||
}
|
||||
|
||||
void RaveController::setEnabled (bool shouldEnable, juce::AudioProcessorValueTreeState& apvts)
|
||||
{
|
||||
if (shouldEnable == enabled)
|
||||
return;
|
||||
|
||||
if (shouldEnable)
|
||||
{
|
||||
snapshot.clear();
|
||||
|
||||
// Snapshot the static "boost" parameters.
|
||||
const char* staticParams[] =
|
||||
{
|
||||
ids::oscAUnison, ids::oscBUnison,
|
||||
ids::oscASpread, ids::oscBSpread,
|
||||
ids::oscADetune, ids::oscBDetune,
|
||||
ids::f1Drive, ids::f2Drive
|
||||
};
|
||||
for (auto id : staticParams)
|
||||
snapshotParam (id, apvts);
|
||||
|
||||
// Snapshot + boost FX-specific params (Hyper intensity / Reverb mix).
|
||||
const char* fxMixIds[kNumFxSlots] = { ids::fx1Mix, ids::fx2Mix, ids::fx3Mix, ids::fx4Mix,
|
||||
ids::fx5Mix, ids::fx6Mix, ids::fx7Mix, ids::fx8Mix };
|
||||
const char* fxP1Ids[kNumFxSlots] = { ids::fx1P1, ids::fx2P1, ids::fx3P1, ids::fx4P1,
|
||||
ids::fx5P1, ids::fx6P1, ids::fx7P1, ids::fx8P1 };
|
||||
const char* fxTypeIds[kNumFxSlots] = { ids::fx1Type, ids::fx2Type, ids::fx3Type, ids::fx4Type,
|
||||
ids::fx5Type, ids::fx6Type, ids::fx7Type, ids::fx8Type };
|
||||
|
||||
for (int i = 0; i < kNumFxSlots; ++i)
|
||||
{
|
||||
const auto* typeParam = apvts.getParameter (fxTypeIds[i]);
|
||||
const int type = typeParam ? (int) (typeParam->getValue() * (int) FxType::Count) : 0;
|
||||
|
||||
if (type == (int) FxType::Hyper)
|
||||
{
|
||||
snapshotParam (fxP1Ids[i], apvts);
|
||||
setParam (fxP1Ids[i], 1.0f, apvts); // OTT intensity 100%
|
||||
}
|
||||
else if (type == (int) FxType::Reverb)
|
||||
{
|
||||
snapshotParam (fxMixIds[i], apvts);
|
||||
const float current = apvts.getParameter (fxMixIds[i])->getValue();
|
||||
setParam (fxMixIds[i], current + 0.4f, apvts); // reverb send +6dB-ish
|
||||
}
|
||||
}
|
||||
|
||||
// Apply boosts.
|
||||
setParam (ids::oscAUnison, 8.0f / 16.0f, apvts);
|
||||
setParam (ids::oscBUnison, 8.0f / 16.0f, apvts);
|
||||
setParam (ids::oscASpread, 1.0f, apvts);
|
||||
setParam (ids::oscBSpread, 1.0f, apvts);
|
||||
setParam (ids::oscADetune, 1.0f, apvts);
|
||||
setParam (ids::oscBDetune, 0.7f, apvts);
|
||||
setParam (ids::f1Drive, 0.6f, apvts);
|
||||
setParam (ids::f2Drive, 0.6f, apvts);
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& entry : snapshot)
|
||||
setParam (entry.first, entry.second, apvts);
|
||||
snapshot.clear();
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace serum
|
||||
Reference in New Issue
Block a user