Browse Source

Tweaks to dsp/filter.hpp algorithms. Re-enable autosave on close.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
1a5ae9ea28
5 changed files with 48 additions and 24 deletions
  1. +38
    -17
      include/dsp/filter.hpp
  2. +2
    -1
      include/helpers.hpp
  3. +0
    -4
      include/ui/MenuItem.hpp
  4. +3
    -1
      src/main.cpp
  5. +5
    -1
      src/ui/MenuItem.cpp

+ 38
- 17
include/dsp/filter.hpp View File

@@ -49,37 +49,56 @@ struct PeakFilter {


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->fall = fall;
}
float process(float in) {
out = math::clamp(in, out - fall, out + rise);
return out;
}
};


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;
}
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;
}
return out;
}
DEPRECATED float process(float in) {
return process(1.f, in);
}
};


@@ -113,7 +132,9 @@ struct ExponentialFilter {
return out;
}

DEPRECATED float process(float in) {return process(1.f, in);}
DEPRECATED float process(float in) {
return process(1.f, in);
}
};




+ 2
- 1
include/helpers.hpp View File

@@ -1,7 +1,8 @@
#pragma once
#include "plugin/Model.hpp"
#include "ui/MenuLabel.hpp"
#include "ui/MenuOverlay.hpp"
#include "ui/MenuItem.hpp"
#include "ui/MenuLabel.hpp"
#include "ui/Menu.hpp"
#include "app/PortWidget.hpp"
#include "app/ParamQuantity.hpp"


+ 0
- 4
include/ui/MenuItem.hpp View File

@@ -2,7 +2,6 @@
#include "ui/common.hpp"
#include "ui/Menu.hpp"
#include "ui/MenuEntry.hpp"
#include "ui/MenuOverlay.hpp"
#include "app.hpp"


@@ -10,9 +9,6 @@ namespace rack {
namespace ui {


#define BND_LABEL_FONT_SIZE 13


struct MenuItem : MenuEntry {
std::string text;
std::string rightText;


+ 3
- 1
src/main.cpp View File

@@ -144,7 +144,9 @@ int main(int argc, char *argv[]) {
APP->engine->stop();

// Destroy app
// APP->patch->save(asset::user("autosave.vcv"));
if (!headless) {
APP->patch->save(asset::user("autosave.vcv"));
}
INFO("Destroying app");
app::destroy();
settings.save(asset::user("settings.json"));


+ 5
- 1
src/ui/MenuItem.cpp View File

@@ -1,10 +1,14 @@
#include "ui/MenuItem.hpp"
#include "ui/MenuOverlay.hpp"


namespace rack {
namespace ui {


#define BND_LABEL_FONT_SIZE 13


void MenuItem::draw(const DrawArgs &args) {
BNDwidgetState state = BND_DEFAULT;

@@ -77,7 +81,7 @@ void MenuItem::doAction() {
if (!eActionContext.consumed)
return;

widget::Widget *overlay = getAncestorOfType<MenuOverlay>();
MenuOverlay *overlay = getAncestorOfType<MenuOverlay>();
if (overlay) {
overlay->requestedDelete = true;
}


Loading…
Cancel
Save