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

How can I capture voice data from microphone with SlimDX?

This topic is 3075 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


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
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:

There's a good practical example here:

You might also consider letting someone else do the dirty work:

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!