Skip to content

Commit 1eb7754

Browse files
committed
chore(release): merge dev into main for v0.0.21
2 parents d7a8c1a + 33281ca commit 1eb7754

188 files changed

Lines changed: 7161 additions & 900 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Audio/FmodEventPath.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,33 @@ namespace STS2RitsuLib.Audio
33
/// <summary>
44
/// FMOD Studio event path (e.g. <c>event:/sfx/block_gain</c>). Implicitly converts to <see cref="string" />.
55
/// </summary>
6+
/// <param name="Value">Raw Studio path string.</param>
67
public readonly record struct FmodEventPath(string Value)
78
{
9+
/// <summary>
10+
/// True when <see cref="Value" /> is null or empty.
11+
/// </summary>
812
public bool IsEmpty => string.IsNullOrEmpty(Value);
913

14+
/// <summary>
15+
/// Returns the wrapped path string.
16+
/// </summary>
1017
public static implicit operator string(FmodEventPath path)
1118
{
1219
return path.Value;
1320
}
1421

22+
/// <summary>
23+
/// Wraps a string as an <see cref="FmodEventPath" />.
24+
/// </summary>
1525
public static implicit operator FmodEventPath(string value)
1626
{
1727
return new(value);
1828
}
1929

30+
/// <summary>
31+
/// Returns <see cref="Value" />.
32+
/// </summary>
2033
public override string ToString()
2134
{
2235
return Value;

Audio/FmodParameterMap.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
namespace STS2RitsuLib.Audio
22
{
3-
/// <summary>Builds parameter maps for <see cref="IFmodOneShotPlayback" /> multi-parameter overloads.</summary>
3+
/// <summary>
4+
/// Builds parameter maps for <see cref="IFmodOneShotPlayback" /> multi-parameter overloads.
5+
/// </summary>
46
public static class FmodParameterMap
57
{
8+
/// <summary>
9+
/// Empty parameter map for overloads that require a dictionary instance.
10+
/// </summary>
611
public static Dictionary<string, float> Empty()
712
{
813
return [];
914
}
1015

16+
/// <summary>
17+
/// Single named parameter suitable for one-shot playback helpers.
18+
/// </summary>
1119
public static Dictionary<string, float> Single(string name, float value)
1220
{
1321
return new() { [name] = value };
1422
}
1523

24+
/// <summary>
25+
/// Builds a map from name/value tuples; duplicates last writer wins.
26+
/// </summary>
1627
public static Dictionary<string, float> Of(params (string Name, float Value)[] pairs)
1728
{
1829
if (pairs.Length == 0)

Audio/FmodPathRoundRobinPool.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
namespace STS2RitsuLib.Audio
22
{
3-
/// <summary>In-memory pool of event or file paths with simple no-repeat random selection.</summary>
3+
/// <summary>
4+
/// In-memory pool of event or file paths with simple no-repeat random selection.
5+
/// </summary>
46
public sealed class FmodPathRoundRobinPool
57
{
68
private readonly List<string> _entries;
79
private readonly Random _rng = new();
810
private int _lastIndex = -1;
911

12+
/// <summary>
13+
/// Copies <paramref name="paths" /> into an internal list (may be empty).
14+
/// </summary>
1015
public FmodPathRoundRobinPool(IEnumerable<string> paths)
1116
{
1217
ArgumentNullException.ThrowIfNull(paths);
1318
_entries = [.. paths];
1419
}
1520

21+
/// <summary>
22+
/// Snapshot of configured paths.
23+
/// </summary>
1624
public IReadOnlyList<string> Entries => _entries;
1725

26+
/// <summary>
27+
/// Picks a random path, avoiding the same index as the previous pick when more than one entry exists.
28+
/// </summary>
1829
public bool TryPickNext(out string path)
1930
{
2031
path = "";
21-
if (_entries.Count == 0)
22-
return false;
23-
24-
if (_entries.Count == 1)
32+
switch (_entries.Count)
2533
{
26-
path = _entries[0];
27-
return true;
34+
case 0:
35+
return false;
36+
case 1:
37+
path = _entries[0];
38+
return true;
2839
}
2940

3041
int index;

Audio/FmodPlaybackThrottle.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
namespace STS2RitsuLib.Audio
44
{
5-
/// <summary>Per-key cooldown for rapid triggers (ms, via <see cref="Stopwatch" /> ticks).</summary>
5+
/// <summary>
6+
/// Per-key cooldown for rapid triggers (ms, via <see cref="Stopwatch" /> ticks).
7+
/// </summary>
68
public static class FmodPlaybackThrottle
79
{
810
private static readonly Lock Gate = new();
911
private static readonly Dictionary<string, long> LastTicks = new(StringComparer.Ordinal);
1012

11-
/// <summary>Returns false if <paramref name="key" /> was used within <paramref name="cooldownMs" />.</summary>
13+
/// <summary>
14+
/// Returns false if <paramref name="key" /> was used within <paramref name="cooldownMs" />.
15+
/// </summary>
1216
public static bool TryEnter(string key, int cooldownMs)
1317
{
1418
if (cooldownMs <= 0)
@@ -27,6 +31,9 @@ public static bool TryEnter(string key, int cooldownMs)
2731
}
2832
}
2933

34+
/// <summary>
35+
/// Removes cooldown state for <paramref name="key" /> so the next <see cref="TryEnter" /> may pass.
36+
/// </summary>
3037
public static void Clear(string key)
3138
{
3239
lock (Gate)
@@ -35,6 +42,9 @@ public static void Clear(string key)
3542
}
3643
}
3744

45+
/// <summary>
46+
/// Clears all throttle keys.
47+
/// </summary>
3848
public static void ClearAll()
3949
{
4050
lock (Gate)

Audio/FmodStudioBusAccess.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,29 @@
33

44
namespace STS2RitsuLib.Audio
55
{
6-
/// <summary>Direct bus objects from FMOD Studio (parallel to strings in <see cref="FmodStudioRouting" />).</summary>
6+
/// <summary>
7+
/// Direct bus objects from FMOD Studio (parallel to strings in <see cref="FmodStudioRouting" />).
8+
/// </summary>
79
public static class FmodStudioBusAccess
810
{
911
private static readonly StringName GetVolume = new("get_volume");
1012
private static readonly StringName SetVolume = new("set_volume");
1113
private static readonly StringName SetMute = new("set_mute");
1214
private static readonly StringName SetPaused = new("set_paused");
1315

16+
/// <summary>
17+
/// Resolves a Studio bus object for <paramref name="busPath" />; null when the addon call fails.
18+
/// </summary>
1419
public static GodotObject? TryGetBus(string busPath)
1520
{
1621
return !FmodStudioGateway.TryCall(out var v, FmodStudioMethodNames.GetBus, busPath)
1722
? null
1823
: v.AsGodotObject();
1924
}
2025

26+
/// <summary>
27+
/// Reads linear volume for <paramref name="busPath" />; 0 when missing or on error.
28+
/// </summary>
2129
public static float TryGetVolume(string busPath)
2230
{
2331
var bus = TryGetBus(busPath);
@@ -35,6 +43,9 @@ public static float TryGetVolume(string busPath)
3543
}
3644
}
3745

46+
/// <summary>
47+
/// Sets linear volume on the resolved bus.
48+
/// </summary>
3849
public static bool TrySetVolume(string busPath, float linearVolume)
3950
{
4051
var bus = TryGetBus(busPath);
@@ -53,6 +64,9 @@ public static bool TrySetVolume(string busPath, float linearVolume)
5364
}
5465
}
5566

67+
/// <summary>
68+
/// Mutes or unmutes the bus.
69+
/// </summary>
5670
public static bool TrySetMute(string busPath, bool muted)
5771
{
5872
var bus = TryGetBus(busPath);
@@ -71,6 +85,9 @@ public static bool TrySetMute(string busPath, bool muted)
7185
}
7286
}
7387

88+
/// <summary>
89+
/// Pauses or resumes the bus.
90+
/// </summary>
7491
public static bool TrySetPaused(string busPath, bool paused)
7592
{
7693
var bus = TryGetBus(busPath);

Audio/FmodStudioDirectOneShots.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ namespace STS2RitsuLib.Audio
1010
/// </summary>
1111
public static class FmodStudioDirectOneShots
1212
{
13+
/// <summary>
14+
/// Plays a one-shot by event path via the Godot FMOD addon.
15+
/// </summary>
1316
public static bool TryPlay(string eventPath)
1417
{
1518
return FmodStudioGateway.TryCall(FmodStudioMethodNames.PlayOneShot, eventPath);
1619
}
1720

21+
/// <summary>
22+
/// Plays a one-shot with initial parameter values.
23+
/// </summary>
1824
public static bool TryPlay(string eventPath, IReadOnlyDictionary<string, float> parameters)
1925
{
2026
var server = FmodStudioGateway.TryGetServer();
@@ -37,6 +43,9 @@ public static bool TryPlay(string eventPath, IReadOnlyDictionary<string, float>
3743
}
3844
}
3945

46+
/// <summary>
47+
/// Plays a one-shot using a Studio event GUID string.
48+
/// </summary>
4049
public static bool TryPlayUsingGuid(string eventGuid)
4150
{
4251
return FmodStudioGateway.TryCall(FmodStudioMethodNames.PlayOneShotUsingGuid, eventGuid);

Audio/FmodStudioEventInstances.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33

44
namespace STS2RitsuLib.Audio
55
{
6-
/// <summary>Long-lived Studio event instances (manual start/stop/release).</summary>
6+
/// <summary>
7+
/// Long-lived Studio event instances (manual start/stop/release).
8+
/// </summary>
79
public static class FmodStudioEventInstances
810
{
11+
/// <summary>
12+
/// Creates a Studio event or snapshot instance; null when creation fails.
13+
/// </summary>
914
public static GodotObject? TryCreate(string eventOrSnapshotPath)
1015
{
1116
return !FmodStudioGateway.TryCall(out var v, FmodStudioMethodNames.CreateEventInstance, eventOrSnapshotPath)
1217
? null
1318
: v.AsGodotObject();
1419
}
1520

21+
/// <summary>
22+
/// Calls <c>start</c> on the instance when non-null.
23+
/// </summary>
1624
public static bool TryStart(GodotObject? instance)
1725
{
1826
if (instance is null)
@@ -30,6 +38,9 @@ public static bool TryStart(GodotObject? instance)
3038
}
3139
}
3240

41+
/// <summary>
42+
/// Stops the instance; <paramref name="allowFadeOut" /> maps to FMOD stop mode.
43+
/// </summary>
3344
public static bool TryStop(GodotObject? instance, bool allowFadeOut = true)
3445
{
3546
if (instance is null)
@@ -47,6 +58,9 @@ public static bool TryStop(GodotObject? instance, bool allowFadeOut = true)
4758
}
4859
}
4960

61+
/// <summary>
62+
/// Releases native resources for the instance; errors are logged only.
63+
/// </summary>
5064
public static void TryRelease(GodotObject? instance)
5165
{
5266
if (instance is null)

Audio/FmodStudioLoadBankMode.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
namespace STS2RitsuLib.Audio
22
{
3-
/// <summary>Values for FMOD Studio load_bank via the Godot FMOD addon.</summary>
3+
/// <summary>
4+
/// Values for FMOD Studio load_bank via the Godot FMOD addon.
5+
/// </summary>
46
public enum FmodStudioLoadBankMode
57
{
8+
/// <summary>
9+
/// Default blocking load.
10+
/// </summary>
611
Normal = 0,
12+
13+
/// <summary>
14+
/// Load without blocking the caller.
15+
/// </summary>
716
NonBlocking = 1,
17+
18+
/// <summary>
19+
/// Decompress sample data into memory (Studio load flag).
20+
/// </summary>
821
DecompressSamples = 2,
922
}
1023
}

0 commit comments

Comments
 (0)