#pragma once #include "LookupTable.h" // TODO: this class should not be templatized. the functions should template class LookupTableFactory { public: static void makeBipolarAudioTaper(LookupTableParams& params); static double audioTaperKnee() { return -24; } /** * Factory methods for exp base 2 * domain = 0..10 * range = 20..20k (for now). but should be .001 to 1.0? */ static void makeExp2(LookupTableParams& params); static double expYMin() { return 4; } static double expYMax() { return 40000; } static double expXMin() { return std::log2(expYMin()); } static double expXMax() { return std::log2(expYMax()); } }; template inline void LookupTableFactory::makeExp2(LookupTableParams& params) { // 128 not enough for one cent const int bins = 256; const T xMin = (T) std::log2(expYMin()); const T xMax = (T) std::log2(expYMax()); assert(xMin < xMax); LookupTable::init(params, bins, xMin, xMax, [](double x) { return std::pow(2, x); }); } template inline void LookupTableFactory::makeBipolarAudioTaper(LookupTableParams& params) { const int bins = 32; std::function audioTaper = AudioMath::makeFunc_AudioTaper(audioTaperKnee()); const T xMin = -1; const T xMax = 1; LookupTable::init(params, bins, xMin, xMax, [audioTaper](double x) { return (x >= 0) ? audioTaper(x) : -audioTaper(-x); }); }