73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using System;
|
|
|
|
namespace Unosquare.RaspberryIO.Computer {
|
|
/// <summary>
|
|
/// Manage the volume of any sound device.
|
|
/// </summary>
|
|
public readonly struct AudioState {
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="AudioState"/> struct.
|
|
/// </summary>
|
|
/// <param name="cardNumber">The card number.</param>
|
|
/// <param name="controlName">Name of the control.</param>
|
|
/// <param name="level">The volume level in percentaje.</param>
|
|
/// <param name="decibels">The volume level in decibels.</param>
|
|
/// <param name="isMute">if set to <c>true</c> the audio is mute.</param>
|
|
public AudioState(Int32 cardNumber, String controlName, Int32 level, Single decibels, Boolean isMute) {
|
|
this.CardNumber = cardNumber;
|
|
this.ControlName = controlName;
|
|
this.Level = level;
|
|
this.Decibels = decibels;
|
|
this.IsMute = isMute;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the card number.
|
|
/// </summary>
|
|
public Int32 CardNumber {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the name of the current control.
|
|
/// </summary>
|
|
public String ControlName {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the volume level in percentage.
|
|
/// </summary>
|
|
public Int32 Level {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the volume level in decibels.
|
|
/// </summary>
|
|
public Single Decibels {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a value indicating whether the audio is mute.
|
|
/// </summary>
|
|
public Boolean IsMute {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a <see cref="String" /> that represents the audio state.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// A <see cref="String" /> that represents the audio state.
|
|
/// </returns>
|
|
public override String ToString() =>
|
|
"Device information: \n" +
|
|
$">> Name: {this.ControlName}\n" +
|
|
$">> Card number: {this.CardNumber}\n" +
|
|
$">> Volume (%): {this.Level}%\n" +
|
|
$">> Volume (dB): {this.Decibels:0.00}dB\n" +
|
|
$">> Mute: [{(this.IsMute ? "Off" : "On")}]\n\n";
|
|
}
|
|
} |