Skip to content

Commit d09466a

Browse files
authored
Merge pull request #96 from neogeek/hotfix/updated-documentation
[hotfix] Updated documentation.
2 parents a180a10 + 0a1fec9 commit d09466a

35 files changed

+1148
-537
lines changed

Documentation/API/Parsers/ParseBpmFromChartSection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);
1212

1313
var bpm = Parsers.ParseBpmFromChartSection(sections[NamedSection.SyncTrack]);
1414

15-
Console.WriteLine(bpm.Count); // 7
15+
Console.WriteLine(bpm.Length); // 7
1616
```
1717

1818
##### C++

Documentation/API/Parsers/ParseLyricsFromChartSection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);
1212

1313
var lyrics = Parsers.ParseLyricsFromChartSection(sections[NamedSection.Events]);
1414

15-
Console.WriteLine(notes.Count); // 12
15+
Console.WriteLine(lyrics.Count); // 12
1616
```
1717

1818
##### C++

Documentation/API/Parsers/ParseNotesFromChartSection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);
1212

1313
var notes = Parsers.ParseNotesFromChartSection(sections[$"{Difficulty.Expert}Single"]);
1414

15-
Console.WriteLine(notes.Count); // 8
15+
Console.WriteLine(notes.Length); // 8
1616
```
1717

1818
##### C++

Documentation/API/Parsers/ParseTimeSignaturesFromChartSection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);
1212

1313
var timeSignatures = Parsers.ParseTimeSignaturesFromChartSection(sections[NamedSection.SyncTrack]);
1414

15-
Console.WriteLine(timeSignatures.Count); // 4
15+
Console.WriteLine(timeSignatures.Length); // 4
1616
```
1717

1818
##### C++

Documentation/API/Utilities/CalculateAccuracyRatio.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ const int seconds = 2;
1212
const int resolution = 192;
1313
const int positionDelta = 50;
1414

15-
var bpmChanges = new Dictionary<int, int> { { 0, 120000 } };
15+
var bpmChanges = new Tempo[] { new() { Position = 0, BPM = 120000 } };
16+
17+
var timeSignatureChanges = new TimeSignature[] { new() { Position = 0, Numerator = 4, Denominator = 2 } };
1618

1719
var note = new Note { Position = 750 };
18-
var currentPosition = Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges);
20+
21+
var currentPosition =
22+
Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges, timeSignatureChanges);
1923

2024
var value = Utilities.CalculateAccuracyRatio(note.Position, currentPosition, positionDelta);
2125

@@ -37,11 +41,12 @@ int main()
3741
const int resolution = 192;
3842
const int positionDelta = 50;
3943

40-
std::map<int, int> bpmChanges = {{0, 120000}};
44+
std::vector<Tempo> bpmChanges = {{0, 120000}};
45+
std::vector<TimeSignature> timeSignatureChanges = {{0, 4}};
4146

4247
auto note = new Note{750};
43-
auto currentPosition =
44-
ConvertSecondsToTicks(seconds, resolution, bpmChanges);
48+
auto currentPosition = ConvertSecondsToTicks(
49+
seconds, resolution, bpmChanges, timeSignatureChanges);
4550

4651
auto value =
4752
CalculateAccuracyRatio(note->Position, currentPosition, positionDelta);
@@ -62,9 +67,15 @@ func _ready() -> void:
6267
var resolution = 192
6368
var position_delta = 50
6469
65-
var bpm_changes = { 0: 120000 }
70+
var bpm_changes = [
71+
{"position": 0, "bpm": 120000 }
72+
]
73+
74+
var time_signature_changes = [
75+
{"position": 0, "numerator": 4, "denominator": 2 }
76+
]
6677
67-
var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes)
78+
var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes, time_signature_changes)
6879
6980
var value = rhythm_game_utilities.calculate_accuracy_ratio(750, current_position, position_delta)
7081

Documentation/API/Utilities/CalculateBeatBars.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@
55
##### C#
66

77
```csharp
8-
const int resolution = 192;
9-
const int timeSignature = 4;
10-
11-
var bpmChanges = new Dictionary<int, int>
8+
var bpmChanges = new Tempo[]
129
{
13-
{ 0, 88000 },
14-
{ 3840, 112000 },
15-
{ 9984, 89600 },
16-
{ 22272, 112000 },
17-
{ 33792, 111500 },
18-
{ 34560, 112000 },
19-
{ 42240, 111980 }
10+
new() { Position = 0, BPM = 88000 }, new() { Position = 3840, BPM = 112000 },
11+
new() { Position = 9984, BPM = 89600 }, new() { Position = 22272, BPM = 112000 },
12+
new() { Position = 33792, BPM = 111500 }, new() { Position = 34560, BPM = 112000 },
13+
new() { Position = 42240, BPM = 111980 }
2014
};
2115

22-
var beatBars = Utilities.CalculateBeatBars(bpmChanges, resolution, timeSignature, true);
16+
var beatBars = Utilities.CalculateBeatBars(bpmChanges);
2317

24-
Console.WriteLine(beatBars.Count); // 440
18+
Console.WriteLine(beatBars.Length); // 440
2519
```
2620

2721
##### C++
@@ -38,7 +32,7 @@ int main()
3832
const int resolution = 192;
3933
const int timeSignature = 4;
4034

41-
std::map<int, int> bpmChanges = {
35+
std::vector<Tempo> bpmChanges = {
4236
{0, 88000}, {3840, 112000}, {9984, 89600}, {22272, 112000},
4337
{33792, 111500}, {34560, 112000}, {42240, 111980}};
4438

@@ -60,11 +54,15 @@ func _ready() -> void:
6054
var resolution = 192
6155
var time_signature = 4
6256
63-
var bpm_changes = {
64-
0: 88000, 3840: 112000, 9984: 89600,
65-
22272: 112000, 33792: 111500, 34560: 112000,
66-
42240: 111980
67-
}
57+
var bpm_changes = [
58+
{"position": 0, "bpm": 8800 },
59+
{"position": 3840, "bpm": 112000 },
60+
{"position": 9984, "bpm": 89600 },
61+
{"position": 22272, "bpm": 112000 },
62+
{"position": 33792, "bpm": 111500 },
63+
{"position": 34560, "bpm": 112000 },
64+
{"position": 42240, "bpm": 111980 }
65+
]
6866
6967
var beat_bars = rhythm_game_utilities.calculate_beat_bars(bpm_changes, resolution, time_signature, true)
7068

Documentation/API/Utilities/ConvertSecondsToTicks.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ using RhythmGameUtilities;
1111
const int seconds = 5;
1212
const int resolution = 192;
1313

14-
var bpmChanges = new Dictionary<int, int>
14+
var bpmChanges = new Tempo[]
1515
{
16-
{ 0, 88000 },
17-
{ 3840, 112000 },
18-
{ 9984, 89600 },
19-
{ 22272, 112000 },
20-
{ 33792, 111500 },
21-
{ 34560, 112000 },
22-
{ 42240, 111980 }
16+
new() { Position = 0, BPM = 88000 }, new() { Position = 3840, BPM = 112000 },
17+
new() { Position = 9984, BPM = 89600 }, new() { Position = 22272, BPM = 112000 },
18+
new() { Position = 33792, BPM = 111500 }, new() { Position = 34560, BPM = 112000 },
19+
new() { Position = 42240, BPM = 111980 }
2320
};
2421

25-
var ticks = Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges);
22+
var timeSignatureChanges = new TimeSignature[] { new() { Position = 0, Numerator = 4, Denominator = 2 } };
23+
24+
var ticks = Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges, timeSignatureChanges);
2625

2726
Console.WriteLine(ticks); // 1408
2827
```
@@ -41,11 +40,14 @@ int main()
4140
const int seconds = 5;
4241
const int resolution = 192;
4342

44-
std::map<int, int> bpmChanges = {
43+
std::vector<Tempo> bpmChanges = {
4544
{0, 88000}, {3840, 112000}, {9984, 89600}, {22272, 112000},
4645
{33792, 111500}, {34560, 112000}, {42240, 111980}};
4746

48-
auto ticks = ConvertSecondsToTicks(seconds, resolution, bpmChanges);
47+
std::vector<TimeSignature> timeSignatureChanges = {{0, 4, 2}};
48+
49+
auto ticks = ConvertSecondsToTicks(seconds, resolution, bpmChanges,
50+
timeSignatureChanges);
4951

5052
std::cout << ticks << std::endl; // 1408
5153

@@ -62,13 +64,21 @@ func _ready() -> void:
6264
var seconds = 5
6365
var resolution = 192
6466
65-
var bpm_changes = {
66-
0: 88000, 3840: 112000, 9984: 89600,
67-
22272: 112000, 33792: 111500, 34560: 112000,
68-
42240: 111980
69-
}
67+
var bpm_changes = [
68+
{"position": 0, "bpm": 8800 },
69+
{"position": 3840, "bpm": 112000 },
70+
{"position": 9984, "bpm": 89600 },
71+
{"position": 22272, "bpm": 112000 },
72+
{"position": 33792, "bpm": 111500 },
73+
{"position": 34560, "bpm": 112000 },
74+
{"position": 42240, "bpm": 111980 }
75+
]
76+
77+
var time_signature_changes = [
78+
{"position": 0, "numerator": 4, "denominator": 2 }
79+
]
7080
71-
var ticks = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes)
81+
var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes, time_signature_changes)
7282
73-
print(ticks) # 1408
83+
print(current_position) # 1408
7484
```

Documentation/API/Utilities/ConvertTickToPosition.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
using System;
99
using RhythmGameUtilities;
1010

11-
const int tick = 2784;
11+
const int tick = 1056;
1212
const int resolution = 192;
1313

1414
var position = Utilities.ConvertTickToPosition(tick, resolution);
1515

16-
Console.WriteLine(position); // 14.5
16+
Console.WriteLine(position); // 5.5
1717
```
1818

1919
##### C++
@@ -27,12 +27,12 @@ using namespace RhythmGameUtilities;
2727

2828
int main()
2929
{
30-
const int tick = 2784;
30+
const int tick = 1056;
3131
const int resolution = 192;
3232

3333
auto position = ConvertTickToPosition(tick, resolution);
3434

35-
std::cout << position << std::endl; // 14.5
35+
std::cout << position << std::endl; // 5.5
3636

3737
return 0;
3838
}
@@ -44,10 +44,10 @@ int main()
4444
extends Node
4545
4646
func _ready() -> void:
47-
var tick = 2784
47+
var tick = 1056
4848
var resolution = 192
4949
5050
var position = rhythm_game_utilities.convert_tick_to_position(tick, resolution)
5151
52-
print(position) # 14.5
52+
print(position) # 5.5
5353
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# FindPositionNearGivenTick
2+
3+
> Languages: `C#` `C++` `GDScript`
4+
5+
##### C#
6+
7+
```csharp
8+
var notes = new Note[]
9+
{
10+
new() { Position = 768 }, new() { Position = 960 }, new() { Position = 1152 },
11+
new() { Position = 1536 }, new() { Position = 1728 }, new() { Position = 1920 },
12+
new() { Position = 2304 }, new() { Position = 2496 }, new() { Position = 2688 },
13+
new() { Position = 3072 }, new() { Position = 3264 }
14+
};
15+
16+
var note = Utilities.FindPositionNearGivenTick(notes, 750);
17+
18+
if (note != null)
19+
{
20+
Console.Write(note.Value.Position); // 768
21+
}
22+
```
23+
24+
##### C++
25+
26+
```cpp
27+
#include <iostream>
28+
29+
#include "RhythmGameUtilities/Utilities.hpp"
30+
31+
using namespace RhythmGameUtilities;
32+
33+
int main()
34+
{
35+
std::vector<Note> notes = {{768, 0, 0}, {960, 0, 0}, {1152, 0, 0},
36+
{1536, 0, 0}, {1728, 0, 0}, {1920, 0, 0},
37+
{2304, 0, 0}, {2496, 0, 0}, {2688, 0, 0},
38+
{3072, 0, 0}, {3264, 0, 0}};
39+
40+
auto note = FindPositionNearGivenTick(notes, 750);
41+
42+
if (note)
43+
{
44+
std::cout << note->Position << std::endl; // 768
45+
}
46+
47+
return 0;
48+
}
49+
```
50+
51+
##### GDScript
52+
53+
```gdscript
54+
extends Node
55+
56+
func _ready() -> void:
57+
var seconds = 5
58+
var resolution = 192
59+
60+
var notes = [
61+
{"position": 768 }, {"position": 960 }, {"position": 1152 },
62+
{"position": 1536 }, {"position": 1728 }, {"position": 1920 },
63+
{"position": 2304 }, {"position": 2496 }, {"position": 2688 },
64+
{"position": 3072 }, {"position": 3264 }
65+
]
66+
67+
var note = rhythm_game_utilities.find_position_near_given_tick(notes, 750);
68+
69+
print(note["position"]) # 768
70+
```

Documentation/API/Utilities/IsOnTheBeat.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ const int bpm = 120;
1212
const float currentTime = 10f;
1313
const float delta = 0.05f;
1414

15-
if (Utilities.IsOnTheBeat(bpm, currentTime, delta))
16-
{
17-
Console.WriteLine("Is on the beat!");
18-
}
15+
var isOnTheBeat = Utilities.IsOnTheBeat(bpm, currentTime, delta);
16+
17+
Console.WriteLine(isOnTheBeat ? "Is on the beat!" : "Is not on the beat!"); // "Is on the beat!"
1918
```
2019

2120
##### C++
@@ -30,13 +29,13 @@ using namespace RhythmGameUtilities;
3029
int main()
3130
{
3231
const int bpm = 120;
33-
const float currentTime = 10f;
32+
const float currentTime = 10;
3433
const float delta = 0.05f;
3534

36-
if (IsOnTheBeat(bpm, currentTime, delta))
37-
{
38-
std::cout << "Is on the beat!" << std::endl;
39-
}
35+
auto isOnTheBeat = IsOnTheBeat(bpm, currentTime, delta);
36+
37+
std::cout << (isOnTheBeat ? "Is on the beat!" : "Is not on the beat!")
38+
<< std::endl; // "Is on the beat!"
4039

4140
return 0;
4241
}
@@ -52,6 +51,10 @@ func _ready() -> void:
5251
var current_time = 10
5352
var delta = 0.05
5453
55-
if rhythm_game_utilities.is_on_the_beat(bpm, current_time, delta):
54+
var isOnTheBeat = rhythm_game_utilities.is_on_the_beat(bpm, current_time, delta)
55+
56+
if isOnTheBeat: # "Is on the beat!"
5657
print("Is on the beat!")
58+
else:
59+
print("Is not on the beat!")
5760
```

0 commit comments

Comments
 (0)