Browse Source

Reorder tag.cpp. Clean up comments.

tags/v1.1.4
Andrew Belt 5 years ago
parent
commit
5c337b6de3
3 changed files with 22 additions and 22 deletions
  1. +2
    -1
      include/dsp/approx.hpp
  2. +8
    -8
      include/tag.hpp
  3. +12
    -13
      src/tag.cpp

+ 2
- 1
include/dsp/approx.hpp View File

@@ -28,10 +28,11 @@ If negative powers are needed, you may use a lower bound and rescale.
*/
template <typename T>
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;


+ 8
- 8
include/tag.hpp View File

@@ -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<std::vector<std::string>> 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

+ 12
- 13
src/tag.cpp View File

@@ -1,6 +1,5 @@
#include <tag.hpp>
#include <string.hpp>

#include <map>


@@ -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<std::vector<std::string>> tagAliases = {
{"Arpeggiator"},
{"Attenuator"}, // With a level knob and not much else.
@@ -79,5 +66,17 @@ const std::vector<std::vector<std::string>> 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

Loading…
Cancel
Save