Toob Flanger, Stereo Reverb, bug fixes

- support state in factory presets.
- Use uncompressed json for settings files.
- Set current plugin preset name to last loaded plugin preset.
- Append plugins after  start node,  before end node fixed.
- Correctly release web socket when web app goes idle.
- Fit and finish issues.
This commit is contained in:
Robin Davies
2023-06-07 04:57:13 -04:00
parent 9dcbf3d00b
commit a3dca9fa5c
133 changed files with 2715 additions and 998 deletions
+261 -34
View File
@@ -25,8 +25,8 @@
using namespace pipedal;
static std::shared_ptr<Lv2PortInfo> MakeBypassPortInfo() {
static std::shared_ptr<Lv2PortInfo> MakeBypassPortInfo()
{
std::shared_ptr<Lv2PortInfo> bypassPortInfo = std::make_shared<Lv2PortInfo>();
bypassPortInfo->symbol("__bypass");
bypassPortInfo->name("Bypass");
@@ -49,10 +49,8 @@ const Lv2PortInfo *pipedal::GetBypassPortInfo()
}
// Just enough to do control value defaulting, and midi value mapping :-/
static Lv2PluginInfo makeSplitterPluginInfo() {
static Lv2PluginInfo makeSplitterPluginInfo()
{
Lv2PluginInfo result;
result.uri(SPLIT_PEDALBOARD_ITEM_URI);
result.name("Split");
@@ -60,7 +58,7 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
result.comment("Internal only.");
result.is_valid(true);
std::shared_ptr<Lv2PortInfo> splitTypeControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> splitTypeControl = std::make_shared<Lv2PortInfo>();
splitTypeControl->symbol(SPLIT_SPLITTYPE_KEY);
splitTypeControl->name("Type");
splitTypeControl->is_input(true);
@@ -71,18 +69,14 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
splitTypeControl->default_value(0);
splitTypeControl->enumeration_property(true);
splitTypeControl->scale_points().push_back(
Lv2ScalePoint(0,"A/B")
);
Lv2ScalePoint(0, "A/B"));
splitTypeControl->scale_points().push_back(
Lv2ScalePoint(1,"Mix")
);
Lv2ScalePoint(1, "Mix"));
splitTypeControl->scale_points().push_back(
Lv2ScalePoint(1,"L/R")
);
Lv2ScalePoint(1, "L/R"));
result.ports().push_back(splitTypeControl);
std::shared_ptr<Lv2PortInfo> abControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> abControl = std::make_shared<Lv2PortInfo>();
abControl->symbol(SPLIT_SELECT_KEY);
abControl->name("Select");
abControl->is_input(true);
@@ -93,14 +87,12 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
abControl->default_value(0);
abControl->enumeration_property(true);
abControl->scale_points().push_back(
Lv2ScalePoint(0,"A")
);
Lv2ScalePoint(0, "A"));
abControl->scale_points().push_back(
Lv2ScalePoint(1,"B")
);
Lv2ScalePoint(1, "B"));
result.ports().push_back(abControl);
std::shared_ptr<Lv2PortInfo> mixControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> mixControl = std::make_shared<Lv2PortInfo>();
mixControl->symbol(SPLIT_MIX_KEY);
mixControl->name("Mix");
mixControl->is_input(true);
@@ -112,7 +104,7 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
result.ports().push_back(mixControl);
std::shared_ptr<Lv2PortInfo> panLControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> panLControl = std::make_shared<Lv2PortInfo>();
panLControl->symbol(SPLIT_PANL_KEY);
panLControl->name("Pan L");
panLControl->is_input(true);
@@ -124,7 +116,7 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
result.ports().push_back(panLControl);
std::shared_ptr<Lv2PortInfo> volLControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> volLControl = std::make_shared<Lv2PortInfo>();
volLControl->symbol(SPLIT_VOLL_KEY);
volLControl->name("Vol L");
volLControl->is_input(true);
@@ -134,12 +126,11 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
volLControl->max_value(12);
volLControl->default_value(-3);
volLControl->scale_points().push_back(
Lv2ScalePoint(-60,"-INF")
);
Lv2ScalePoint(-60, "-INF"));
result.ports().push_back(volLControl);
std::shared_ptr<Lv2PortInfo> panRControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> panRControl = std::make_shared<Lv2PortInfo>();
panRControl->symbol(SPLIT_PANR_KEY);
panRControl->name("Pan R");
panRControl->is_input(true);
@@ -151,7 +142,7 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
result.ports().push_back(panRControl);
std::shared_ptr<Lv2PortInfo> volRControl= std::make_shared<Lv2PortInfo>();
std::shared_ptr<Lv2PortInfo> volRControl = std::make_shared<Lv2PortInfo>();
volRControl->symbol(SPLIT_VOLR_KEY);
volRControl->name("Vol R");
volRControl->is_input(true);
@@ -161,24 +152,260 @@ static Lv2PluginInfo makeSplitterPluginInfo() {
volRControl->max_value(12);
volRControl->default_value(-3);
volRControl->scale_points().push_back(
Lv2ScalePoint(-60,"-INF")
);
Lv2ScalePoint(-60, "-INF"));
result.ports().push_back(volRControl);
return result;
}
Lv2PluginInfo g_splitterPluginInfo = makeSplitterPluginInfo();
const Lv2PluginInfo * pipedal::GetSplitterPluginInfo() { return &g_splitterPluginInfo; }
const Lv2PluginInfo *pipedal::GetSplitterPluginInfo() { return &g_splitterPluginInfo; }
int SplitEffect::GetControlIndex(const std::string &symbol) const
{
if (symbol == "splitType")
return SPLIT_TYPE_CTL;
if (symbol == "select")
return SELECT_CTL;
if (symbol == "mix")
return MIX_CTL;
if (symbol == "panL")
return PANL_CTL;
if (symbol == "volL")
return VOLL_CTL;
if (symbol == "panR")
return PANR_CTL;
if (symbol == "volR")
return VOLR_CTL;
return -1;
}
void SplitEffect::Activate()
{
activated = true;
updateMixFunction();
snapToMixTarget();
mixBottomInputs.clear();
mixTopInputs.clear();
if (outputBuffers.size() == 1)
{
mixTopInputs.push_back(this->topOutputs[0]);
mixBottomInputs.push_back(this->bottomOutputs[0]);
}
else
{
if (this->topOutputs.size() == 1)
{
mixTopInputs.push_back(topOutputs[0]);
mixTopInputs.push_back(topOutputs[0]);
}
else
{
mixTopInputs.push_back(topOutputs[0]);
mixTopInputs.push_back(topOutputs[1]);
}
if (this->bottomOutputs.size() == 1)
{
mixBottomInputs.push_back(bottomOutputs[0]);
mixBottomInputs.push_back(bottomOutputs[0]);
}
else
{
mixBottomInputs.push_back(bottomOutputs[0]);
mixBottomInputs.push_back(bottomOutputs[1]);
}
}
}
void SplitEffect::Deactivate()
{
activated = false;
}
void SplitEffect::SetChainBuffers(
const std::vector<float *> &topInputs,
const std::vector<float *> &bottomInputs,
const std::vector<float *> &topOutputs,
const std::vector<float *> &bottomOutputs,
bool forceStereo)
{
this->topInputs = topInputs;
this->bottomInputs = bottomInputs;
this->topOutputs = topOutputs;
this->bottomOutputs = bottomOutputs;
if (forceStereo)
{
numberOfOutputPorts = 2;
} else {
if (topOutputs.size() > 1 || bottomOutputs.size() > 1)
{
numberOfOutputPorts = 2;
} else {
numberOfOutputPorts = 1;
}
}
if (this->topOutputs.size() == 1 && numberOfOutputPorts != 1)
{
this->topOutputs.push_back(this->topOutputs[0]);
}
if (this->bottomOutputs.size() == 1 && numberOfOutputPorts != 1)
{
this->bottomOutputs.push_back(this->bottomOutputs[0]);
}
outputBuffers.resize(numberOfOutputPorts);
}
void SplitEffect::snapToMixTarget()
{
this->blendLTop = targetBlendLTop;
this->blendRTop = targetBlendRTop;
this->blendRBottom = targetBlendRBottom;
this->blendLBottom = targetBlendLBottom;
this->blendFadeSamples = 0;
this->blendDxLTop = 0;
this->blendDxRTop = 0;
this->blendDxLBottom = 0;
this->blendDxRBottom = 0;
}
void SplitEffect::mixToTarget()
{
uint32_t transitionSamples = (uint32_t)(this->sampleRate * MIX_TRANSITION_TIME_S);
if (transitionSamples < 1)
transitionSamples = 1;
double dxScale = 1.0 / transitionSamples;
this->blendFadeSamples = transitionSamples;
this->blendDxLTop = dxScale * (this->targetBlendLTop - this->blendLTop);
this->blendDxRTop = dxScale * (this->targetBlendRTop - this->blendRTop);
this->blendDxLBottom = dxScale * (this->targetBlendLBottom - this->blendLBottom);
this->blendDxRBottom = dxScale * (this->targetBlendRBottom - this->blendRBottom);
}
void SplitEffect::mixTo(float value)
{
float blend = (value + 1) * 0.5f;
this->targetBlendRTop = this->targetBlendLTop = 1 - blend;
this->targetBlendLBottom = this->targetBlendRBottom = blend;
mixToTarget();
}
void SplitEffect::mixTo(float panL, float volL, float panR, float volR)
{
float aTop = (volL <= SPLIT_DB_MIN) ? 0 : db2a(volL);
float aBottom = (volR <= SPLIT_DB_MIN) ? 0 : db2a(volR);
if (this->outputBuffers.size() == 1)
{
// ignore pan. The R values actually have no effect.
this->targetBlendLTop = this->targetBlendRTop = aTop;
this->targetBlendLBottom = this->targetBlendRBottom = aBottom;
}
else
{
float blendTop = (panL + 1) * 0.5;
float blendBottom = (panR + 1) * 0.5;
this->targetBlendLTop = (1 - blendTop) * aTop;
this->targetBlendRTop = (blendTop)*aTop;
this->targetBlendLBottom = (1 - blendBottom) * aBottom;
this->targetBlendRBottom = (blendBottom)*aBottom;
}
mixToTarget();
}
float SplitEffect::GetControlValue(int portIndex) const
{
switch (portIndex)
{
case -1: /* (bypass) */
return 1;
case SPLIT_TYPE_CTL:
{
return (int)(this->splitType);
}
case SELECT_CTL:
{
return selectA ? 0 : 1;
}
case MIX_CTL:
return mix;
case PANL_CTL:
return this->panL;
case VOLL_CTL:
return this->volL;
case PANR_CTL:
return this->panR;
case VOLR_CTL:
return this->volR;
default:
throw PiPedalArgumentException("Invalid argument");
}
}
void SplitEffect::SetControl(int index, float value)
{
switch (index)
{
case -1: /* (bypass) */
return; // no can bypass.
case SPLIT_TYPE_CTL:
{
SplitType t = valueToSplitType(value);
if (splitType != t)
{
splitType = t;
updateMixFunction();
}
break;
}
case SELECT_CTL:
{
bool t = value == 0;
if (selectA != t)
{
selectA = t;
if (splitType == SplitType::Ab)
{
mixTo(selectA ? -1 : 1);
}
}
break;
}
case MIX_CTL:
mix = value;
if (splitType == SplitType::Mix)
{
mixTo(value);
}
break;
case PANL_CTL:
panL = value;
if (splitType == SplitType::Lr)
{
mixTo(panL, volL, panR, volR);
}
break;
case VOLL_CTL:
volL = value;
if (splitType == SplitType::Lr)
{
mixTo(panL, volL, panR, volR);
}
break;
case PANR_CTL:
panR = value;
if (splitType == SplitType::Lr)
{
mixTo(panL, volL, panR, volR);
}
break;
case VOLR_CTL:
volR = value;
if (splitType == SplitType::Lr)
{
mixTo(panL, volL, panR, volR);
}
break;
}
}