Re: Sound recording - HELP!



Cor,

I think that was my initial shortcoming. I have an app that does a
similar thing in vb6, and I wanted to upgrade it to VB2005 because I
really liked the 'run an application in a task tray' tools with vb
2005.

I've found the difference in structure declarations, api calls, and
parameter passing to be the root of my issues. As stated prior, I
found a post of a different way to declare the functions allowed me to
just list the devices on the machine, so I figured that it had to be my
issue of not being able to record.

So, in short, converting from one language, or version to another, got
me in this mess. heh... But, maybe this would be a great app to get my
feet wet with C#.

I'll let you know how it goes... Maybe even post the app, since I had
such a problem finding the info myself.

Jerry




Cor Ligthert [MVP] wrote:
Jer,

I am impressed by the answer from Herfried, I never get such nice samples
from him.

However in the SDK from DirectX are(were) in my idea samples that handles
what you want.

The pittfall is that the DirectX people are not able to write VB.Net
(probably to difficult for them) so the samples are only in C#.

Cor


"jer" <gerald.king@xxxxxxxxx> schreef in bericht
news:1166565254.425871.58350@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
My apologies... I'll remove your name from the subject.
So, you suggest the MCI recording instead of using waveopen/in?

Maybe if I explain what I'm doing, you might have a better suggestion
for me.

Where I work, I can't get a good signal for a sports station I like to
listing on the radio. So, I tought of an application that I could
write in VB.Net that would record from a radio plugged into my PC at
home (server), and record 30 minute chunks. This app would then
convert the wav to an MP3 and list it on my web server. I could
navigate to my web server (if I wanted to), and click to have it
emailed to my google account for downloading to my work PC.

The radio station does not offer streaming audio yet, so I can't listen
over the radio. Also, with my new MP3 player, I'd have enough storage
to sync it every night, and listen to the AM sports station the next
day.

So, that's my idea of the project. I will try using the code you've
supplied first. Do you foresee any issues with the large data size of
the recording? Would you still recommend this method, or maybe use
DirectX?

Thank you very much, and I greatly appreciate your input.

Jerry



Herfried K. Wagner [MVP] wrote:
"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

  • Re: Sound recording - HELP!
    ... you suggest the MCI recording instead of using waveopen/in? ... listing on the radio. ... Private Sub StartRecording() ... mciSimpleSendString("open new type waveaudio alias capture") ...
    (microsoft.public.dotnet.languages.vb)
  • Re: .NET Remoting Exception handling
    ... one way to handle this to put add page_error event and use the following code snippet to capture and display the error: ... In my app, I redirected to generic error page and in its page. ... Private Sub Page_LoadHandles MyBase.Load ...
    (microsoft.public.dotnet.framework.remoting)
  • RE: Strange behavior of redirected stdout. Streams Broken?
    ... I can capture stderr and stdout from a console app. ...
    (microsoft.public.dotnet.general)
  • 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: Captureing device error: "Busy
    ... Can you show me how to locate the app in MCE? ... >>> I have the same error message when I tired to capture analog video ... >>> the video and sound from my VCR. ...
    (microsoft.public.windowsxp.video)