Browse Source

Add Quantity evaluation functions gaintodb(), dbtogain(), vtof(), and ftov().

tags/v2.5.0
Andrew Belt 1 year ago
parent
commit
a6ab2b19aa
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      src/Quantity.cpp

+ 15
- 0
src/Quantity.cpp View File

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

#include <Quantity.hpp>
#include <string.hpp>
#include <dsp/common.hpp>


namespace rack {
@@ -78,6 +79,20 @@ static void teVarsInit() {

// Add custom functions
teVars.push_back({"log2", (void*) (double(*)(double)) std::log2, TE_FUNCTION1 | TE_FLAG_PURE, NULL});

teVars.push_back({"gaintodb", (void*) (double(*)(double)) [](double x) -> double {
return std::log10(x) * 20;
}, TE_FUNCTION1 | TE_FLAG_PURE, NULL});
teVars.push_back({"dbtogain", (void*) (double(*)(double)) [](double x) -> double {
return std::pow(10, x / 20);
}, TE_FUNCTION1 | TE_FLAG_PURE, NULL});

teVars.push_back({"vtof", (void*) (double(*)(double)) [](double x) -> double {
return std::pow(2, x) * dsp::FREQ_C4;
}, TE_FUNCTION1 | TE_FLAG_PURE, NULL});
teVars.push_back({"ftov", (void*) (double(*)(double)) [](double x) -> double {
return std::log2(x / dsp::FREQ_C4);
}, TE_FUNCTION1 | TE_FLAG_PURE, NULL});
}

void Quantity::setDisplayValueString(std::string s) {


Loading…
Cancel
Save