Low-level Audio Programming

Started by
3 comments, last by iMalc 19 years, 4 months ago
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
Advertisement
there is always PortAudio, though I'm sure it has it's delays too.
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.
if you have a sblive/audigy series card, look into the kx driver project.
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!
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement