?? form2.frm
字號(hào):
VERSION 5.00
Begin VB.Form Form2
Caption = "波形窗口"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form2"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Visible = 0 'False
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Sub DrawWaves()
' 繪制波形
Dim x As Long ' X位置
Dim leftYOffset As Long ' Y 左聲道Y方向偏移
Dim rightYOffset As Long ' Y 右聲道Y方向偏移
Dim curLeftY As Long ' 左聲道Y方向值
Dim curRightY As Long ' 右聲道Y方向值
Dim lastX As Long ' 最后X位置
Dim lastLeftY As Long ' 最后左聲道Y值
Dim lastRightY As Long ' 最后右聲道Y值
Dim maxAmplitude As Long ' 圖象在窗體中的最大寬度
Dim leftVol As Double ' 左音量
Dim rightVol As Double ' 右音量
Dim scaleFactor As Double ' 在圖像上的采樣率
Dim xStep As Double ' 在圖像上每采樣占的點(diǎn)數(shù)
Dim curSample As Long ' 當(dāng)前采樣值
' 清屏
Me.Cls
' 如果沒有文件,退出
If (Module1.fFileLoaded = False) Then
Exit Sub
End If
' 計(jì)算繪圖的參數(shù)
scaleFactor = (Module1.drawTo - Module1.drawFrom) / Me.Width
If (scaleFactor < 1) Then
xStep = 1 / scaleFactor
Else
xStep = 1
End If
' 繪制波形圖
If (Module1.format.nChannels = 2) Then
maxAmplitude = Me.Height / 4
leftYOffset = maxAmplitude
rightYOffset = maxAmplitude * 3
For x = 0 To Me.Width Step xStep
curSample = scaleFactor * x + Module1.drawFrom
If (Module1.format.wBitsPerSample = 16) Then
GetStereo16Sample curSample, leftVol, rightVol
Else
GetStereo8Sample curSample, leftVol, rightVol
End If
curRightY = CLng(rightVol * maxAmplitude)
curLeftY = CLng(leftVol * maxAmplitude)
Line (lastX, leftYOffset + lastLeftY)-(x, curLeftY + leftYOffset)
Line (lastX, rightYOffset + lastRightY)-(x, curRightY + rightYOffset)
lastLeftY = curLeftY
lastRightY = curRightY
lastX = x
Next
Else
maxAmplitude = Me.Height / 2
leftYOffset = maxAmplitude
For x = 0 To Me.Width Step xStep
curSample = scaleFactor * x + Module1.drawFrom
If (Module1.format.wBitsPerSample = 16) Then
GetMono16Sample curSample, leftVol
Else
GetMono8Sample curSample, leftVol
End If
curLeftY = CLng(leftVol * maxAmplitude)
Line (lastX, leftYOffset + lastLeftY)-(x, curLeftY + leftYOffset)
lastLeftY = curLeftY
lastX = x
Next
End If
End Sub
Private Sub Form_Paint()
DrawWaves
End Sub
Private Sub Form_Resize()
DrawWaves
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -