-
Notifications
You must be signed in to change notification settings - Fork 450
/
EndpointTests.cs
107 lines (98 loc) · 3.63 KB
/
EndpointTests.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using CSCore.CoreAudioAPI;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace CSCore.Test.CoreAudioAPI
{
[TestClass]
public class EndpointTests
{
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanCreateAudioEndpointVolume()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var endpointVolume = AudioEndpointVolume.FromDevice(device))
{
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanGetAudioEndpointVolume()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var endpointVolume = AudioEndpointVolume.FromDevice(device))
{
var volume = endpointVolume.GetMasterVolumeLevelScalar();
Debug.WriteLine("Volume: {0}", volume);
endpointVolume.SetMasterVolumeLevelScalar(0.5f, Guid.Empty);
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanGetAudioEndpointVolumeChannelCount()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var endpointVolume = AudioEndpointVolume.FromDevice(device))
{
Debug.WriteLine(endpointVolume.GetChannelCount());
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanCreateAudioEndpointVolumeNotification()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var endpointVolume = AudioEndpointVolume.FromDevice(device))
{
AudioEndpointVolumeCallback callback = new AudioEndpointVolumeCallback();
callback.NotifyRecived += (s, e) =>
{
Debug.WriteLine("Notification1");
//Debug.Assert(e.Channels == endpointVolume.ChannelCount);
};
endpointVolume.RegisterControlChangeNotify(callback);
var vol = endpointVolume.GetChannelVolumeLevelScalar(0);
endpointVolume.SetChannelVolumeLevelScalar(0, 1f, Guid.Empty);
endpointVolume.SetChannelVolumeLevelScalar(0, vol, Guid.Empty);
endpointVolume.UnregisterControlChangeNotify(callback);
System.Threading.Thread.Sleep(1000);
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanCreateAudioMeterInformation()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var meter = AudioMeterInformation.FromDevice(device))
{
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanGetAudioMeterInformationPeakValue()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var meter = AudioMeterInformation.FromDevice(device))
{
Console.WriteLine(meter.PeakValue);
}
}
[TestMethod]
[TestCategory("CoreAudioAPI.Endpoint")]
public void CanGetAudioMeterInformationChannelsPeaks()
{
using (var device = Utils.GetDefaultRenderDevice())
using (var meter = AudioMeterInformation.FromDevice(device))
{
for (int i = 0; i < meter.MeteringChannelCount; i++)
{
Console.WriteLine(meter[i]);
}
}
}
}
}