Sign in to follow this  

Creating a sound level meter using directX

This topic is 3742 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 have written a program in Java that uses Quicktime for Java. It is a simple program that records sounds and is able to identify whether a sound is coming into the microphone or not, and the relative volume of the sound compared to a pre-defined level. In Quicktime, I used the method getSoundEqualizerBand() to get back data that tells you the loudness or softness of certain frequencies (It’s the information usually displayed in level meters). The problem is, I am trying to make a non java/ non quicktime version of the program using DirectX. I figured out how to use filters to play a sound file using DirectShow, and am HOPING that I could just find the right interface to get an equivalent method to the quicktime method getSoundEqualizerBand---but it seems like that is wishful thinking. Does anyone know if there are avail methods to get frequency bands in DirectShow or DirectSound? Also, does anyone have any suggestions (directX or not) to what I should look at to create a non-java/non quicktime version of the program? The main goal of the program is just to be able to detect if sound is coming in, and the volume of the sound relative to a pre defined level. Thanks for taking the time to read my post.

Share this post


Link to post
Share on other sites
I'm afraid DirectSound doesn't offer any interfaces for frequency analysis. If you need a frequency spectrum, you'll have to introduce a Fourier transform yourself. More bad news: while there are plenty of FFT libraries out there, I've not found any that are particularly easy to use, and none that are written in an object-oriented way. If you find one, please let me know [smile].

I have absolutely no experience with DirectShow, but form what I've Googled, it doesn't offer any such interface either. However, if I correctly understand the role of DirectShow, you may be able to find a third-party filter that will do the work for you.

Admiral

Share this post


Link to post
Share on other sites
If you do decide to do the transforms manually look at FFTW (The fastest fourier transform in the west). It's kept very up do date and while not object oriented is pretty easy to use and doesn't take more than a few function calls to get a fourier transform. IIRC the website has some simple examples that really clarify how the library is used. It's also fast enough for some realtime audio applications - which is a definite plus.

Share this post


Link to post
Share on other sites
Theres some interesting features worthy of note when using a FFT, its a matter of domain resolution; you may need to find a compromise along the way.

The more samples you feed into an fft filter, loosely speaking the better results you'll get, but at a lose of performance. But with more samples you'll get better low frequency resolution. Decreasing the number of samples inputted into a fft filter will come at a cost of better high frequency resolution, but you'll lose the detail on low frequencies. Its a mixed bag and requires balancing.

i believe the most interesting aspect of the FFTW implementation is that its not just a single implementation, it is many, tailored for different chipsets to get the most performance possible. I even believe there is a GPU implementation for this, taking advantages of a parallel implementation of the algorithm.

Its really important not to get too bogged down in this detail, otherwise you'll never get the thing you're trying to write implemented!

Share this post


Link to post
Share on other sites

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