| @@ -49,37 +49,56 @@ struct PeakFilter { | |||||
| struct SlewLimiter { | struct SlewLimiter { | ||||
| float rise = 1.f; | |||||
| float fall = 1.f; | |||||
| float out = 0.f; | |||||
| float rise = 0.f; | |||||
| float fall = 0.f; | |||||
| float out = NAN; | |||||
| void setRiseFall(float rise, float fall) { | |||||
| float process(float deltaTime, float in) { | |||||
| if (std::isnan(out)) { | |||||
| out = in; | |||||
| } | |||||
| else if (out < in) { | |||||
| float y = out + rise * deltaTime; | |||||
| out = std::fmin(y, in); | |||||
| } | |||||
| else if (out > in) { | |||||
| float y = out - fall * deltaTime; | |||||
| out = std::fmax(y, in); | |||||
| } | |||||
| return out; | |||||
| } | |||||
| DEPRECATED float process(float in) { | |||||
| return process(1.f, in); | |||||
| } | |||||
| DEPRECATED void setRiseFall(float rise, float fall) { | |||||
| this->rise = rise; | this->rise = rise; | ||||
| this->fall = fall; | this->fall = fall; | ||||
| } | } | ||||
| float process(float in) { | |||||
| out = math::clamp(in, out - fall, out + rise); | |||||
| return out; | |||||
| } | |||||
| }; | }; | ||||
| struct ExponentialSlewLimiter { | struct ExponentialSlewLimiter { | ||||
| float riseLambda = 1.f; | |||||
| float fallLambda = 1.f; | |||||
| float out = 0.f; | |||||
| float riseLambda = 0.f; | |||||
| float fallLambda = 0.f; | |||||
| float out = NAN; | |||||
| float process(float in) { | |||||
| if (in > out) { | |||||
| float y = out + (in - out) * riseLambda; | |||||
| float process(float deltaTime, float in) { | |||||
| if (std::isnan(out)) { | |||||
| out = in; | |||||
| } | |||||
| else if (out < in) { | |||||
| float y = out + (in - out) * riseLambda * deltaTime; | |||||
| out = (out == y) ? in : y; | out = (out == y) ? in : y; | ||||
| } | } | ||||
| else if (in < out) { | |||||
| float y = out + (in - out) * fallLambda; | |||||
| else if (out > in) { | |||||
| float y = out + (in - out) * fallLambda * deltaTime; | |||||
| out = (out == y) ? in : y; | out = (out == y) ? in : y; | ||||
| } | } | ||||
| return out; | return out; | ||||
| } | } | ||||
| DEPRECATED float process(float in) { | |||||
| return process(1.f, in); | |||||
| } | |||||
| }; | }; | ||||
| @@ -113,7 +132,9 @@ struct ExponentialFilter { | |||||
| return out; | return out; | ||||
| } | } | ||||
| DEPRECATED float process(float in) {return process(1.f, in);} | |||||
| DEPRECATED float process(float in) { | |||||
| return process(1.f, in); | |||||
| } | |||||
| }; | }; | ||||
| @@ -1,7 +1,8 @@ | |||||
| #pragma once | #pragma once | ||||
| #include "plugin/Model.hpp" | #include "plugin/Model.hpp" | ||||
| #include "ui/MenuLabel.hpp" | |||||
| #include "ui/MenuOverlay.hpp" | |||||
| #include "ui/MenuItem.hpp" | #include "ui/MenuItem.hpp" | ||||
| #include "ui/MenuLabel.hpp" | |||||
| #include "ui/Menu.hpp" | #include "ui/Menu.hpp" | ||||
| #include "app/PortWidget.hpp" | #include "app/PortWidget.hpp" | ||||
| #include "app/ParamQuantity.hpp" | #include "app/ParamQuantity.hpp" | ||||
| @@ -2,7 +2,6 @@ | |||||
| #include "ui/common.hpp" | #include "ui/common.hpp" | ||||
| #include "ui/Menu.hpp" | #include "ui/Menu.hpp" | ||||
| #include "ui/MenuEntry.hpp" | #include "ui/MenuEntry.hpp" | ||||
| #include "ui/MenuOverlay.hpp" | |||||
| #include "app.hpp" | #include "app.hpp" | ||||
| @@ -10,9 +9,6 @@ namespace rack { | |||||
| namespace ui { | namespace ui { | ||||
| #define BND_LABEL_FONT_SIZE 13 | |||||
| struct MenuItem : MenuEntry { | struct MenuItem : MenuEntry { | ||||
| std::string text; | std::string text; | ||||
| std::string rightText; | std::string rightText; | ||||
| @@ -144,7 +144,9 @@ int main(int argc, char *argv[]) { | |||||
| APP->engine->stop(); | APP->engine->stop(); | ||||
| // Destroy app | // Destroy app | ||||
| // APP->patch->save(asset::user("autosave.vcv")); | |||||
| if (!headless) { | |||||
| APP->patch->save(asset::user("autosave.vcv")); | |||||
| } | |||||
| INFO("Destroying app"); | INFO("Destroying app"); | ||||
| app::destroy(); | app::destroy(); | ||||
| settings.save(asset::user("settings.json")); | settings.save(asset::user("settings.json")); | ||||
| @@ -1,10 +1,14 @@ | |||||
| #include "ui/MenuItem.hpp" | #include "ui/MenuItem.hpp" | ||||
| #include "ui/MenuOverlay.hpp" | |||||
| namespace rack { | namespace rack { | ||||
| namespace ui { | namespace ui { | ||||
| #define BND_LABEL_FONT_SIZE 13 | |||||
| void MenuItem::draw(const DrawArgs &args) { | void MenuItem::draw(const DrawArgs &args) { | ||||
| BNDwidgetState state = BND_DEFAULT; | BNDwidgetState state = BND_DEFAULT; | ||||
| @@ -77,7 +81,7 @@ void MenuItem::doAction() { | |||||
| if (!eActionContext.consumed) | if (!eActionContext.consumed) | ||||
| return; | return; | ||||
| widget::Widget *overlay = getAncestorOfType<MenuOverlay>(); | |||||
| MenuOverlay *overlay = getAncestorOfType<MenuOverlay>(); | |||||
| if (overlay) { | if (overlay) { | ||||
| overlay->requestedDelete = true; | overlay->requestedDelete = true; | ||||
| } | } | ||||