using Newtonsoft.Json;
using RhythmBase.Converters;
namespace RhythmBase.Components;
///
/// Represents an audio file with properties for volume, pitch, pan, and offset.
///
public class RDAudio
{
///
/// Initializes a new instance of the class with default values.
///
public RDAudio() { }
///
/// Gets or sets the file name of the audio.
///
public string Filename { get; set; } = "";
///
/// Gets or sets the volume of the audio.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public int Volume { get; set; } = 100;
///
/// Gets or sets the pitch of the audio.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public int Pitch { get; set; } = 100;
///
/// Gets or sets the pan of the audio.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public int Pan { get; set; }
///
/// Gets or sets the offset of the audio.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
[JsonConverter(typeof(MilliSecondConverter))]
public TimeSpan Offset { get; set; }
///
/// Gets a value indicating whether the file is a valid audio file based on its extension.
///
[JsonIgnore]
public bool IsFile => sourceArray.Contains(Path.GetExtension(Filename));
private static readonly string[] sourceArray =
[
".mp3",
".wav",
".ogg",
".aif",
".aiff"
];
///
/// Returns a string that represents the current object.
///
/// A string that represents the current object.
public override string ToString() => Filename;
}