Skip to content

Commit d6667c9

Browse files
committed
Added comments to csharp methods.
1 parent b75af06 commit d6667c9

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed

RhythmGameUtilities/Scripts/Audio.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ internal static class AudioInternal
3030
public static class Audio
3131
{
3232

33+
/// <summary>
34+
/// Converts samples from an audio file into data used to display a waveform.
35+
/// </summary>
36+
///
37+
/// <param name="samples">Array of sample data from an audio file.</param>
38+
/// <param name="width">Width of the waveform.</param>
39+
/// <param name="height">Height of the waveform.</param>
3340
public static int[][] ConvertSamplesToWaveform(float[] samples, int width, int height)
3441
{
3542
var ptr = AudioInternal.ConvertSamplesToWaveform(samples, samples.Length, width, height);

RhythmGameUtilities/Scripts/Common.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,25 @@ public static class CommonInternal
2929
public static class Common
3030
{
3131

32+
/// <summary>
33+
/// Calculates the linear interpolation between two values.
34+
/// </summary>
35+
///
36+
/// <param name="a">The start value.</param>
37+
/// <param name="b">The end value.</param>
38+
/// <param name="t">The value used for interpolation.</param>
3239
public static float Lerp(float a, float b, float t)
3340
{
3441
return CommonInternal.Lerp(a, b, t);
3542
}
3643

44+
/// <summary>
45+
/// Calculates the fraction, based on a value between two values.
46+
/// </summary>
47+
///
48+
/// <param name="a">The start value.</param>
49+
/// <param name="b">The end value.</param>
50+
/// <param name="v">The value in the middle.</param>
3751
public static float InverseLerp(float a, float b, float v)
3852
{
3953
return CommonInternal.InverseLerp(a, b, v);

RhythmGameUtilities/Scripts/Utilities.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,47 @@ public static class Utilities
7373

7474
public const float SECONDS_PER_MINUTE = 60.0f;
7575

76+
/// <summary>
77+
/// Convert a tick to a 2D/3D position.
78+
/// </summary>
79+
///
80+
/// <param name="tick">The tick.</param>
81+
/// <param name="resolution">The resolution of the song.</param>
7682
public static float ConvertTickToPosition(float tick, int resolution)
7783
{
7884
return UtilitiesInternal.ConvertTickToPosition(tick, resolution);
7985
}
8086

87+
/// <summary>
88+
/// Convert seconds to ticks.
89+
/// </summary>
90+
///
91+
/// <param name="seconds">The seconds to generate ticks with.</param>
92+
/// <param name="resolution">The resolution of the song.</param>
93+
/// <param name="bpmChanges">All BPM changes within the song.</param>
8194
public static int ConvertSecondsToTicks(float seconds, int resolution, Dictionary<int, int> bpmChanges)
8295
{
8396
return UtilitiesInternal.ConvertSecondsToTicksInternal(seconds, resolution, bpmChanges.Keys.ToArray(),
8497
bpmChanges.Values.ToArray(), bpmChanges.Count);
8598
}
8699

100+
/// <summary>
101+
/// Checks to see if the current time of a game or audio file is on the beat.
102+
/// </summary>
103+
///
104+
/// <param name="bpm">The base BPM for a song.</param>
105+
/// <param name="currentTime">A timestamp to compare to the BPM.</param>
87106
public static bool IsOnTheBeat(float bpm, float currentTime)
88107
{
89108
return UtilitiesInternal.IsOnTheBeat(bpm, currentTime);
90109
}
91110

111+
/// <summary>
112+
/// Rounds a value up the nearest multiplier.
113+
/// </summary>
114+
///
115+
/// <param name="value">The value to round.</param>
116+
/// <param name="multiplier">The multiplier to round using.</param>
92117
public static int RoundUpToTheNearestMultiplier(int value, int multiplier)
93118
{
94119
return UtilitiesInternal.RoundUpToTheNearestMultiplier(value, multiplier);
@@ -146,6 +171,13 @@ public static List<BeatBar> CalculateBeatBars(Dictionary<int, int> bpmChanges, i
146171
return null;
147172
}
148173

174+
/// <summary>
175+
/// Calculated the accuracy ratio of the current position against a static position.
176+
/// </summary>
177+
///
178+
/// <param name="position">The position to test against.</param>
179+
/// <param name="currentPosition">The current position.</param>
180+
/// <param name="delta">The plus/minus delta to test the current position against.</param>
149181
public static float CalculateAccuracyRatio(int position, int currentPosition, int delta = 50)
150182
{
151183
return UtilitiesInternal.CalculateAccuracyRatio(position, currentPosition, delta);

UnityPackage/Scripts/Audio.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ internal static class AudioInternal
3030
public static class Audio
3131
{
3232

33+
/// <summary>
34+
/// Converts samples from an audio file into data used to display a waveform.
35+
/// </summary>
36+
///
37+
/// <param name="samples">Array of sample data from an audio file.</param>
38+
/// <param name="width">Width of the waveform.</param>
39+
/// <param name="height">Height of the waveform.</param>
3340
public static int[][] ConvertSamplesToWaveform(float[] samples, int width, int height)
3441
{
3542
var ptr = AudioInternal.ConvertSamplesToWaveform(samples, samples.Length, width, height);

UnityPackage/Scripts/Common.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,25 @@ public static class CommonInternal
2929
public static class Common
3030
{
3131

32+
/// <summary>
33+
/// Calculates the linear interpolation between two values.
34+
/// </summary>
35+
///
36+
/// <param name="a">The start value.</param>
37+
/// <param name="b">The end value.</param>
38+
/// <param name="t">The value used for interpolation.</param>
3239
public static float Lerp(float a, float b, float t)
3340
{
3441
return CommonInternal.Lerp(a, b, t);
3542
}
3643

44+
/// <summary>
45+
/// Calculates the fraction, based on a value between two values.
46+
/// </summary>
47+
///
48+
/// <param name="a">The start value.</param>
49+
/// <param name="b">The end value.</param>
50+
/// <param name="v">The value in the middle.</param>
3751
public static float InverseLerp(float a, float b, float v)
3852
{
3953
return CommonInternal.InverseLerp(a, b, v);

UnityPackage/Scripts/Utilities.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,47 @@ public static class Utilities
7373

7474
public const float SECONDS_PER_MINUTE = 60.0f;
7575

76+
/// <summary>
77+
/// Convert a tick to a 2D/3D position.
78+
/// </summary>
79+
///
80+
/// <param name="tick">The tick.</param>
81+
/// <param name="resolution">The resolution of the song.</param>
7682
public static float ConvertTickToPosition(float tick, int resolution)
7783
{
7884
return UtilitiesInternal.ConvertTickToPosition(tick, resolution);
7985
}
8086

87+
/// <summary>
88+
/// Convert seconds to ticks.
89+
/// </summary>
90+
///
91+
/// <param name="seconds">The seconds to generate ticks with.</param>
92+
/// <param name="resolution">The resolution of the song.</param>
93+
/// <param name="bpmChanges">All BPM changes within the song.</param>
8194
public static int ConvertSecondsToTicks(float seconds, int resolution, Dictionary<int, int> bpmChanges)
8295
{
8396
return UtilitiesInternal.ConvertSecondsToTicksInternal(seconds, resolution, bpmChanges.Keys.ToArray(),
8497
bpmChanges.Values.ToArray(), bpmChanges.Count);
8598
}
8699

100+
/// <summary>
101+
/// Checks to see if the current time of a game or audio file is on the beat.
102+
/// </summary>
103+
///
104+
/// <param name="bpm">The base BPM for a song.</param>
105+
/// <param name="currentTime">A timestamp to compare to the BPM.</param>
87106
public static bool IsOnTheBeat(float bpm, float currentTime)
88107
{
89108
return UtilitiesInternal.IsOnTheBeat(bpm, currentTime);
90109
}
91110

111+
/// <summary>
112+
/// Rounds a value up the nearest multiplier.
113+
/// </summary>
114+
///
115+
/// <param name="value">The value to round.</param>
116+
/// <param name="multiplier">The multiplier to round using.</param>
92117
public static int RoundUpToTheNearestMultiplier(int value, int multiplier)
93118
{
94119
return UtilitiesInternal.RoundUpToTheNearestMultiplier(value, multiplier);
@@ -146,6 +171,13 @@ public static List<BeatBar> CalculateBeatBars(Dictionary<int, int> bpmChanges, i
146171
return null;
147172
}
148173

174+
/// <summary>
175+
/// Calculated the accuracy ratio of the current position against a static position.
176+
/// </summary>
177+
///
178+
/// <param name="position">The position to test against.</param>
179+
/// <param name="currentPosition">The current position.</param>
180+
/// <param name="delta">The plus/minus delta to test the current position against.</param>
149181
public static float CalculateAccuracyRatio(int position, int currentPosition, int delta = 50)
150182
{
151183
return UtilitiesInternal.CalculateAccuracyRatio(position, currentPosition, delta);

0 commit comments

Comments
 (0)