C#
C# Sound Meter 사운드 미터
J-sean
2023. 10. 28. 20:10
반응형
Sound Meter를 표시해 보자.
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
|
using System;
using System.Text;
using NAudio.CoreAudioApi;
namespace ConsoleApp1
{ class Program
{
static void Main()
{
MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
MMDevice device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
while (true)
{
//Console.Write("\r{0}", device.AudioMeterInformation.MasterPeakValue);
//System.Threading.Thread.Sleep(100);
System.Threading.Thread.Sleep(100);
float volume = device.AudioMeterInformation.MasterPeakValue;
int scale = (int)Math.Floor(volume * 79);
StringBuilder sb = new StringBuilder();
Console.Write("\r");
sb.Append("Value: " + scale + " ");
if (scale < 1)
{
sb.Append(' ', 79);
Console.Write(sb.ToString());
continue;
}
sb.Append('=', scale);
sb.Append(' ', 79 - scale);
Console.Write(sb.ToString());
}
}
}
}
|
코드를 작성하고 실행한다.
※ 참고
Displaying a Volume Meter using NAudio
2023.10.26 - [Python] - Python Core Audio Windows Library 파이썬 코어 오디오 라이브러리
2022.01.06 - [C#] - C# AudioSwitcher System Audio/Sound Volume Control - 시스템 오디오/사운드 볼륨 컨트롤 1
2022.01.07 - [C#] - C# AudioSwitcher System Audio/Sound Volume Control - 시스템 오디오/사운드 볼륨 컨트롤 2
반응형