Browse Source

Add polyfill for future LightWidget

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
84f4efcbeb
4 changed files with 14 additions and 3 deletions
  1. +0
    -1
      include/components.hpp
  2. +3
    -0
      include/engine.hpp
  3. +10
    -1
      include/rack.hpp
  4. +1
    -1
      src/engine.cpp

+ 0
- 1
include/components.hpp View File

@@ -337,7 +337,6 @@ struct Rogan1PWhite : Rogan1P {

struct SynthTechAlco : SVGKnob {
SynthTechAlco() {
box.size = Vec(45, 45);
minAngle = -0.82*M_PI;
maxAngle = 0.82*M_PI;
setSVG(SVG::load(assetGlobal("res/ComponentLibrary/SynthTechAlco.svg")));


+ 3
- 0
include/engine.hpp View File

@@ -32,6 +32,9 @@ struct Output {
struct Light {
/** The square of the brightness value */
float value = 0.0;
void setBrightness(float brightness) {
value = brightness * brightness;
}
void setBrightnessSmooth(float brightness);
};



+ 10
- 1
include/rack.hpp View File

@@ -2,12 +2,12 @@

#include "util.hpp"
#include "math.hpp"
#include "asset.hpp"
#include "plugin.hpp"
#include "engine.hpp"
#include "gui.hpp"
#include "app.hpp"
#include "components.hpp"
#include "asset.hpp"


namespace rack {
@@ -80,5 +80,14 @@ ValueLight *createValueLight(Vec pos, float *value) {
return light;
}

/** Polyfill for future LightWidget */
template <class TLight>
ValueLight *createValueLight(Vec pos, Module *module, int lightId) {
ValueLight *light = new TLight();
light->box.pos = pos;
light->value = &module->lights[lightId].value;
return light;
}


} // namespace rack

+ 1
- 1
src/engine.cpp View File

@@ -34,7 +34,7 @@ static float smoothValue;


void Light::setBrightnessSmooth(float brightness) {
value += (powf(brightness, 2) - value) / sampleRate * 60.0;
value += (brightness * brightness - value) / sampleRate * 60.0;
}




Loading…
Cancel
Save