DirectX Sound

Started by
4 comments, last by Buckeye 14 years, 1 month ago
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!
Advertisement
I would start looking at XACT. I found it quite easy to write a class wrapper for it. I can only assume it allows for sound recording.
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.



"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;

}
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#.
Up
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 WORDFloat value = Float(RecordBuffer - 32768); // get value relative to midpoint

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement