Skip to content

Commit

Permalink
Merge pull request stakira#761 from oxygen-dioxide/fix-curve
Browse files Browse the repository at this point in the history
Fix wordline-R stop on pitch snaps
  • Loading branch information
stakira authored Jun 30, 2023
2 parents bee3b76 + c0e58c8 commit cb6422d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions OpenUtau.Core/Util/MusicMath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ public static double getZoomRatio(double quarterWidth, int beatPerBar, int beatU
}
}

const double ep = 0.001;

public static double SinEasingInOut(double x0, double x1, double y0, double y1, double x) {
if(x1 - x0 < ep){
return y1;
}
return y0 + (y1 - y0) * (1 - Math.Cos((x - x0) / (x1 - x0) * Math.PI)) / 2;
}

Expand All @@ -97,6 +102,9 @@ public static double SinEasingInOutX(double x0, double x1, double y0, double y1,
}

public static double SinEasingIn(double x0, double x1, double y0, double y1, double x) {
if(x1 - x0 < ep){
return y1;
}
return y0 + (y1 - y0) * (1 - Math.Cos((x - x0) / (x1 - x0) * Math.PI / 2));
}

Expand All @@ -105,6 +113,9 @@ public static double SinEasingInX(double x0, double x1, double y0, double y1, do
}

public static double SinEasingOut(double x0, double x1, double y0, double y1, double x) {
if(x1 - x0 < ep){
return y1;
}
return y0 + (y1 - y0) * Math.Sin((x - x0) / (x1 - x0) * Math.PI / 2);
}

Expand All @@ -113,6 +124,9 @@ public static double SinEasingOutX(double x0, double x1, double y0, double y1, d
}

public static double Linear(double x0, double x1, double y0, double y1, double x) {
if(x1 - x0 < ep){
return y1;
}
return y0 + (y1 - y0) * (x - x0) / (x1 - x0);
}

Expand Down

0 comments on commit cb6422d

Please sign in to comment.