Imports System.ComponentModel
Imports VUMeter.SampleAudioAPI
Public Class Mixer
Private AudioAPI As New SampleAudioAPI()
Private WithEvents Observer As New Windows.Forms.Timer() With {.Interval = 10, .Enabled = True}
Sub New()
InitializeComponent()
MICROPHONE_BAR.Maximum = 200
End Sub
Private Sub Start(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
IN_MasterScalarValue = AudioAPI.IN_MasterScalar
RaiseEvent MicrophoneValueChanged(IN_MasterScalarValue)
End Sub
Private Sub Observer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Observer.Tick
If Not ((MICROPHONE.Checked = False) And (AudioAPI.IN_MUTE = True)) Then
MICROPHONE.Checked = If(AudioAPI.IN_MUTE = True, False, True)
End If
Refresher()
End Sub
Private IN_MasterScalarValue As Single = 0.0F
Private Event MicrophoneValueChanged(ByVal value As Single)
Private Sub Microphone_ValueChanged(ByVal value As Single) Handles Me.MicrophoneValueChanged
IN_MasterScalarValue = value
MICROPHONE_BAR.Value = (SingleToIntPercentage(value))
End Sub
Dim _SMOOTHTRANSITION As Boolean = True
Private Sub Refresher()
'ไมค์
VPB_IN_MASTER.Value = SingleToIntPercentage(AudioAPI.Value(Channels.IN_Master, _SmoothTransition))
End Sub
Private Sub Microphone_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MICROPHONE.CheckedChanged
'เช็ค MUTE
AudioAPI.IN_MUTE = If(MICROPHONE.Checked = True, False, True)
End Sub
Private Sub Microphone_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MICROPHONE_BAR.Scroll
AudioAPI.IN_MasterScalar = IntToSinglePercentage(MICROPHONE_BAR.Value)
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Dim value As String = Convert.ToString(value)
TextBox1.Text = value(0)
End Sub
End Class
<BrowsableAttribute(True), DescriptionAttribute("Vertical ProgressBar.")>
Public NotInheritable Class VerticalProgressBar
Inherits ProgressBar
Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.Style = cp.Style Or &H4
Return cp
End Get
End Property
End Class
Code (VB.NET)
อยากได้ค่าระดับความดังของเสียงที่แสดงในแถบ bar ไปแสดงออกเป็นตัวเลขที่ textbox1 ต้องทำอย่างไรครับ
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
TextBox1.Text = ProgressBar1.Value
End Sub
End Class