Jump to content
  • Advertisement
Sign in to follow this  
YoungKee Shon

How can I capture voice data from microphone with SlimDX?

This topic is 2994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm a newbie in the SlimDX.

My planned application is a very simple voice chat with C#.

It will send voice data captured from the microphone and transmit it in UDP packets.
The remote party receives the data and outs it to (default) PC speaker.

There is no detail API descriptions in the document of SlimDX.
I could find some sample code written in the (old?) DirectX API, but the APIs are somewhat different from SlimDX.

I know well about socket programming.
Just What I want to know is,
- How can I capture voice data from the microphone and send it repeatedly in socket send while loop?
- How can I receive the data and put the received data repeatedly out to speaker?
written in C# code with SlimDX APIs.

The waveformat can I guess is below:

SlimDX.Multimedia.WaveFormat waveFormat = new SlimDX.Multimedia.WaveFormat();
waveFormat.FormatTag = WaveFormatTag.Pcm;
waveFormat.Channels = 1; // mono
waveFormat.BitsPerSample = 16; // 16-bit
waveFormat.SamplesPerSecond = 22050;
waveFormat.BlockAlignment = (Int16)(_waveFormat.Channels * waveFormat.BitsPerSample / 8);
waveFormat.AverageBytesPerSecond = _waveFormat.BlockAlignment * waveFormat.SamplesPerSecond;

Any sample code will be great appreciated!

YoungKee Shon

Share this post


Link to post
Share on other sites
Advertisement
Well, you're on the right track. Don't use DirectSoundCapture, because it's been deprecated and is not that well supported on Vista and later. Use the old Windows 3.x era multimedia API, which is what you're looking at. It's sad, but this is what things have come to.

The documentation is here:
http://msdn.microsoft.com/en-us/library/dd757715%28v=VS.85%29.aspx

There's a good practical example here:
http://www.codeproject.com/KB/audio-video/cswavrec.aspx

You might also consider letting someone else do the dirty work:
http://www.portaudio.com/

Good luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!