Getting extra info from wave file
Finding out if wave file is mono or stereo, 8bit or 16bit, and how many KHz's.
Rate Getting extra info from wave file
(5(5 Vote))
In order for this to work you would have to have these on your form:
- Text Boxes named:
txtFile
Freq
Bit
Channel
- Button named:
Load
Note: I didn't want to use Common dialog or any other control for
simplicity, you just type the location of your wave file in a textbox.
Code:
Dim Buf As String * 58
Dim beg As Byte
Private Sub Load_Click()
Open txtFile.Text For Binary As #1
Get #1, 1, Buf
Close #1
beg = InStr(1, Buf, "WAVE")
If beg = 0 Then
MsgBox "Sorry not a wave file...", vbCritical, "Error..."
Else
'The 23rd byte in a wave file determines if file is Mono(1 Ascii) or Stereo(2 Ascii)
If Mid(Buf, 23, 1) = Chr$(1) Then
Channel = "Mono"
Else
Channel = "Stereo"
End If
'The 25th byte in a wave file determines how many KHz the file has
'44KHz(Ascii 68{44 hexadecimal})
'22KHz(Ascii 34{22 hexadecimal})
'11KHz(Ascii 17{11 hexadecimal})
Freq = Sredi(Mid(Buf, 25, 1)) / 17 * 11 & " KHz"
'The 35 byte in a wave file determines if the file is 16bit(16 ascii) or 8bit(8 ascii)
Bit = Sredi(Mid(Buf, 35, 1)) & " Bit"
End If
End Sub
Private Function Sredi(ByVal accStr As String) As String
Sredi = Trim(Str(Asc(accStr)))
End Function
Getting extra info from wave file Comments
No comments yet — be the first to post one!
Post a Comment