打印本文 打印本文 关闭窗口 关闭窗口
VB.NET实现DirectSound9 (7) 录音
作者:武汉SEO闵涛  文章来源:敏韬网  点击数10925  更新时间:2009/4/23 19:00:44  文章录入:mintao  责任编辑:mintao
;   Return

            End If

            '''' Stop the buffer, and read any data that was not

            '''' caught by a notification

            applicationBuffer.Stop()

 

            RecordCapturedData()

 

            Writer.Seek(4, SeekOrigin.Begin) '''' Seek to the length descriptor of the RIFF file.

            Writer.Write(CInt(SampleCount + 36)) '''' Write the file length, minus first 8 bytes of RIFF description.

            Writer.Seek(40, SeekOrigin.Begin) '''' Seek to the data length descriptor of the RIFF file.

            Writer.Write(SampleCount) '''' Write the length of the sample data in bytes.

            Writer.Close() '''' Close the file now.

            Writer = Nothing '''' Set the writer to null.

            WaveFile = Nothing '''' Set the FileStream to null.

        End If

    End Sub ''''StartOrStopRecord

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        CreateRIFF()

        StartOrStopRecord(True)

 

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        StartOrStopRecord(False)

 

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        DevPlay.SetCooperativeLevel(Me, CooperativeLevel.Priority)

        BufPlay = New SecondaryBuffer(TextBox1.Text, DevPlay)

        BufPlay.Play(0, BufferPlayFlags.Default)

 

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        BufPlay.Stop()

        BufPlay.Dispose()

 

    End Sub

    Private Sub MainForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

        If Not Nothing Is NotificationEvent Then

            NotificationEvent.Set()

        End If

        If Not Nothing Is applicationBuffer Then

            If applicationBuffer.Capturing Then

                StartOrStopRecord(False)

            End If

        End If

        End

    End Sub ''''MainForm_Closing

 

End Class

 

=======================================
OK DirectSound最后的部分写完了.总体感觉微软的封装还是有道理的

既要体现出易用性,而且还要充分发挥硬件的能力.如果你觉得某

 << 上一页  [11] [12]  下一页

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