|
-
Jan 16th, 2002, 11:41 PM
#1
start and stop a sound record event by a string receive by the com port
Hai guy. Here is my situation. i got a record function, Normally u use the start a record function by a click of button let say " RECORD" button on ur form, but what i need now is the start of the recording to be triger by a text file that i receive from the external device via serial port. Let say:
txttext1.text = MScomm1.input
If txttext1.text = 'START RECORD" Then
call (Record Function)
can i do this?????.
where should i put this code ?????. In the Mscomm_commeven()????.
Can any one provide me some help here. If u don't understand my question here, please feel free to ask. hope i make this clear enough. Thanks And have A Nice day.
Here is my record function i got from VB forum
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" _
(ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long
Private Declare Function mciGetErrorString Lib "winmm.dll" _
Alias "mciGetErrorStringA" _
(ByVal dwError As Long, _
ByVal lpstrBuffer As String, _
ByVal uLength As Long) As Long
Dim RecdTime As Boolean
Private Function RecordSound(FileName As String) As Boolean
'sound aliased by recsound
cmdRecord.Enabled = False
Dim Result&
Dim errormsg%
Dim ReturnString As String * 1024
Dim ErrorString As String * 1024
Result& = mciSendString("open new Type waveaudio Alias recsound", ReturnString, Len(ReturnString), 0)
If Not Result& = 0 Then
errormsg% = mciGetErrorString(Result&, ErrorString, 1024)
MsgBox ErrorString, 0, "Error"
End If
Result& = mciSendString("set recsound time format ms bitspersample 16 channels 2 bytespersec 22500 samplespersec 44100", ReturnString, 1024, 0)
If Not Result& = 0 Then
errormsg% = mciGetErrorString(Result&, ErrorString, 1024)
MsgBox ErrorString, 0, "Error"
End If
Result& = mciSendString("record recsound", ReturnString, Len(ReturnString), 0)
If Not Result& = 0 Then
errormsg% = mciGetErrorString(Result&, ErrorString, 1024)
MsgBox ErrorString, 0, "Error"
End If
RecdTime = True
Do Until Not RecdTime
DoEvents
Loop
Result& = mciSendString("save recsound " & FileName, ReturnString, Len(ReturnString), 0)
If Not Result& = 0 Then
errormsg% = mciGetErrorString(Result&, ErrorString, 1024)
MsgBox ErrorString, 0, "Error"
End If
Result& = mciSendString("close recsound", ReturnString, 1024, 0)
If Not Result& = 0 Then
errormsg% = mciGetErrorString(Result&, ErrorString, 1024)
MsgBox ErrorString, 0, "Error"
End If
Unload Me
End Function
Hope this is not too long for u guys.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|