I want to record a wave file by using "mciSendStringA". The output audio file should support telephony and can be used to play greeting message on PSTN line Telephone. Please help how to set required audio format parameters to wave audio device. The following code produces an error in the msgbox like (302 : Can not carry out the commands in the order specified. Correct the command sequence, and then try again). Therefore programme takes default & noncompliant format parameters.
cmnd = "open " & Chr(34) & App.Path & "\" & MicFile & ".wav" & Chr(34) & " type waveaudio alias " & MicFile
errorCode = mciSendStringA(cmnd, returnStr, 255, 0)
'errorCode = mciSendStringA("Set " & MicFile & " time format milliseconds", returnStr, 255, 0)
'errorCode = mciSendStringA("set " & MicFile & " bitspersample 8 ", returnStr, 255, 0)
'errorCode = mciSendStringA("set " & MicFile & " samplespersec 8000 ", returnStr, 255, 0)
'errorCode = mciSendStringA("set " & MicFile & " channels 1 ", returnStr, 255, 0)
errorCode = mciSendStringA("set " & MicFile & " time format ms bitspersample 8 channels 1 samplespersec 8000", returnStr, 255, 0)
returnCode = mciGetErrorStringA(errorCode, errorStr, 255)
MsgBox errorCode & " : " & errorStr, vbOKOnly
errorCode = mciSendStringA("record " & MicFile, returnStr, 255, 0)
Format produced by above code:
Bit Rate = 176kbps
Audio samples size = 8 bit
Channels = 1 (mono)
Audio sample rate = 22 khz
Audio format = PCM
Audio format required to be set:
Bit Rate = 64kbps
Audio samples size = 8 bit
Channels = 1 (mono)
Audio sample rate = 8 khz
Audio format = CCITT u-Law