namespace Unosquare.RaspberryIO.Computer
{
///
/// Manage the volume of any sound device.
///
public readonly struct AudioState
{
///
/// Initializes a new instance of the struct.
///
/// The card number.
/// Name of the control.
/// The volume level in percentaje.
/// The volume level in decibels.
/// if set to true the audio is mute.
public AudioState(int cardNumber, string controlName, int level, float decibels, bool isMute)
{
CardNumber = cardNumber;
ControlName = controlName;
Level = level;
Decibels = decibels;
IsMute = isMute;
}
///
/// Gets the card number.
///
public int CardNumber { get; }
///
/// Gets the name of the current control.
///
public string ControlName { get; }
///
/// Gets the volume level in percentage.
///
public int Level { get; }
///
/// Gets the volume level in decibels.
///
public float Decibels { get; }
///
/// Gets a value indicating whether the audio is mute.
///
public bool IsMute { get; }
///
/// Returns a that represents the audio state.
///
///
/// A that represents the audio state.
///
public override string ToString() =>
"Device information: \n" +
$">> Name: {ControlName}\n" +
$">> Card number: {CardNumber}\n" +
$">> Volume (%): {Level}%\n" +
$">> Volume (dB): {Decibels:0.00}dB\n" +
$">> Mute: [{(IsMute ? "Off" : "On")}]\n\n";
}
}