@rian8337/osu-base 4.0.0-beta.74 → 4.0.0-beta.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +50 -5
- package/package.json +2 -2
- package/typings/index.d.ts +36 -4
package/dist/index.js
CHANGED
|
@@ -130,6 +130,16 @@ class MathUtils {
|
|
|
130
130
|
static millisecondsToBPM(milliseconds, delimiter = 4) {
|
|
131
131
|
return 60000 / (milliseconds * delimiter);
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Calculates an S-shaped {@link https://en.wikipedia.org/wiki/Logistic_function logistic function}.
|
|
135
|
+
*
|
|
136
|
+
* @param exponent The exponent to calculate the function for.
|
|
137
|
+
* @param maxValue The maximum value returnable by the function.
|
|
138
|
+
* @returns The output of the logistic function calculated at `exponent`.
|
|
139
|
+
*/
|
|
140
|
+
static logistic(exponent, maxValue = 1) {
|
|
141
|
+
return maxValue / (1 + Math.exp(exponent));
|
|
142
|
+
}
|
|
133
143
|
/**
|
|
134
144
|
* Calculates an S-shaped {@link https://en.wikipedia.org/wiki/Logistic_function logistic function}
|
|
135
145
|
* with offset at `x`.
|
|
@@ -156,6 +166,26 @@ class MathUtils {
|
|
|
156
166
|
x = this.reverseLerp(x, start, end);
|
|
157
167
|
return x * x * (3 - 2 * x);
|
|
158
168
|
}
|
|
169
|
+
/// <summary>
|
|
170
|
+
///
|
|
171
|
+
/// </summary>
|
|
172
|
+
/// <param name="x">Value to calculate the function for</param>
|
|
173
|
+
/// <param name="mean">Value of x, for which return value will be the highest (=1)</param>
|
|
174
|
+
/// <param name="width">Range [mean - width, mean + width] where function will change values</param>
|
|
175
|
+
/// <returns>The output of the smoothstep bell curve function of <paramref name="x"/></returns>
|
|
176
|
+
/**
|
|
177
|
+
* Calculates a {@link https://en.wikipedia.org/wiki/Smoothstep smoothstep bell curve} function that returns 1 for `x = mean`,
|
|
178
|
+
* and smoothly reducing it's value to 0 over width.
|
|
179
|
+
*
|
|
180
|
+
* @param x The value to calculate the function for.
|
|
181
|
+
* @param mean The value of x, for which the return value will be the highest (=1).
|
|
182
|
+
* @param width Range `[mean - width, mean + width]` where the function will change values.
|
|
183
|
+
*/
|
|
184
|
+
static smoothstepBellCurve(x, mean = 0.5, width = 0.5) {
|
|
185
|
+
x -= mean;
|
|
186
|
+
x = x > 0 ? width - x : width + x;
|
|
187
|
+
return this.smoothstep(x, 0, width);
|
|
188
|
+
}
|
|
159
189
|
/**
|
|
160
190
|
* Calculates the {@link https://en.wikipedia.org/wiki/Smoothstep#Variations smoothstep}
|
|
161
191
|
* function at `x`.
|
|
@@ -11691,16 +11721,31 @@ class MapInfo {
|
|
|
11691
11721
|
/**
|
|
11692
11722
|
* Represents the "old" `ModNightCore`.
|
|
11693
11723
|
*
|
|
11694
|
-
* This
|
|
11695
|
-
*
|
|
11724
|
+
* This `Mod` is used solely for difficulty calculation of replays with version 3 or older. The reason behind this is a
|
|
11725
|
+
* bug that was patched in replay version 4, where all audio that did not have 44100Hz frequency would slow down or
|
|
11726
|
+
* speed up depending on the frequency of the audio.
|
|
11727
|
+
*
|
|
11728
|
+
* The equation for the playback rate with respect to the audio frequency (in Hz) was:
|
|
11729
|
+
*
|
|
11730
|
+
* ```
|
|
11731
|
+
* playback_rate = 44100 * 1.5 / audio_frequency
|
|
11732
|
+
* ```
|
|
11733
|
+
*
|
|
11734
|
+
* For example, if the audio's frequency is 48000Hz, the audio would play at `44100 * 1.5 / 48000 = 1.378125` playback
|
|
11735
|
+
* rate.
|
|
11736
|
+
*
|
|
11737
|
+
* This `Mod` assumes that the audio frequency is 48000Hz and applies the same equation to calculate the playback rate.
|
|
11738
|
+
* The frequency was chosen after sampling many audio files that were affected by this bug, and it seemed that 48000Hz
|
|
11739
|
+
* was the most common frequency used in those files.
|
|
11696
11740
|
*
|
|
11697
|
-
*
|
|
11698
|
-
*
|
|
11741
|
+
* Realistically, it is possible to obtain the audio frequency in the game during gameplay loading (and therefore would
|
|
11742
|
+
* result in the correct playback rate), but this would require additional work and the current solution is deemed
|
|
11743
|
+
* sufficient for the purpose it serves.
|
|
11699
11744
|
*/
|
|
11700
11745
|
class ModOldNightCore extends ModNightCore {
|
|
11701
11746
|
constructor() {
|
|
11702
11747
|
super();
|
|
11703
|
-
this.trackRateMultiplier.value = 1.
|
|
11748
|
+
this.trackRateMultiplier.value = (44.1 * 1.5) / 48;
|
|
11704
11749
|
}
|
|
11705
11750
|
get droidScoreMultiplier() {
|
|
11706
11751
|
return 1.12;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rian8337/osu-base",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.77",
|
|
4
4
|
"description": "Base module for all osu! related modules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"osu",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "13ad454ea657dbd5821d0857c4da6dc7ab0fe965"
|
|
39
39
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -4668,6 +4668,14 @@ declare abstract class MathUtils {
|
|
|
4668
4668
|
* @returns The milliseconds value in BPM.
|
|
4669
4669
|
*/
|
|
4670
4670
|
static millisecondsToBPM(milliseconds: number, delimiter?: number): number;
|
|
4671
|
+
/**
|
|
4672
|
+
* Calculates an S-shaped {@link https://en.wikipedia.org/wiki/Logistic_function logistic function}.
|
|
4673
|
+
*
|
|
4674
|
+
* @param exponent The exponent to calculate the function for.
|
|
4675
|
+
* @param maxValue The maximum value returnable by the function.
|
|
4676
|
+
* @returns The output of the logistic function calculated at `exponent`.
|
|
4677
|
+
*/
|
|
4678
|
+
static logistic(exponent: number, maxValue?: number): number;
|
|
4671
4679
|
/**
|
|
4672
4680
|
* Calculates an S-shaped {@link https://en.wikipedia.org/wiki/Logistic_function logistic function}
|
|
4673
4681
|
* with offset at `x`.
|
|
@@ -4689,6 +4697,15 @@ declare abstract class MathUtils {
|
|
|
4689
4697
|
* @returns The output of the smoothstep function calculated at `x`.
|
|
4690
4698
|
*/
|
|
4691
4699
|
static smoothstep(x: number, start: number, end: number): number;
|
|
4700
|
+
/**
|
|
4701
|
+
* Calculates a {@link https://en.wikipedia.org/wiki/Smoothstep smoothstep bell curve} function that returns 1 for `x = mean`,
|
|
4702
|
+
* and smoothly reducing it's value to 0 over width.
|
|
4703
|
+
*
|
|
4704
|
+
* @param x The value to calculate the function for.
|
|
4705
|
+
* @param mean The value of x, for which the return value will be the highest (=1).
|
|
4706
|
+
* @param width Range `[mean - width, mean + width]` where the function will change values.
|
|
4707
|
+
*/
|
|
4708
|
+
static smoothstepBellCurve(x: number, mean?: number, width?: number): number;
|
|
4692
4709
|
/**
|
|
4693
4710
|
* Calculates the {@link https://en.wikipedia.org/wiki/Smoothstep#Variations smoothstep}
|
|
4694
4711
|
* function at `x`.
|
|
@@ -5175,11 +5192,26 @@ declare class ModNoFail extends Mod implements IModApplicableToDroid, IModApplic
|
|
|
5175
5192
|
/**
|
|
5176
5193
|
* Represents the "old" `ModNightCore`.
|
|
5177
5194
|
*
|
|
5178
|
-
* This
|
|
5179
|
-
*
|
|
5195
|
+
* This `Mod` is used solely for difficulty calculation of replays with version 3 or older. The reason behind this is a
|
|
5196
|
+
* bug that was patched in replay version 4, where all audio that did not have 44100Hz frequency would slow down or
|
|
5197
|
+
* speed up depending on the frequency of the audio.
|
|
5198
|
+
*
|
|
5199
|
+
* The equation for the playback rate with respect to the audio frequency (in Hz) was:
|
|
5200
|
+
*
|
|
5201
|
+
* ```
|
|
5202
|
+
* playback_rate = 44100 * 1.5 / audio_frequency
|
|
5203
|
+
* ```
|
|
5204
|
+
*
|
|
5205
|
+
* For example, if the audio's frequency is 48000Hz, the audio would play at `44100 * 1.5 / 48000 = 1.378125` playback
|
|
5206
|
+
* rate.
|
|
5207
|
+
*
|
|
5208
|
+
* This `Mod` assumes that the audio frequency is 48000Hz and applies the same equation to calculate the playback rate.
|
|
5209
|
+
* The frequency was chosen after sampling many audio files that were affected by this bug, and it seemed that 48000Hz
|
|
5210
|
+
* was the most common frequency used in those files.
|
|
5180
5211
|
*
|
|
5181
|
-
*
|
|
5182
|
-
*
|
|
5212
|
+
* Realistically, it is possible to obtain the audio frequency in the game during gameplay loading (and therefore would
|
|
5213
|
+
* result in the correct playback rate), but this would require additional work and the current solution is deemed
|
|
5214
|
+
* sufficient for the purpose it serves.
|
|
5183
5215
|
*/
|
|
5184
5216
|
declare class ModOldNightCore extends ModNightCore {
|
|
5185
5217
|
constructor();
|