Skip to content

Instantly share code, notes, and snippets.

@mataha
Last active May 9, 2021 04:19
Show Gist options
  • Save mataha/0f15afca673b6263e99109415e2a6ec4 to your computer and use it in GitHub Desktop.
Save mataha/0f15afca673b6263e99109415e2a6ec4 to your computer and use it in GitHub Desktop.
Touhou Music Room 2.3.0 patch
diff --unified a/musicroom/extract.cpp b/musicroom/extract.cpp
--- a/musicroom/extract.cpp
+++ b/musicroom/extract.cpp
@@ -8,6 +8,14 @@
#include <math.h>
+#if __cplusplus > 201703L
+# include <numbers>
+ static constexpr double PI = std::numbers::pi_v<double>;
+#else
+# include <cmath>
+ static constexpr double PI = std::acos(-1.0);
+#endif
+
// FOX
#include <FXHash.h>
#include <FXStream.h>
@@ -95,6 +103,24 @@
SINGLETON(FadeAlg_Exp);
};
+class FadeAlg_Smooth : public FadeAlg
+{
+public:
+ short* Eval(short* f, long& c, long& Len)
+ {
+ double Step = (double)c / (double)Len;
+ for (unsigned short i = 0; i < 2; ++i)
+ {
+ *f = (double)*f * (0.5 * (cos(Step * PI) + 1.0));
+ f++;
+ }
+ return f;
+ }
+
+ FadeAlg_Smooth() {Name = "Smooth";}
+ SINGLETON(FadeAlg_Smooth);
+}
+
// Decryption thread
// -----------------
FXint Decrypter::run()
@@ -136,6 +162,7 @@
{
FAs.Add()->Data = &FadeAlg_Linear::Inst();
FAs.Add()->Data = &FadeAlg_Exp::Inst();
+ FAs.Add()->Data = &FadeAlg_Smooth::Inst();
}
Extract_Vals::Extract_Vals()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment