diff --git a/BRRSuite.csproj b/BRRSuite.csproj
index c91103f..b35d7e4 100644
--- a/BRRSuite.csproj
+++ b/BRRSuite.csproj
@@ -12,8 +12,8 @@
README.md
git
False
- 1.0.1
- 1.0.1
+ 1.1.0
+ 1.1.0
LICENSE
True
False
@@ -24,6 +24,7 @@
snes;brr;audio;spc700
BRR Suite
+ $(AssemblyVersion)
diff --git a/Conversion.cs b/Conversion.cs
index 63d8af1..7a77a78 100644
--- a/Conversion.cs
+++ b/Conversion.cs
@@ -79,7 +79,7 @@ public static int Clamp(int v) {
///
/// A new 15-bit value.
public static int Clip(int v) => v switch {
- > 0x7FFF => v - 2, // equivalent to (p + 0x7FFF) & 0x7FFF
+ > 0x7FFF => (v + 0x7FFF) & 0x7FFF,
< -0x8000 => 0, // clipped to 0
> 0x3FFF => v - 0x8000, // [4000,7FFF] => [-4000,-1]
< -0x4000 => v + 0x8000, // [-8000,-4001] => [0,-3FFF]
diff --git a/SampleRate.cs b/SampleRate.cs
index f90a29d..4d4e3cd 100644
--- a/SampleRate.cs
+++ b/SampleRate.cs
@@ -3,11 +3,11 @@
///
/// Represents an audio sample rate given in hertz.
///
-public sealed class SampleRate : IComparable {
+public readonly struct SampleRate : IComparable {
///
/// Gets the number of samples per second expressed by this frequency.
///
- public int Frequency { get; }
+ public readonly int Frequency { get; }
///
/// Gets the frequency expressed as and rounded to the nearest kilohertz.
@@ -19,11 +19,6 @@ public sealed class SampleRate : IComparable {
///
public decimal Cram => 32000M / Frequency;
- ///
- /// Gets the value of this frequency with units (Hz).
- ///
- public string Name { get; }
-
///
/// Creates a new instance of the class with the specified frequency.
///
@@ -34,12 +29,11 @@ public SampleRate(int frequency) {
throw new ArgumentException("Frequency should be a positive, non-zero value.");
}
- Name = $"{frequency} Hz";
Frequency = frequency;
}
///
- public override string ToString() => Name;
+ public override string ToString() => $"{Frequency} Hz";
///
/// Calculates the ratio representing this sample rate resampled to the given target frequency.
@@ -57,10 +51,7 @@ public decimal ResampleTo(SampleRate targetFrequency) {
///
/// If is .
- public int CompareTo(SampleRate? other) {
- if (other is null) {
- throw new ArgumentNullException(nameof(other), "Comparator argument was null.");
- }
+ public int CompareTo(SampleRate other) {
return Frequency.CompareTo(other.Frequency);
}
@@ -88,4 +79,12 @@ public int CompareTo(SampleRate? other) {
/// Represents a sample rate of 44100 Hz, the standard for CD-quality audio.
///
public static readonly SampleRate SR44100 = new(44100);
+
+
+
+#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
+ public static explicit operator SampleRate(int sr) => new(sr);
+
+ public static implicit operator int(SampleRate sr) => sr.Frequency;
+#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}