Dim yLec As Long, ydate As Date, ysg As Single
Dim yint As Integer, ybt As Byte
Dim LenData As Long, InData As Long
Dim Nbits As Integer, StMo As String
Me.Caption = "Waveform View - " & "(" & FName & ")"
Label1.Caption = "File: " & FName
Open FName For Binary Access Read As #1
Label2.Caption = "Size: " & LOF(1) & " Bytes"
Label3.Left = Label1.Left + Label1.Width + 500
Label3.Caption = "Last modified: " & FileDateTime(FName)
Label4.Caption = 0 'IniPlay of present Zoom
Label17.Caption = 0 '= selected Samples
For n = 1 To 100
X$ = Input(4, #1)
If n = 2 Then HOLDER$ = X$ ' Hold This for Saving a New Wav
If X$ = "fmt " Then Exit For 'Ignore everything else till this
Next n
'Get the Wave File Header Info
Get #1, , yLec ' 16
Get #1, , yint 'Compression Type (1=PCM)
Get #1, , yint 'is Channels, 1 if mono and 2 if stereo
If yint = 2 Then
Label9.Caption = "Stereo"
ElseIf yint = 1 Then
Label9.Caption = "Mono"
Else
Label9.Caption = "Error!"
GoTo Errhandler
End If
Get #1, , yLec 'is the Sampling frequency of the file
Label8.Caption = yLec
Get #1, , yLec 'is a multiple of the sample frequency
Get #1, , yint 'is the divisor of the number of bytes of
'data which gives the number of Samples in the .wav
yDiv = yint
Label12.Caption = yDiv
Get #1, , yint 'is the number of bits (8 or 16)
If yint = 8 Or yint = 16 Then
Label10.Caption = yint & " bits"
Else
Label10.Caption = "Error"
GoTo Errhandler
End If
GotTheData:
For n = 1 To 100
Y$ = Input(1, #1)
If Y$ = "d" Then Exit For ' Seek for start of Wav Data
Next n
Z$ = Input(3, #1)
If Z$ <> "ata" Then 'Wav Data Starts here
If n > 90 Then GoTo Errhandler
Temp = Seek(1)
Seek #1, Temp - 3
GoTo GotTheData
End If
Get #1, , yLec '= num of bytes of data, start reading data here.
Label13.Caption = yLec
LenData = yLec / yDiv
Label6(0).Caption = LenData
Label6(1).Caption = LenData
LenTemp = LenData / (Label8.Caption)
Extemp = (Int(LenTemp * 1000)) / 1000
If LenTemp - Extemp >= 0.0005 Then
Extemp = Extemp + 0.001
End If
Label14.Caption = "Length: " & Extemp & " seconds"
Label15(0).Caption = LenTemp
Label15(1).Caption = LenTemp
FimPlay = Int(LenTemp * 1000)
InData = Seek(1) 'Loc(1) + 1 is the number of the first sound data byte of the file.
Label11.Caption = InData
StMo = Label9.Caption
Nbits = Val(Label10.Caption)
MousePointer = vbHourglass 'Busy
Call GraphWave(InData, LenData, Nbits, StMo)
Close #1
Call DrawTickMarks
MousePointer = 0 ' Arrow
PlayControls = True
If Label9.Caption = "Stereo" Then
Frame2.Visible = True
Frame1.Height = 1815
Else
Frame2.Visible = False
Frame1.Height = 800
End If
MousePointer = 0
Exit Sub
Errhandler:
MsgBox "Error!!", vbOKOnly
Close #1