Public mLength As Integer
Public mChannels As Short
Public mSampleRate As Integer
Public mDataLength As Integer
Public mBitsPerSample As Short
Public Sub CreateWaveHeade r(ByRef sPath As String)
Dim fileNumber As Integer
Try
fileNumber = FreeFile()
FileOpen(fileNu mber, sPath, OpenMode.Binary , OpenAccess.Writ e)
'Write the RIFF bit of the header first.
FilePut(fileNum ber, "RIFF", 1)
FilePut(fileNum ber, mLength, 5)
'Then do the wave header.
FilePut(fileNum ber, "WAVEfmt ", 9)
FilePut(fileNum ber, CInt(16), 17)
FilePut(fileNum ber, CShort(1), 21)
FilePut(fileNum ber, mChannels, 23)
FilePut(fileNum ber, mSampleRate, 25)
FilePut(fileNum ber, CInt(mSampleRat e * ((mBitsPerSampl e *
mChannels) / 8)), 29)
FilePut(fileNum ber, CShort((mBitsPe rSample * mChannels) / 8),
33)
FilePut(fileNum ber, mBitsPerSample, 35)
FilePut(fileNum ber, "data", 37)
FilePut(fileNum ber, mDataLength, 41)
Catch ex As Exception
Throw ex
Finally
FileClose(fileN umber)
End Try
End Sub
Public Sub CreateWaveHeade rEx(ByRef sPath As String)
Try
Using bw As New BinaryWriter(Fi le.Open(sPath,
FileMode.OpenOr Create, FileAccess.Writ e))
'Write the RIFF bit of the header first.
bw.Write("RIFF" )
bw.Write(mLengt h)
'Then the wave header.
bw.Write("WAVEf mt ")
bw.Write(CInt(1 6))
bw.Write(CShort (1))
bw.Write(mChann els)
bw.Write(mSampl eRate)
bw.Write(CInt(m SampleRate * ((mBitsPerSampl e * mChannels) /
8)))
bw.Write(CShort ((mBitsPerSampl e * mChannels) / 8))
bw.Write(mBitsP erSample)
bw.Write("data" )
bw.Write(mDataL ength)
bw.Flush()
End Using
Catch ex As Exception
Throw ex
End Try
End Sub
Public mChannels As Short
Public mSampleRate As Integer
Public mDataLength As Integer
Public mBitsPerSample As Short
Public Sub CreateWaveHeade r(ByRef sPath As String)
Dim fileNumber As Integer
Try
fileNumber = FreeFile()
FileOpen(fileNu mber, sPath, OpenMode.Binary , OpenAccess.Writ e)
'Write the RIFF bit of the header first.
FilePut(fileNum ber, "RIFF", 1)
FilePut(fileNum ber, mLength, 5)
'Then do the wave header.
FilePut(fileNum ber, "WAVEfmt ", 9)
FilePut(fileNum ber, CInt(16), 17)
FilePut(fileNum ber, CShort(1), 21)
FilePut(fileNum ber, mChannels, 23)
FilePut(fileNum ber, mSampleRate, 25)
FilePut(fileNum ber, CInt(mSampleRat e * ((mBitsPerSampl e *
mChannels) / 8)), 29)
FilePut(fileNum ber, CShort((mBitsPe rSample * mChannels) / 8),
33)
FilePut(fileNum ber, mBitsPerSample, 35)
FilePut(fileNum ber, "data", 37)
FilePut(fileNum ber, mDataLength, 41)
Catch ex As Exception
Throw ex
Finally
FileClose(fileN umber)
End Try
End Sub
Public Sub CreateWaveHeade rEx(ByRef sPath As String)
Try
Using bw As New BinaryWriter(Fi le.Open(sPath,
FileMode.OpenOr Create, FileAccess.Writ e))
'Write the RIFF bit of the header first.
bw.Write("RIFF" )
bw.Write(mLengt h)
'Then the wave header.
bw.Write("WAVEf mt ")
bw.Write(CInt(1 6))
bw.Write(CShort (1))
bw.Write(mChann els)
bw.Write(mSampl eRate)
bw.Write(CInt(m SampleRate * ((mBitsPerSampl e * mChannels) /
8)))
bw.Write(CShort ((mBitsPerSampl e * mChannels) / 8))
bw.Write(mBitsP erSample)
bw.Write("data" )
bw.Write(mDataL ength)
bw.Flush()
End Using
Catch ex As Exception
Throw ex
End Try
End Sub
Comment