Skip to content

Commit

Permalink
Merge pull request #1177 from sfztools/issue-1176
Browse files Browse the repository at this point in the history
Fix FlexEGs shape
  • Loading branch information
paulfd authored Aug 3, 2023
2 parents 2248de3 + 4d8c780 commit 2722822
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/sfizz/FlexEGDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ std::shared_ptr<Curve> FlexEGs::getShapeCurve(float shape)
else if (shape > 0) {
for (unsigned i = 0; i < numPoints; ++i) {
float x = float(i) / (numPoints - 1);
points[i] = std::pow(x, shape);
points[i] = std::pow(x, 1 + shape);
}
*curve = Curve::buildFromPoints(points);
}
else if (shape < 0) {
for (unsigned i = 0; i < numPoints; ++i) {
float x = float(i) / (numPoints - 1);
points[i] = 1 - std::pow(1 - x, -shape);
points[i] = 1 - std::pow(1 - x, 1 - shape);
}
*curve = Curve::buildFromPoints(points);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/FlexEGT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ TEST_CASE("[FlexEG] Detailed numerical envelope test (with shapes)")
std::vector<float> output;
std::vector<float> expected {
0.0f,
0.01f, 0.04f, 0.09f, 0.16f, 0.25f,
0.58f, 0.72f, 0.83f, 0.92f, 1.0f,
0.002f, 0.016f, 0.054f, 0.128f, 0.25f,
0.317f, 0.44f, 0.6f, 0.787f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
0.99f, 0.97f, 0.87f, 0.59f, 0.0f,
1.0f, 0.99f, 0.922f, 0.672f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f
};
output.resize(expected.size());
Expand Down

0 comments on commit 2722822

Please sign in to comment.