InetSendSound Example for Visual Basic
' This example uses LEAD Capture control to capture audio
from the microphone and send it to
' a remote computer. For an example of starting and stopping recording,
refer to the LEAD Capture
' control documentation.
Private Sub StartRecord_Click()
' the capture doesn't have to be connected to use the
following functions
LEADCap1.CapAudioFormat(CAP_AUDIO_RECORD) = FILE_WAV_1M08
' open recording device
LEADCap1.CapOpenRecord 0, 2, LEADCap1.CapWaveAvgBytesPerSec(CAP_AUDIO_RECORD)
LEADCap1.CapStartRecord
End Sub
Private Sub LEADCap1_CapAudioData(ByVal pData As Variant, ByVal lBytesRecorded
As Long, ByVal iIndex As Integer)
' send sound to remote computer (items in SendList property)
' you should be connected to a remote computer first
by using the
' InetConnect method of the Internet COM
Dim RasterVar1 As LEADRasterVariant
Dim RasterVar2 As LEADRasterVariant
Dim pExtraData As Variant
Dim size As Integer, i As Integer
vExtraData = LEADCap1.CapWaveExtraData(CAP_AUDIO_RECORD)
If VarType(vExtraData) = vbArray Or vbByte Then
RasterVar1.Type = VALUE_ARRAY_BYTE
size = UBound(vExtraData) - LBound(vExtraData)
+ 1
Dim LArray(size) As Byte
LArray = vExtraData
RasterVar1.ItemCount = size
For i = 0 To i < size - 1 Step 1
RasterVar1.ShortItemValue(i)
= Array(i)
Next i
ElseIf VarType(vExtraData) = vbString Then
RasterVar1.Type = VALUE_STRING
RasterVar1.StringValue = vExtraData
Else
Exit Sub
End If
If VarType(pData) = vbArray Or vbByte Then
RasterVar2.Type = VALUE_ARRAY_BYTE
size = UBound(pData) - LBound(pData)
+ 1
Dim LArray(size) As Byte
LArray = pData
RasterVar2.ItemCount = size
For i = 0 To i < size - 1 Step 1
RasterVar2.ShortItemValue(i)
= Array(i)
Next i
ElseIf VarType(pData) = vbString Then
RasterVar2.Type = VALUE_STRING
RasterVar2.StringValue = pData
Else
Exit Sub
End If
LEADClient.InetSendSound
LEADCap1.CapWaveFormatTag(CAP_AUDIO_RECORD), LEADCap1.CapWaveChannels(CAP_AUDIO_RECORD),
_
LEADCap1.CapWaveSamplesPerSec(CAP_AUDIO_RECORD), LEADCap1.CapWaveAvgBytesPerSec(CAP_AUDIO_RECORD),
_
LEADCap1.CapWaveBlockAlign(CAP_AUDIO_RECORD), LEADCap1.CapWaveBitsPerSample(CAP_AUDIO_RECORD),
_
LEADCap1.CapWaveExtraSize(CAP_AUDIO_RECORD), RasterVar1,
RasterVar2, lBytesRecorded
DoEvents
End Sub