当前位置: 动力学知识库 > 问答 > 编程问答 >

audio - Get/Set Line-In Volume in Windows 7 Using VB.NET

问题描述:

I'm looking for a way to get and set the line-in volume in VB.NET. I was looking at NAudio at first which looked good while capturing audio from the Mic jack, but not so much once I started using the Line In jack (unless I was doing something completely wrong with it).

So now I'm working with CoreAudioApi.dll, but not having any luck on getting the current volume level. I was only able to find the device "rear blue in", which corresponds with the blue line in jack in the back.

Does anyone have any tips on what my next step(s) should be?

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

On Error Resume Next

Dim enmDevice As New MMDeviceEnumerator

Dim devDevice As MMDeviceCollection = enmDevice.EnumerateAudioEndPoints(EDataFlow.eAll, EDeviceState.DEVICE_STATEMASK_ALL)

Dim intLineIn As Int32 = -1

For i As Int32 = 0 To devDevice.Count - 1

If devDevice.Item(i).FriendlyName = "Rear Blue In" Then

intLineIn = i

Exit For

End If

Next

If intLineIn = -1 Then Exit Sub

Dim devLineIn As MMDevice = devDevice.Item(intLineIn)

MessageBox.Show(devLineIn.AudioEndpointVolume.MasterVolumeLevel)

MessageBox.Show(devLineIn.AudioEndpointVolume.MasterVolumeLevelScalar)

MessageBox.Show(devLineIn.AudioEndpointVolume.VolumeRange.MindB)

MessageBox.Show(devLineIn.AudioEndpointVolume.VolumeRange.MaxdB)

MessageBox.Show(devLineIn.AudioEndpointVolume.VolumeRange.IncrementdB)

End Sub

分享给朋友:
您可能感兴趣的文章:
随机阅读: