Browse Source

Header file tweaks

tags/v0.6.1
Andrew Belt 6 years ago
parent
commit
5a90888a09
4 changed files with 19 additions and 3 deletions
  1. +2
    -0
      include/dsp/frame.hpp
  2. +9
    -1
      include/dsp/functions.hpp
  3. +5
    -0
      include/util/color.hpp
  4. +3
    -2
      include/widgets.hpp

+ 2
- 0
include/dsp/frame.hpp View File

@@ -9,6 +9,8 @@ namespace rack {
template <size_t CHANNELS>
struct Frame {
float samples[CHANNELS];

Frame() {}
};

} // namespace rack

+ 9
- 1
include/dsp/functions.hpp View File

@@ -1,6 +1,6 @@
#pragma once

#include <cmath>
#include "util/math.hpp"


namespace rack {
@@ -42,5 +42,13 @@ inline float exponentialBipolar(float b, float x) {
return (powf(b, x) - powf(b, -x)) / a;
}

inline float gainToDb(float gain) {
return log10f(gain) * 20.f;
}

inline float dbToGain(float db) {
return powf(10.f, db / 20.f);
}


} // namespace rack

+ 5
- 0
include/util/color.hpp View File

@@ -54,5 +54,10 @@ inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) {
return c;
}

inline NVGcolor colorAlpha(NVGcolor a, float alpha) {
a.a *= alpha;
return a;
}


} // namespace rack

+ 3
- 2
include/widgets.hpp View File

@@ -7,6 +7,7 @@

#include "util/common.hpp"
#include "events.hpp"
#include "util/color.hpp"


namespace rack {
@@ -144,10 +145,10 @@ struct Widget {
/** Helper function for creating and initializing a Widget with certain arguments (in this case just the position).
In this project, you will find this idiom everywhere, as an easier alternative to constructor arguments, for building a Widget (or a subclass) with a one-liner.
Example:
addChild(Widget::create<SVGWidget>(Vec(0, 0)))
addChild(Widget::create<SVGWidget>(Vec(10, 10)))
*/
template <typename T = Widget>
static T *create(Vec pos) {
static T *create(Vec pos = Vec()) {
T *o = new T();
o->box.pos = pos;
return o;


Loading…
Cancel
Save