Sign in to follow this  

DirectX Sound

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

Hello everybody! I want to make a program that captures the sound from a microphone and views the level of sound in a percentage. In the same time when the person talks without recording, also it displays the echo of the sound. I wrote this question after a long search I am really tired of it!!! I read many book and I didn’t find any helpful thing! Your help will be GREATLY appreciated, and I’m in desperate need for you people!

Share this post


Link to post
Share on other sites
First, you'll have to select and implement a sound library from several which are available. You can search this site for discussions of sound libraries using the search box in the upper right-hand corner of this screen. "DirectX", "audio" and "sound" are good keywords to start out with.

If you want to continuously display microphone input, capture the microphone input (probably double- or triple-buffered), process the data for a buffer and display it.

The "percentage" will depend on the buffer format. Commonly, buffer data will be in BYTEs or WORDs, with "no sound" at a value = 1/2 of the max value of the format data-type. That is, for WORD data, "no sound" = 32767 ( half of 65535 ). Input values will vary from 0 to 65535, but the percentage will vary plus-or-minus around 32767.

Maybe that will help you get started.

NOTE: most microphone input will have a bias. That is, the actual "no sound" level will actually be offset a little one way or the other from the calculated "no sound" level.

Share this post


Link to post
Share on other sites


"If you want to continuously display microphone input, capture the microphone input (probably double- or triple-buffered), process the data for a buffer and display it.

The "percentage" will depend on the buffer format. Commonly, buffer data will be in BYTEs or WORDs, with "no sound" at a value = 1/2 of the max value of the format data-type. That is, for WORD data, "no sound" = 32767 ( half of 65535 ). Input values will vary from 0 to 65535, but the percentage will vary plus-or-minus around 32767.

Maybe that will help you get started.

NOTE: most microphone input will have a bias. That is, the actual "no sound" level will actually be offset a little one way or the other from the calculated "no sound" level."





How can I deal with the “byte of array”
Because when I put the loop indicated below on the ‘array of byte’ after capturing the sound, 255 sound appears when there is no sound and 0 as a maximum value.
for (int i = 0; i < RecordBuffer.Length; i++)
{
Float Value= RecordBuffer[i];

}
And wave format
WaveFormat Format = new WaveFormat(44100, 16, 2);
How can I calculate the sound level from 0 to 100 as a persentage
I use C#.

Share this post


Link to post
Share on other sites
I'm not a C# person, but it looks like you're creating a 16bit format, which is WORD, not byte.

Try something like:

// Record buffer should be array of WORD
Float value = Float(RecordBuffer[i] - 32768); // get value relative to midpoint

Share this post


Link to post
Share on other sites

This topic is 2833 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this