Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/API/Parsers/ParseBpmFromChartSection.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);

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

Console.WriteLine(bpm.Count); // 7
Console.WriteLine(bpm.Length); // 7
```

##### C++
Expand Down
2 changes: 1 addition & 1 deletion Documentation/API/Parsers/ParseLyricsFromChartSection.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);

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

Console.WriteLine(notes.Count); // 12
Console.WriteLine(lyrics.Count); // 12
```

##### C++
Expand Down
2 changes: 1 addition & 1 deletion Documentation/API/Parsers/ParseNotesFromChartSection.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);

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

Console.WriteLine(notes.Count); // 8
Console.WriteLine(notes.Length); // 8
```

##### C++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var sections = Parsers.ParseSectionsFromChart(contents);

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

Console.WriteLine(timeSignatures.Count); // 4
Console.WriteLine(timeSignatures.Length); // 4
```

##### C++
Expand Down
25 changes: 18 additions & 7 deletions Documentation/API/Utilities/CalculateAccuracyRatio.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ const int seconds = 2;
const int resolution = 192;
const int positionDelta = 50;

var bpmChanges = new Dictionary<int, int> { { 0, 120000 } };
var bpmChanges = new Tempo[] { new() { Position = 0, BPM = 120000 } };

var timeSignatureChanges = new TimeSignature[] { new() { Position = 0, Numerator = 4, Denominator = 2 } };

var note = new Note { Position = 750 };
var currentPosition = Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges);

var currentPosition =
Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges, timeSignatureChanges);

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

Expand All @@ -37,11 +41,12 @@ int main()
const int resolution = 192;
const int positionDelta = 50;

std::map<int, int> bpmChanges = {{0, 120000}};
std::vector<Tempo> bpmChanges = {{0, 120000}};
std::vector<TimeSignature> timeSignatureChanges = {{0, 4}};

auto note = new Note{750};
auto currentPosition =
ConvertSecondsToTicks(seconds, resolution, bpmChanges);
auto currentPosition = ConvertSecondsToTicks(
seconds, resolution, bpmChanges, timeSignatureChanges);

auto value =
CalculateAccuracyRatio(note->Position, currentPosition, positionDelta);
Expand All @@ -62,9 +67,15 @@ func _ready() -> void:
var resolution = 192
var position_delta = 50

var bpm_changes = { 0: 120000 }
var bpm_changes = [
{"position": 0, "bpm": 120000 }
]

var time_signature_changes = [
{"position": 0, "numerator": 4, "denominator": 2 }
]

var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes)
var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes, time_signature_changes)

var value = rhythm_game_utilities.calculate_accuracy_ratio(750, current_position, position_delta)

Expand Down
36 changes: 17 additions & 19 deletions Documentation/API/Utilities/CalculateBeatBars.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@
##### C#

```csharp
const int resolution = 192;
const int timeSignature = 4;

var bpmChanges = new Dictionary<int, int>
var bpmChanges = new Tempo[]
{
{ 0, 88000 },
{ 3840, 112000 },
{ 9984, 89600 },
{ 22272, 112000 },
{ 33792, 111500 },
{ 34560, 112000 },
{ 42240, 111980 }
new() { Position = 0, BPM = 88000 }, new() { Position = 3840, BPM = 112000 },
new() { Position = 9984, BPM = 89600 }, new() { Position = 22272, BPM = 112000 },
new() { Position = 33792, BPM = 111500 }, new() { Position = 34560, BPM = 112000 },
new() { Position = 42240, BPM = 111980 }
};

var beatBars = Utilities.CalculateBeatBars(bpmChanges, resolution, timeSignature, true);
var beatBars = Utilities.CalculateBeatBars(bpmChanges);

Console.WriteLine(beatBars.Count); // 440
Console.WriteLine(beatBars.Length); // 440
```

##### C++
Expand All @@ -38,7 +32,7 @@ int main()
const int resolution = 192;
const int timeSignature = 4;

std::map<int, int> bpmChanges = {
std::vector<Tempo> bpmChanges = {
{0, 88000}, {3840, 112000}, {9984, 89600}, {22272, 112000},
{33792, 111500}, {34560, 112000}, {42240, 111980}};

Expand All @@ -60,11 +54,15 @@ func _ready() -> void:
var resolution = 192
var time_signature = 4

var bpm_changes = {
0: 88000, 3840: 112000, 9984: 89600,
22272: 112000, 33792: 111500, 34560: 112000,
42240: 111980
}
var bpm_changes = [
{"position": 0, "bpm": 8800 },
{"position": 3840, "bpm": 112000 },
{"position": 9984, "bpm": 89600 },
{"position": 22272, "bpm": 112000 },
{"position": 33792, "bpm": 111500 },
{"position": 34560, "bpm": 112000 },
{"position": 42240, "bpm": 111980 }
]

var beat_bars = rhythm_game_utilities.calculate_beat_bars(bpm_changes, resolution, time_signature, true)

Expand Down
46 changes: 28 additions & 18 deletions Documentation/API/Utilities/ConvertSecondsToTicks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ using RhythmGameUtilities;
const int seconds = 5;
const int resolution = 192;

var bpmChanges = new Dictionary<int, int>
var bpmChanges = new Tempo[]
{
{ 0, 88000 },
{ 3840, 112000 },
{ 9984, 89600 },
{ 22272, 112000 },
{ 33792, 111500 },
{ 34560, 112000 },
{ 42240, 111980 }
new() { Position = 0, BPM = 88000 }, new() { Position = 3840, BPM = 112000 },
new() { Position = 9984, BPM = 89600 }, new() { Position = 22272, BPM = 112000 },
new() { Position = 33792, BPM = 111500 }, new() { Position = 34560, BPM = 112000 },
new() { Position = 42240, BPM = 111980 }
};

var ticks = Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges);
var timeSignatureChanges = new TimeSignature[] { new() { Position = 0, Numerator = 4, Denominator = 2 } };

var ticks = Utilities.ConvertSecondsToTicks(seconds, resolution, bpmChanges, timeSignatureChanges);

Console.WriteLine(ticks); // 1408
```
Expand All @@ -41,11 +40,14 @@ int main()
const int seconds = 5;
const int resolution = 192;

std::map<int, int> bpmChanges = {
std::vector<Tempo> bpmChanges = {
{0, 88000}, {3840, 112000}, {9984, 89600}, {22272, 112000},
{33792, 111500}, {34560, 112000}, {42240, 111980}};

auto ticks = ConvertSecondsToTicks(seconds, resolution, bpmChanges);
std::vector<TimeSignature> timeSignatureChanges = {{0, 4, 2}};

auto ticks = ConvertSecondsToTicks(seconds, resolution, bpmChanges,
timeSignatureChanges);

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

Expand All @@ -62,13 +64,21 @@ func _ready() -> void:
var seconds = 5
var resolution = 192

var bpm_changes = {
0: 88000, 3840: 112000, 9984: 89600,
22272: 112000, 33792: 111500, 34560: 112000,
42240: 111980
}
var bpm_changes = [
{"position": 0, "bpm": 8800 },
{"position": 3840, "bpm": 112000 },
{"position": 9984, "bpm": 89600 },
{"position": 22272, "bpm": 112000 },
{"position": 33792, "bpm": 111500 },
{"position": 34560, "bpm": 112000 },
{"position": 42240, "bpm": 111980 }
]

var time_signature_changes = [
{"position": 0, "numerator": 4, "denominator": 2 }
]

var ticks = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes)
var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes, time_signature_changes)

print(ticks) # 1408
print(current_position) # 1408
```
12 changes: 6 additions & 6 deletions Documentation/API/Utilities/ConvertTickToPosition.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
using System;
using RhythmGameUtilities;

const int tick = 2784;
const int tick = 1056;
const int resolution = 192;

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

Console.WriteLine(position); // 14.5
Console.WriteLine(position); // 5.5
```

##### C++
Expand All @@ -27,12 +27,12 @@ using namespace RhythmGameUtilities;

int main()
{
const int tick = 2784;
const int tick = 1056;
const int resolution = 192;

auto position = ConvertTickToPosition(tick, resolution);

std::cout << position << std::endl; // 14.5
std::cout << position << std::endl; // 5.5

return 0;
}
Expand All @@ -44,10 +44,10 @@ int main()
extends Node
func _ready() -> void:
var tick = 2784
var tick = 1056
var resolution = 192
var position = rhythm_game_utilities.convert_tick_to_position(tick, resolution)
print(position) # 14.5
print(position) # 5.5
```
70 changes: 70 additions & 0 deletions Documentation/API/Utilities/FindPositionNearGivenTick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# FindPositionNearGivenTick

> Languages: `C#` `C++` `GDScript`

##### C#

```csharp
var notes = new Note[]
{
new() { Position = 768 }, new() { Position = 960 }, new() { Position = 1152 },
new() { Position = 1536 }, new() { Position = 1728 }, new() { Position = 1920 },
new() { Position = 2304 }, new() { Position = 2496 }, new() { Position = 2688 },
new() { Position = 3072 }, new() { Position = 3264 }
};

var note = Utilities.FindPositionNearGivenTick(notes, 750);

if (note != null)
{
Console.Write(note.Value.Position); // 768
}
```

##### C++

```cpp
#include <iostream>

#include "RhythmGameUtilities/Utilities.hpp"

using namespace RhythmGameUtilities;

int main()
{
std::vector<Note> notes = {{768, 0, 0}, {960, 0, 0}, {1152, 0, 0},
{1536, 0, 0}, {1728, 0, 0}, {1920, 0, 0},
{2304, 0, 0}, {2496, 0, 0}, {2688, 0, 0},
{3072, 0, 0}, {3264, 0, 0}};

auto note = FindPositionNearGivenTick(notes, 750);

if (note)
{
std::cout << note->Position << std::endl; // 768
}

return 0;
}
```

##### GDScript

```gdscript
extends Node

func _ready() -> void:
var seconds = 5
var resolution = 192

var notes = [
{"position": 768 }, {"position": 960 }, {"position": 1152 },
{"position": 1536 }, {"position": 1728 }, {"position": 1920 },
{"position": 2304 }, {"position": 2496 }, {"position": 2688 },
{"position": 3072 }, {"position": 3264 }
]

var note = rhythm_game_utilities.find_position_near_given_tick(notes, 750);

print(note["position"]) # 768
```
23 changes: 13 additions & 10 deletions Documentation/API/Utilities/IsOnTheBeat.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ const int bpm = 120;
const float currentTime = 10f;
const float delta = 0.05f;

if (Utilities.IsOnTheBeat(bpm, currentTime, delta))
{
Console.WriteLine("Is on the beat!");
}
var isOnTheBeat = Utilities.IsOnTheBeat(bpm, currentTime, delta);

Console.WriteLine(isOnTheBeat ? "Is on the beat!" : "Is not on the beat!"); // "Is on the beat!"
```

##### C++
Expand All @@ -30,13 +29,13 @@ using namespace RhythmGameUtilities;
int main()
{
const int bpm = 120;
const float currentTime = 10f;
const float currentTime = 10;
const float delta = 0.05f;

if (IsOnTheBeat(bpm, currentTime, delta))
{
std::cout << "Is on the beat!" << std::endl;
}
auto isOnTheBeat = IsOnTheBeat(bpm, currentTime, delta);

std::cout << (isOnTheBeat ? "Is on the beat!" : "Is not on the beat!")
<< std::endl; // "Is on the beat!"

return 0;
}
Expand All @@ -52,6 +51,10 @@ func _ready() -> void:
var current_time = 10
var delta = 0.05
if rhythm_game_utilities.is_on_the_beat(bpm, current_time, delta):
var isOnTheBeat = rhythm_game_utilities.is_on_the_beat(bpm, current_time, delta)
if isOnTheBeat: # "Is on the beat!"
print("Is on the beat!")
else:
print("Is not on the beat!")
```
1 change: 1 addition & 0 deletions Documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ _Prototype game built using these utilities._
1. [CalculateBeatBars](#utilitiescalculatebeatbars)
1. [ConvertSecondsToTicks](#utilitiesconvertsecondstoticks)
1. [ConvertTickToPosition](#utilitiesconvertticktoposition)
1. [FindPositionNearGivenTick](#utilitiesfindpositionneargiventick)
1. [IsOnTheBeat](#utilitiesisonthebeat)
1. [RoundUpToTheNearestMultiplier](#utilitiesrounduptothenearestmultiplier)

Expand Down
Loading