diff --git a/include/dsp/approx.hpp b/include/dsp/approx.hpp index 37f4f1cf..e4fb6d91 100644 --- a/include/dsp/approx.hpp +++ b/include/dsp/approx.hpp @@ -28,10 +28,11 @@ If negative powers are needed, you may use a lower bound and rescale. */ template T approxExp2_taylor5(T x) { + // Use bit-shifting for integer part of x. int xi = x; x -= xi; T y = 1 << xi; - // Fifth order expansion of 2^x around 0.4752 in Horner form. + // 5th order expansion of 2^x around 0.4752 in Horner form. // The center is chosen so that the endpoints of [0, 1] have equal error, creating no discontinuity at integers. y *= T(0.9999976457798443) + x * (T(0.6931766804601935) + x * (T(0.2400729486415728) + x * (T(0.05592817518644387) + x * (T(0.008966320633544) + x * T(0.001853512473884202))))); return y; diff --git a/include/tag.hpp b/include/tag.hpp index 3a2d8933..57d37703 100644 --- a/include/tag.hpp +++ b/include/tag.hpp @@ -7,14 +7,6 @@ namespace rack { namespace tag { -/** Searches for a tag ID. -Searches tag aliases. -Case-insensitive. -Returns -1 if not found. -*/ -int findId(const std::string& tag); - - /** List of tags and their aliases. The first alias of each tag `tag[tagId][0]` is the "canonical" alias. It is guaranteed to exist and should be used as the human-readable form. @@ -24,5 +16,13 @@ This list is manually alphabetized by the canonical alias. extern const std::vector> tagAliases; +/** Searches for a tag ID. +Searches tag aliases. +Case-insensitive. +Returns -1 if not found. +*/ +int findId(const std::string& tag); + + } // namespace tag } // namespace rack diff --git a/src/tag.cpp b/src/tag.cpp index ebff5899..78e6daaf 100644 --- a/src/tag.cpp +++ b/src/tag.cpp @@ -1,6 +1,5 @@ #include #include - #include @@ -8,18 +7,6 @@ namespace rack { namespace tag { -int findId(const std::string& tag) { - std::string lowercaseTag = string::lowercase(tag); - for (int tagId = 0; tagId < (int) tagAliases.size(); tagId++) { - for (const std::string& alias : tagAliases[tagId]) { - if (string::lowercase(alias) == lowercaseTag) - return tagId; - } - } - return -1; -} - - const std::vector> tagAliases = { {"Arpeggiator"}, {"Attenuator"}, // With a level knob and not much else. @@ -79,5 +66,17 @@ const std::vector> tagAliases = { }; +int findId(const std::string& tag) { + std::string lowercaseTag = string::lowercase(tag); + for (int tagId = 0; tagId < (int) tagAliases.size(); tagId++) { + for (const std::string& alias : tagAliases[tagId]) { + if (string::lowercase(alias) == lowercaseTag) + return tagId; + } + } + return -1; +} + + } // namespace tag } // namespace rack