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

        dscheckboxd.BufferBytes = CaptureBufferSize

        InputFormat.FormatTag = WaveFormatTag.Pcm

        dscheckboxd.Format = InputFormat '''' Set the format during creatation

        applicationBuffer = New CaptureBuffer(dscheckboxd, Cap)

        NextCaptureOffset = 0

 

        InitNotifications()

    End Sub ''''CreateCaptureBuffer

 

    Sub InitNotifications()

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

        '''' Name: InitNotifications()

        '''' Desc: Inits the notifications on the capture buffer which are handled

        ''''       in the notify thread.

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

        If Nothing Is applicationBuffer Then

            Throw New ArgumentNullException

        End If

        '''' Create a thread to monitor the notify events

        If Nothing Is NotifyThread Then

            NotifyThread = New Thread(New ThreadStart(AddressOf WaitThread))

            NotifyThread.Start()

 

            '''' Create a notification event, for when the sound stops playing

            NotificationEvent = New AutoResetEvent(False)

        End If

 

        '''' Setup the notification positions

        Dim i As Integer

        For i = 0 To NumberRecordNotifications - 1

            PositionNotify(i).Offset = NotifySize * i + NotifySize - 1

            PositionNotify(i).EventNotifyHandle = NotificationEvent.Handle

        Next i

 

        applicationNotify = New Notify(applicationBuffer)

 

        '''' Tell DirectSound when to notify the app. The notification will come in the from

        '''' of signaled events that are handled in the notify thread.

        applicationNotify.SetNotificationPositions(PositionNotify, NumberRecordNotifications)

    End Sub ''''InitNotifications

    Private Sub WaitThread()

        While Created

            ''''Sit here and wait for a message to arrive

            NotificationEvent.WaitOne(Timeout.Infinite, True)

            RecordCapturedData()

        End While

    End Sub ''''WaitThread

    Sub RecordCapturedData()

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

        '''' Name: RecordCapturedData()

        '''' Desc: Copies data from the capture buffer to the output buffer

       

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

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