GFWaveViewer/GFWaveViewerfrm.frm
VERSION 5.00
Begin VB.Form GFWaveViewerfrm
BorderStyle = 1 'Fest Einfach
Caption = "GFWaveViewer ‑ (c)2003 by Louis."
ClientHeight = 4890
ClientLeft = 45
ClientTop = 420
ClientWidth = 11610
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4890
ScaleWidth = 11610
StartUpPosition = 3 'Windows‑Standard
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 7
Left = 11220
TabIndex = 13
ToolTipText = "show/hide wave 8"
Top = 3900
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 6
Left = 11220
TabIndex = 12
ToolTipText = "show/hide wave 7"
Top = 3540
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 5
Left = 11220
TabIndex = 11
ToolTipText = "show/hide wave 6"
Top = 3180
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 4
Left = 11220
TabIndex = 10
ToolTipText = "show/hide wave 5"
Top = 2820
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 3
Left = 11220
TabIndex = 9
ToolTipText = "show/hide wave 4"
Top = 2460
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 2
Left = 11220
TabIndex = 8
ToolTipText = "show/hide wave 3"
Top = 2100
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 1
Left = 11220
TabIndex = 7
ToolTipText = "show/hide wave 2"
Top = 1740
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CheckBox WaveVisibleCheck
Height = 255
Index = 0
Left = 11220
TabIndex = 6
ToolTipText = "show/hide wave 1"
Top = 1380
Value = 1 'Aktiviert
Width = 255
End
Begin VB.CommandButton InfoCommand
Caption = "i"
Height = 315
Left = 11220
TabIndex = 5
Top = 900
Width = 315
End
Begin VB.CommandButton ZoomOutCommand
Caption = "<|"
Height = 315
Left = 11220
TabIndex = 1
ToolTipText = "Zoom out"
Top = 420
Width = 315
End
Begin VB.CommandButton ZoomInCommand
Caption = ">|"
Height = 315
Left = 11220
TabIndex = 0
ToolTipText = "Zoom in"
Top = 60
Width = 315
End
Begin VB.HScrollBar HScroll
Height = 255
Left = 60
TabIndex = 2
Top = 4560
Width = 11055
End
Begin VB.PictureBox OverviewPicture
AutoRedraw = ‑1 'True
BackColor = &H00FFFFFF&
Height = 735
Left = 60
ScaleHeight = 45
ScaleMode = 3 'Pixel
ScaleWidth = 733
TabIndex = 4
Top = 3780
Width = 11055
End
Begin VB.PictureBox MainPicture
AutoRedraw = ‑1 'True
BackColor = &H00FFFFFF&
Height = 3675
Left = 60
ScaleHeight = 241
ScaleMode = 3 'Pixel
ScaleWidth = 733
TabIndex = 3
Top = 60
Width = 11055
End
End
Attribute VB_Name = "GFWaveViewerfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2003, 2004 by Louis. Load multiple instances of this form to display multiple waves.
'Downloadable via Louis Coder's Code Section. www.louis‑coder.com.
'
'GFWV_ReceiveWaveDataArrayDbl
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
'other
Dim WaveDataArray() As Double
Dim WaveDataNumber(1 To 8) As Long
Dim WaveDataNumberMax As Long
Dim WaveDescription As String
Dim ZoomFactorX As Long
Dim ScrollPos As Long 'where we are in WaveDataArray() (equal to HScroll.Value)
Private Sub Form_Initialize()
'on error resume next
ZoomFactorX = 1 'preset
ScrollPos = 0 'reset
Call GFWV_Redraw 'update scroll bar
End Sub
'***INTERFACE SUBS***
'NOTE: after having passed WaveDataArray() data the target project should
'call GFWV_ReceiveWaveDescription(), GFWV_Redraw and finally show
'this form.
Public Sub GFWV_Reset()
'on error resume next
WaveDataNumber(1) = 0 'reset
WaveDataNumber(2) = 0 'reset
WaveDataNumber(3) = 0 'reset
WaveDataNumber(4) = 0 'reset
WaveDataNumber(5) = 0 'reset
WaveDataNumber(6) = 0 'reset
WaveDataNumber(7) = 0 'reset
WaveDataNumber(8) = 0 'reset
WaveDataNumberMax = 0 'reset
End Sub
Public Sub GFWV_ReceiveWaveDescription(ByVal WaveDescriptionPassed As String)
'on error resume next
WaveDescription = Left$(WaveDescriptionPassed, 128)
Call GFWV_RefreshCaption
End Sub
Public Sub GFWV_ReceiveWaveDataArrayInt(ByVal BankNumber As Integer, ByRef WaveDataNumberPassed As Long, ByRef WaveDataArrayPassed() As Integer)
'on error resume next
Dim Temp As Long
'verify
Select Case BankNumber
Case 1 To 8
Case Else
MsgBox "internal error in GFWV_ReceiveWaveDataArrayInt(): passed value invalid !", vbOKOnly + vbExclamation
Exit Sub 'error
End Select
'begin
If (WaveDataNumberPassed > 0) Then 'pass 0 to disable
WaveDataNumber(BankNumber) = WaveDataNumberPassed
If WaveDataNumberPassed > WaveDataNumberMax Then 'some memory is wasted, but who cares
ReDim Preserve WaveDataArray(1 To 8, 1 To WaveDataNumber(BankNumber)) As Double
End If
For Temp = 1 To WaveDataNumber(BankNumber)
WaveDataArray(BankNumber, Temp) = WaveDataArrayPassed(Temp)
Next Temp
WaveDataNumberMax = 0 'reset
For Temp = 1 To 8
If WaveDataNumber(Temp) > WaveDataNumberMax Then WaveDataNumberMax = WaveDataNumber(Temp)
Next Temp
Else
WaveDataNumber(BankNumber) = 0 'reset (not in use)
'ReDim WaveDataArray(1 To 8, 1 To 1) As Double 'reset (not in use)
End If
Exit Sub
End Sub
Public Sub GFWV_ReceiveWaveDataArrayDbl(ByVal BankNumber As Integer, ByRef WaveDataNumberPassed As Long, ByRef WaveDataArrayPassed() As Double)
'on error resume next
Dim Temp As Long
'verify
Select Case BankNumber
Case 1 To 8
Case Else
MsgBox "internal error in GFWV_ReceiveWaveDataArrayInt(): passed value invalid !", vbOKOnly + vbExclamation
Exit Sub 'error
End Select
'begin
If (WaveDataNumberPassed > 0) Then 'pass 0 to disable
WaveDataNumber(BankNumber) = WaveDataNumberPassed
If WaveDataNumberPassed > WaveDataNumberMax Then 'some memory is wasted, but who cares
ReDim Preserve WaveDataArray(1 To 8, 1 To WaveDataNumber(BankNumber)) As Double
End If
'Call CopyMemory(WaveDataArray(BankNumber, 1), WaveDataArrayPassed(1), WaveDataNumber * 8&) 'not sure if this works
For Temp = 1 To WaveDataNumber(BankNumber)
WaveDataArray(BankNumber, Temp) = WaveDataArrayPassed(Temp)
Next Temp
WaveDataNumberMax = 0 'reset
For Temp = 1 To 8
If WaveDataNumber(Temp) > WaveDataNumberMax Then WaveDataNumberMax = WaveDataNumber(Temp)
Next Temp
Else
WaveDataNumber(BankNumber) = 0 'reset (not in use)
'ReDim WaveDataArray(1 To 8, 1 To 1) As Double 'reset (not in use)
End If
Exit Sub
End Sub
Public Sub GFWV_Redraw()
'on error resume next
Dim DrawXPos As Long
Dim ForMin As Long
Dim ForMax As Long
Dim BankLoop As Integer
Dim Temp As Long
'preset
If WaveDataNumberMax > MainPicture.ScaleWidth Then 'verify (that usable)
With HScroll
.MIN = ‑32768
.MAX = 32767
.TabStop = False 'avoid blinking slider (looks ugly)
.LargeChange = MAX(Int((WaveDataNumberMax / 65536) * 1024), 128)
.SmallChange = MAX(Int((WaveDataNumberMax / 65536) * 1), 1)
.Value = ScrollPos
.Enabled = True
End With
Else
With HScroll
.TabStop = False 'avoid blinking slider (looks ugly)
.Enabled = False
End With
End If
'reset
MainPicture.Cls
OverviewPicture.Cls
'begin; draw main
MainPicture.Line (0, MainPicture.ScaleHeight / 2!)‑(MainPicture.ScaleWidth ‑ 1!, MainPicture.ScaleHeight / 2!), RGB(224, 224, 224)
For BankLoop = 1 To 8
If (WaveDataNumber(BankLoop)) Then
If WaveVisibleCheck(BankLoop ‑ 1).Value = 1 Then
Select Case BankLoop
Case 1
MainPicture.ForeColor = RGB(255, 0, 0) 'red
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 2
MainPicture.ForeColor = RGB(0, 255, 0) 'green
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 3
MainPicture.ForeColor = RGB(64, 64, 255) 'blue
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 4
MainPicture.ForeColor = RGB(220, 120, 220) 'grey
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 5
MainPicture.ForeColor = RGB(0, 0, 0) 'black
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 6
MainPicture.ForeColor = RGB(128, 128, 255) '***TEMP***
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 7
MainPicture.ForeColor = RGB(255, 255, 0) '***TEMP***
OverviewPicture.ForeColor = MainPicture.ForeColor
Case 8
MainPicture.ForeColor = RGB(0, 255, 255) '***TEMP***
OverviewPicture.ForeColor = MainPicture.ForeColor
End Select
DrawXPos = 1& 'preset
ForMin = MAX(1&, ((CLng(ScrollPos) + 32767&) / 65536 * WaveDataNumber(BankLoop))) + 1&
ForMax = MIN(WaveDataNumber(BankLoop), (((CLng(ScrollPos) + 32767&) / 65536 * WaveDataNumber(BankLoop)) + MainPicture.ScaleWidth / ZoomFactorX))
For Temp = ForMin To ForMax
Select Case DrawXPos 'verify
Case 1 To MainPicture.ScaleWidth
MainPicture.Line (DrawXPos ‑ ZoomFactorX, MainPicture.ScaleHeight / 2! ‑ WaveDataArray(BankLoop, Temp ‑ 1&) / 32767! * MainPicture.ScaleHeight / 2!)‑ _
(DrawXPos, MainPicture.ScaleHeight / 2! ‑ WaveDataArray(BankLoop, Temp) / 32767! * MainPicture.ScaleHeight / 2!)
End Select
DrawXPos = DrawXPos + ZoomFactorX
Next Temp
'draw overview
OverviewPicture.Line (ForMin / WaveDataNumber(BankLoop) * OverviewPicture.ScaleWidth, 0)‑(ForMax / WaveDataNumber(BankLoop) * OverviewPicture.ScaleWidth, OverviewPicture.ScaleHeight), RGB(255, 128, 128), BF
For Temp = 2 To OverviewPicture.ScaleWidth
OverviewPicture.Line (Temp ‑ 2&, OverviewPicture.ScaleHeight / 2! ‑ WaveDataArray(BankLoop, MAX(1&, MIN(WaveDataNumber(BankLoop), Int((Temp ‑ 1&) / OverviewPicture.ScaleWidth * WaveDataNumber(BankLoop))))) / 32767! * OverviewPicture.ScaleHeight / 2!)‑ _
(Temp ‑ 1&, OverviewPicture.ScaleHeight / 2! ‑ WaveDataArray(BankLoop, MAX(1&, MIN(WaveDataNumber(BankLoop), Int(Temp / OverviewPicture.ScaleWidth * WaveDataNumber(BankLoop))))) / 32767! * OverviewPicture.ScaleHeight / 2!)
Next Temp
End If
End If
Next BankLoop
'refresh
MainPicture.Refresh 'important
OverviewPicture.Refresh
End Sub
Public Sub GFWV_RefreshCaption()
'on error resume next
If Len(WaveDescription) Then
If (WaveDataNumberMax) Then 'verify (important)
Me.Caption = WaveDescription + " [1:" + CStr(ZoomFactorX) + "] ‑ Sample " + CStr(Int((CLng(ScrollPos) + 32767&) / 65536 * WaveDataNumberMax)) + " of " + CStr(WaveDataNumberMax) + " (" + CStr(Int((Int((CLng(ScrollPos) + 32767&) / 65536 * WaveDataNumberMax) / WaveDataNumberMax) * 100000) / 1000) + "%)"
Else
Me.Caption = WaveDescription
End If
Else
If (WaveDataNumberMax) Then 'verify (important)
Me.Caption = "GFWaveViewer" + " [1:" + CStr(ZoomFactorX) + "] ‑ Sample " + CStr(Int((CLng(ScrollPos) + 32767&) / 65536 * WaveDataNumberMax)) + " of " + CStr(WaveDataNumberMax) + " (" + CStr(Int((Int((CLng(ScrollPos) + 32767&) / 65536 * WaveDataNumberMax) / WaveDataNumberMax) * 100000) / 1000) + "%)"
Else
Me.Caption = "GFWaveViewer"
End If
End If
End Sub
'***END OF INTERFACE SUBS***
'***CONTROL EVENTS***
Private Sub WaveVisibleCheck_Click(Index As Integer)
'on error resume next
Call GFWV_Redraw
End Sub
Private Sub HScroll_Scroll()
'on error resume next
Call HScroll_Change
End Sub
Private Sub HScroll_Change()
'on error resume next
ScrollPos = HScroll.Value
Call GFWV_Redraw
Call GFWV_RefreshCaption
End Sub
Private Sub ZoomInCommand_Click()
'on error resume next
ZoomFactorX = ZoomFactorX + 1
If ZoomFactorX > 6 Then ZoomFactorX = 6
Call GFWV_Redraw
Call GFWV_RefreshCaption
End Sub
Private Sub ZoomOutCommand_Click()
'on error resume next
ZoomFactorX = ZoomFactorX ‑ 1
If ZoomFactorX < 1 Then ZoomFactorX = 1 'verify
Call GFWV_Redraw
Call GFWV_RefreshCaption
End Sub
Private Sub InfoCommand_Click()
'on error resume next
MsgBox "GFWaveViewer (c)2003, 2004 by Louis. www.louis‑coder.com.", vbOKOnly + vbInformation
End Sub
'***END OF CONTROL EVENTS***
'***OTHER***
Private Function MIN(ByVal Value1 As Long, ByVal Value2 As Long) As Long
'on error resume next
If Value1 < Value2 Then
MIN = Value1
Else
MIN = Value2
End If
End Function
Private Function MAX(ByVal Value1 As Long, ByVal Value2 As Long) As Long
'on error resume next
If Value1 > Value2 Then
MAX = Value1
Else
MAX = Value2
End If
End Function
[END OF FILE]