打印本文 打印本文 关闭窗口 关闭窗口
VB.NET实现DirectSound9 (7) 录音
作者:武汉SEO闵涛  文章来源:敏韬网  点击数10923  更新时间:2009/4/23 19:00:44  文章录入:mintao  责任编辑:mintao
        '''' Figure out how many bytes there will be per sample.

        If 8 = InputFormat.BitsPerSample And 1 = InputFormat.Channels Then

            shBytesPerSample = 1

        ElseIf 8 = InputFormat.BitsPerSample And 2 = InputFormat.Channels Or (16 = InputFormat.BitsPerSample And 1 = InputFormat.Channels) Then

            shBytesPerSample = 2

        ElseIf 16 = InputFormat.BitsPerSample And 2 = InputFormat.Channels Then

            shBytesPerSample = 4

        End If

        '''' Fill in the riff info for the wave file.

        Writer.Write(ChunkRiff)

        Writer.Write(nLength)

        Writer.Write(ChunkType)

 

        '''' Fill in the format info for the wave file.

        Writer.Write(ChunkFmt)

        Writer.Write(nFormatChunkLength)

        Writer.Write(shPad)

        Writer.Write(InputFormat.Channels)

        Writer.Write(InputFormat.SamplesPerSecond)

        Writer.Write(InputFormat.AverageBytesPerSecond)

        Writer.Write(shBytesPerSample)

        Writer.Write(InputFormat.BitsPerSample)

 

        '''' Now fill in the data chunk.

        Writer.Write(ChunkData)

        Writer.Write(CInt(0)) '''' The sample length will be written in later.

    End Sub ''''CreateRIFF

    Sub CreateCaptureBuffer()

        ''''-----------------------------------------------------------------------------

        '''' Name: CreateCaptureBuffer()

        '''' Desc: Creates a capture buffer and sets the format

        ''''-----------------------------------------------------------------------------

        Dim dscheckboxd As New CaptureBufferDescription

 

        If Not Nothing Is applicationNotify Then

            applicationNotify.Dispose()

            applicationNotify = Nothing

        End If

        If Not Nothing Is applicationBuffer Then

            applicationBuffer.Dispose()

            applicationBuffer = Nothing

        End If

 

        If 0 = InputFormat.Channels Then

            Return

        End If

        '''' Set the notification size

        NotifySize = IIf(1024 > InputFormat.AverageBytesPerSecond / 8, 1024, InputFormat.AverageBytesPerSecond / 8)

        NotifySize -= NotifySize Mod InputFormat.BlockAlign

 

        '''' Set the buffer sizes

        CaptureBufferSize = NotifySize * NumberRecordNotifications

 

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口