views:

589

answers:

4

How would I go about turning the microphone on and open some kind of a live stream to listen to whats happening on my PC in another location? It's going to be a baby-monitor project.

Any ideas on the way I should do this? I am only really after code to do the task. I can do the rest. I am learning Delphi so I should be okay.

I would also need to be able to stop the mic. At this stage I do not want to talk back, just listen in real time or as close as I can get.

A: 

A lot of integration I did with a windows environment through Delphi was via a COM / ActiveX object. Lookup the CoCreateInstance calls, and then try to locate an ActiveX control that will take care of the microphone for you.

Kieveli
hey thanks to everyone who made a comment, yes I will look into this as you suggested but I am really wanting to code it in delphi rather than replying on another application.I want enable the mic, listen to the sound in the room, how would this work to get rid of the sound file on my machine, would it record to my drive then auto delete itself every 5 mins, or save multiple files 10 mins long like a1390049382.wav a9383827737382.wav and so on, whats the best way to deal with this.
ActiveX components are windows system based. You code in Delphi to control them, and then do what you want with the output. If an ActiveX component provides a way to turn on the mic, and then record the music, then you're coding it all in Delphi. You just need to install the ActiveX control into your system.
Kieveli
What you're looking for is an ActiveX control that will feed you the live sound data instead of saving it to a file.
Kieveli
right, i see good thanks so much, now i want to write the code to start the mic on my pc upstairs, listent to that is going on, and recieve the sound through speakers, Icontrol on / off which would be start stop mic?whats the next step for me?, hey and thanks..
+1  A: 

I found the Wave Audio Package, which has a component for recording audio. It can record to a file or a stream, or it can call an event handler with blocks of data as they become available.

It includes an audio redirector, which will take audio from one place (like the recorder component, in your case) and send it somewhere else (such as the playback component). If you want to play the microphone's audio as you collect it, you'll probably want that. The package comes with a handful of demos.

The redirector looks like it can accept other playback objects in addition to the default, so if you want to play the sound on another computer, then you might try writing a descendant class that sends the data over the network instead of sending it to a local speaker.

Rob Kennedy
thanks rob, I will look into this when I get back home today, I wish I could just code today and really get into this.So are you suggesting it records the file and sends me the file after every 5mins as a .wav?I really need to listen live mate with it being a baby monitor program, I have a few ideas to check from the posts posted here I just dont understand how to recieve.do i recieve the sound live my making a connection the remote pc but what about the sound files? do they come to me as logs? if so would they slow the pc down if i record for say 3 or 4 hours at a time~
If you want "live", you need to record in small chunk, then send that data to receiving computer, buffer some and playback that buffer.
Harriv
No, it doesn't record to a file that it gives you every 5 minutes. It *can* record to a file, and that's the easiest way to use it, but that's clearly not what you want. Like I said, it can trigger an event handler, and that will provide you with blocks of data continuously. I also mentioned another alternative, which is to write your own playback class that fits the interface of the ones provided, but instead of sending data to the speaker, sends it over the network. No files need be involved at all. Send what *would be* the *contents* of files.
Rob Kennedy
hi rob, the computer wont be on my network at the end result.It will be for my baby monitor but not for the final program.how should I do this? your first suggestion> or second?
How can anyone possibly make a recommendation about what you should do for your final program when you've never even hinted at the existence of anything but the baby monitor until just now?
Rob Kennedy
+2  A: 

Audiolab has all the needed (and more) functionality, and it's free for non-commercial use. It also supports both Win32 and .NET.

If you want to go low level, you need to explore one of the API's supporting recording, like Wave API (example in C++)

Harriv
Wow, this looks fantastic! Nice suggestion!
Argalatyr
had a loom today and it seems to be pretty dam good, i will have a play about the software tonight and into the morning and see if it would solve my problems, thanks
+5  A: 

Wow, everyone keeps on recommending external packages for this. It's built into Windows - the waveInOpen/waveInPrepareHeader/waveInBufferRead APIs should work on all versions of Windows.

You can also use DirectSoundCapture if you need finer control.

Larry Osterman
do u have any more info on this Larry, where should I start to look to record sound from mic and listen live through IP
Ronnie, you should *start* by reading the documentation for the functions Larry mentioned. They're all at MSDN. The next step is to try using them. If you have trouble, then ask new questions about the specific parts you're having trouble with.
Rob Kennedy