-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ae2c29
commit 33f1a4e
Showing
7 changed files
with
521 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/KristofferStrube.Blazor.WebAudio/Converters/DistanceModelTypeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace KristofferStrube.Blazor.WebAudio.Converters; | ||
|
||
internal class DistanceModelTypeConverter : JsonConverter<DistanceModelType> | ||
{ | ||
public override DistanceModelType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return reader.GetString() switch | ||
{ | ||
"linear" => DistanceModelType.Linear, | ||
"inverse" => DistanceModelType.Inverse, | ||
"exponential" => DistanceModelType.Exponential, | ||
var value => throw new ArgumentException($"Value '{value}' was not a valid {nameof(DistanceModelType)}.") | ||
}; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, DistanceModelType value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value switch | ||
{ | ||
DistanceModelType.Linear => "linear", | ||
DistanceModelType.Inverse => "inverse", | ||
DistanceModelType.Exponential => "exponential", | ||
_ => throw new ArgumentException($"Value '{value}' was not a valid {nameof(DistanceModelType)}.") | ||
}); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/KristofferStrube.Blazor.WebAudio/Converters/PanningModelTypeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace KristofferStrube.Blazor.WebAudio.Converters; | ||
|
||
internal class PanningModelTypeConverter : JsonConverter<PanningModelType> | ||
{ | ||
public override PanningModelType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return reader.GetString() switch | ||
{ | ||
"equalpower" => PanningModelType.EqualPower, | ||
"HRTF" => PanningModelType.HRTF, | ||
var value => throw new ArgumentException($"Value '{value}' was not a valid {nameof(PanningModelType)}.") | ||
}; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, PanningModelType value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value switch | ||
{ | ||
PanningModelType.EqualPower => "equalpower", | ||
PanningModelType.HRTF => "HRTF", | ||
_ => throw new ArgumentException($"Value '{value}' was not a valid {nameof(PanningModelType)}.") | ||
}); | ||
} | ||
} |
Oops, something went wrong.