Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Public Class ReadWAVClass
<StructLayout(LayoutKind.Sequential)> Public Structure WAVEFORMATEX
<VBFixedString(4)> Dim RIFF As String
Dim FileLen As Int32
<VBFixedString(4)> Dim Wave As String
<VBFixedString(4)> Dim fmt As String
<VBFixedString(4)> Dim full As String
Dim Type As Int16
Dim Channels As Int16
Dim SamplesPerSecond As Int32
Dim lAvgBytesPerSec As Int32
Dim BlockAlign As Int16
Dim BitsPerSample As Int16
<VBFixedString(4)> Dim Data As String
Dim DataLen As Int32
Dim Mess As String
End Structure'公开结构
Private m_Reader As BinaryReader
Private m_Stream As FileStream
Private format As WAVEFORMATEX
Private filename As String
Public Sub New(ByVal m_filename As String)
filename = m_filename
End Sub
Public Function ReadWavHand() As WAVEFORMATEX
Try
m_Reader.Close()
m_Stream.Close()
Catch ex As Exception
End Try
Try
m_Stream = New FileStream(filename, FileMode.Open,
FileAccess.Read)
m_Reader = New BinaryReader(m_Stream)
Debug.WriteLine("打开文件")
Catch ex As Exception
format.Mess="打开文件失败"
Return format
End Try