Re: Herfried K. Wagner - HELP!



"jer" <gerald.king@xxxxxxxxx> schrieb:
I've noticed you've helped a lot of people that were trying to do sound
recording through VB.net. I'm searched all over the internet, and I'm
still having problems write sound to a wav file.

Please do not address posts to a specific person here. Each thread/question can/should by answered by all readers.

... So my quesiton... Do you have a similar post or sample application
for vb2005 that will write a wave file from the sound card?

That's not that complicated using good old MCI:

\\\
Private Declare Auto Function mciSendString Lib "winmm.dll" ( _
ByVal lpszCommand As String, _
ByVal lpszReturnString As String, _
ByVal cchReturn As Int32, _
ByVal hwndCallback As IntPtr _
) As MCIERROR

Public Enum MCIERROR
MCIERR_BASE = 256

MCIERR_INVALID_DEVICE_ID = MCIERR_BASE + 1
MCIERR_UNRECOGNIZED_KEYWORD = MCIERR_BASE + 3
MCIERR_UNRECOGNIZED_COMMAND = MCIERR_BASE + 5
MCIERR_HARDWARE = MCIERR_BASE + 6
MCIERR_INVALID_DEVICE_NAME = MCIERR_BASE + 7
MCIERR_OUT_OF_MEMORY = MCIERR_BASE + 8
MCIERR_DEVICE_OPEN = MCIERR_BASE + 9
MCIERR_CANNOT_LOAD_DRIVER = MCIERR_BASE + 10
MCIERR_MISSING_COMMAND_STRING = MCIERR_BASE + 11
MCIERR_PARAM_OVERFLOW = MCIERR_BASE + 12
MCIERR_MISSING_STRING_ARGUMENT = MCIERR_BASE + 13
MCIERR_BAD_INTEGER = MCIERR_BASE + 14
MCIERR_PARSER_INTERNAL = MCIERR_BASE + 15
MCIERR_DRIVER_INTERNAL = MCIERR_BASE + 16
MCIERR_MISSING_PARAMETER = MCIERR_BASE + 17
MCIERR_UNSUPPORTED_FUNCTION = MCIERR_BASE + 18
MCIERR_FILE_NOT_FOUND = MCIERR_BASE + 19
MCIERR_DEVICE_NOT_READY = MCIERR_BASE + 20
MCIERR_INTERNAL = MCIERR_BASE + 21
MCIERR_DRIVER = MCIERR_BASE + 22
MCIERR_CANNOT_USE_ALL = MCIERR_BASE + 23
MCIERR_MULTIPLE = MCIERR_BASE + 24
MCIERR_EXTENSION_NOT_FOUND = MCIERR_BASE + 25
MCIERR_OUTOFRANGE = MCIERR_BASE + 26
MCIERR_FLAGS_NOT_COMPATIBLE = MCIERR_BASE + 28
MCIERR_FILE_NOT_SAVED = MCIERR_BASE + 30
MCIERR_DEVICE_TYPE_REQUIRED = MCIERR_BASE + 31
MCIERR_DEVICE_LOCKED = MCIERR_BASE + 32
MCIERR_DUPLICATE_ALIAS = MCIERR_BASE + 33
MCIERR_BAD_CONSTANT = MCIERR_BASE + 34
MCIERR_MUST_USE_SHAREABLE = MCIERR_BASE + 35
MCIERR_MISSING_DEVICE_NAME = MCIERR_BASE + 36
MCIERR_BAD_TIME_FORMAT = MCIERR_BASE + 37
MCIERR_NO_CLOSING_QUOTE = MCIERR_BASE + 38
MCIERR_DUPLICATE_FLAGS = MCIERR_BASE + 39
MCIERR_INVALID_FILE = MCIERR_BASE + 40
MCIERR_NULL_PARAMETER_BLOCK = MCIERR_BASE + 41
MCIERR_UNNAMED_RESOURCE = MCIERR_BASE + 42
MCIERR_NEW_REQUIRES_ALIAS = MCIERR_BASE + 43
MCIERR_NOTIFY_ON_AUTO_OPEN = MCIERR_BASE + 44
MCIERR_NO_ELEMENT_ALLOWED = MCIERR_BASE + 45
MCIERR_NONAPPLICABLE_FUNCTION = MCIERR_BASE + 46
MCIERR_ILLEGAL_FOR_AUTO_OPEN = MCIERR_BASE + 47
MCIERR_FILENAME_REQUIRED = MCIERR_BASE + 48
MCIERR_EXTRA_CHARACTERS = MCIERR_BASE + 49
MCIERR_DEVICE_NOT_INSTALLED = MCIERR_BASE + 50
MCIERR_GET_CD = MCIERR_BASE + 51
MCIERR_SET_CD = MCIERR_BASE + 52
MCIERR_SET_DRIVE = MCIERR_BASE + 53
MCIERR_DEVICE_LENGTH = MCIERR_BASE + 54
MCIERR_DEVICE_ORD_LENGTH = MCIERR_BASE + 55
MCIERR_NO_INTEGER = MCIERR_BASE + 56

MCIERR_WAVE_OUTPUTSINUSE = MCIERR_BASE + 64
MCIERR_WAVE_SETOUTPUTINUSE = MCIERR_BASE + 65
MCIERR_WAVE_INPUTSINUSE = MCIERR_BASE + 66
MCIERR_WAVE_SETINPUTINUSE = MCIERR_BASE + 67
MCIERR_WAVE_OUTPUTUNSPECIFIED = MCIERR_BASE + 68
MCIERR_WAVE_INPUTUNSPECIFIED = MCIERR_BASE + 69
MCIERR_WAVE_OUTPUTSUNSUITABLE = MCIERR_BASE + 70
MCIERR_WAVE_SETOUTPUTUNSUITABLE = MCIERR_BASE + 71
MCIERR_WAVE_INPUTSUNSUITABLE = MCIERR_BASE + 72
MCIERR_WAVE_SETINPUTUNSUITABLE = MCIERR_BASE + 73

MCIERR_SEQ_DIV_INCOMPATIBLE = MCIERR_BASE + 80
MCIERR_SEQ_PORT_INUSE = MCIERR_BASE + 81
MCIERR_SEQ_PORT_NONEXISTENT = MCIERR_BASE + 82
MCIERR_SEQ_PORT_MAPNODEVICE = MCIERR_BASE + 83
MCIERR_SEQ_PORT_MISCERROR = MCIERR_BASE + 84
MCIERR_SEQ_TIMER = MCIERR_BASE + 85
MCIERR_SEQ_PORTUNSPECIFIED = MCIERR_BASE + 86
MCIERR_SEQ_NOMIDIPRESENT = MCIERR_BASE + 87

MCIERR_NO_WINDOW = MCIERR_BASE + 90
MCIERR_CREATEWINDOW = MCIERR_BASE + 91
MCIERR_FILE_READ = MCIERR_BASE + 92
MCIERR_FILE_WRITE = MCIERR_BASE + 93

MCIERR_NO_IDENTITY = MCIERR_BASE + 94

' all custom device driver errors must be >= than this value
MCIERR_CUSTOM_DRIVER_BASE = MCIERR_BASE + 256
End Enum

Private Function mciSimpleSendString(ByVal Command As String) As MCIERROR
Return mciSendString(Command, Nothing, 0, IntPtr.Zero)
End Function

Private Sub StartRecording()
mciSimpleSendString("close all")
mciSimpleSendString("open new type waveaudio alias capture")

' Set capturing options here.
'mciSimpleSendString("set capture bitspersample 16")
'mciSimpleSendString("set capture samplespersec 44100")
'mciSimpleSendString("set capture channels 2")
mciSimpleSendString("record capture")
End Sub

Private Sub StopRecording()
mciSimpleSendString("save capture C:\sample.wav")
mciSimpleSendString("close capture")
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

.



Relevant Pages

  • Java/VB6 to VB.NET for IP WEBCAM capture
    ... included Imports GIFLib in my Form1. ... Private Sub Button1_Click(ByVal sender As System.Object, ... The getconfigand capture() return return -1 upon success. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to cut/append data from one field to another
    ... Doug Steele, Microsoft Access MVP ... Private Sub TransferComment_Click ... Doug Steele suggests using vbCrLf. ... there is a way to capture the name of the person logging in to ...
    (microsoft.public.access.forms)
  • Re: How to cut/append data from one field to another
    ... The code you provided before seems to already separate the comments ... Private Sub TransferComment_Click ... The procedure above allows for a double line feed so that the next entry ... there is a way to capture the name of the person logging in to the ...
    (microsoft.public.access.forms)
  • Re: How to cut/append data from one field to another
    ... When transferred over to the 'History' text box, ... Private Sub TransferComment_Click ... The procedure above allows for a double line feed so that the next entry ... there is a way to capture the name of the person logging in to the ...
    (microsoft.public.access.forms)
  • Re: Sound recording - HELP!
    ... maybe this would be a great app to get my ... listing on the radio. ... Private Sub StartRecording() ... mciSimpleSendString("open new type waveaudio alias capture") ...
    (microsoft.public.dotnet.languages.vb)