forked from naudio/NAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAudioVolumeLevel.cs
85 lines (77 loc) · 2.81 KB
/
AudioVolumeLevel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using NAudio.CoreAudioApi.Interfaces;
using System;
namespace NAudio.Wasapi.CoreAudioApi
{
/// <summary>
/// Audio Volume Level
/// </summary>
public class AudioVolumeLevel
{
private readonly IAudioVolumeLevel audioVolumeLevelInterface;
internal AudioVolumeLevel(IAudioVolumeLevel audioVolumeLevel)
{
audioVolumeLevelInterface = audioVolumeLevel;
}
/// <summary>
/// Channel Count
/// </summary>
public uint ChannelCount
{
get
{
audioVolumeLevelInterface.GetChannelCount(out uint result);
return result;
}
}
/// <summary>
/// Get Level Range
/// </summary>
/// <param name="channel">Channel</param>
/// <param name="minLevelDb">Minimum Level dB</param>
/// <param name="maxLevelDb">Maximum Level dB</param>
/// <param name="stepping">Stepping</param>
public void GetLevelRange(uint channel, out float minLevelDb, out float maxLevelDb, out float stepping)
{
audioVolumeLevelInterface.GetLevelRange(channel, out minLevelDb, out maxLevelDb, out stepping);
}
/// <summary>
/// Get Channel Volume Level
/// </summary>
/// <param name="channel">Channel</param>
/// <returns>Volume Level</returns>
public float GetLevel(uint channel)
{
audioVolumeLevelInterface.GetLevel(channel, out float result);
return result;
}
/// <summary>
/// Set Channel Volume Level
/// </summary>
/// <param name="channel">Channel</param>
/// <param name="value">Volume</param>
public void SetLevel(uint channel, float value)
{
var guid = Guid.Empty;
audioVolumeLevelInterface.SetLevel(channel, value, ref guid);
}
/// <summary>
/// Sets all channels in the audio stream to the same uniform volume level, in decibels.
/// </summary>
/// <param name="value">Volume in decibels</param>
public void SetLevelUniform(float value)
{
var guid = Guid.Empty;
audioVolumeLevelInterface.SetLevelUniform(value, ref guid);
}
/// <summary>
/// sets the volume levels, in decibels, of all the channels in the audio stream
/// </summary>
/// <param name="values">Volume levels in decibels</param>
/// <param name="channels">Channels</param>
public void SetLevelAllChannel(float[] values, uint channels)
{
var guid = Guid.Empty;
audioVolumeLevelInterface.SetLevelAllChannel(values, channels, ref guid);
}
}
}