Sign in to follow this  
eternovsky

Low-level Audio Programming

Recommended Posts

I have a bit of a project I want to undertake. It's essence lies in taking a wave-form input from the microphone, taking the wave's inverse, mixing it with any sound being outputted via the sound card, and then outputting the mixed sound (preferably to a set of non-leaky earphones). What this should theoretically create is a background-noise cancelling effect. What I'm wondering is what should I use for programming the code. After looking at some libraries like OpenAL and SDL, I'm not too sure they will be able to achieve the effect I need. Which brings forth the question of something very low-level with direct access to the audio card. I've been looking around, but haven't really been able to find anything to suit my needs. Solutions for both Windows or Linux are OK. Can anyone please give me suggestions as to how to best approach this problem from a what-tool-to-use perspective? Thanks in advance, -Evgeny Ternovsky Marc Garneau Collegiate Institute

Share this post


Link to post
Share on other sites
As far as I know, ASIO drivers offer the lowest latency on most operating systems. The catch is you have to have a card that has ASIO drivers in the first place. If you have such a card, you can get the sdk here. If your card doesn't have ASIO drivers, native OpenAL drivers are probably slightly faster than DSound, but again, not many cards have those either.

Audigy, nForce2, and most other higher-end cards do have ASIO drivers however. Alternatively, PortAudio that lonesock gave you a link for has an ASIO wrapper (as well as a DSound and WMM) if you want to go that route.

Share this post


Link to post
Share on other sites
Just off the top of my head...

Your simple wave-inversion idea will not work. That type of cancalling needs to be extremely low-latency. I doubt any PC could pull it off. If you're the slightest bit behind the sampling then you might still cancel out some of the low frequency noise, but you'll end up amplifying some of the higher frequency noise. In fact you'll probably have bands of louder, and softer pitch throughout the frequency range.

Ideally, I think you probablly need to get an exact measure of this delay, and then do a fft on the wave and reconstruct a signal with the same frequency components where each frequency is phase shifted by the correct amount, according to the fixed delay. This is in itself a 'chicken and egg' scenario as the resulting code, causes the delay to be different from the initial measurement.

This is all assuming that you orient your speakers and mic in exactly the right direction.

Good luck anyway!

Share this post


Link to post
Share on other sites

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