Skip to main content

Build those noise cancelling headphones

So, here's another DIY

Let me start by putting the cart before the horse. I shall start with the credits. This project was done while I was working on my Electronics Design Lab, along with my friends, Srujan M and Indrasen Bhattacharya. The work would not have been possible without the generous help received from the staff at Wadhwani Electronics Laboratory, who ensured that the only thing we did right was to leave the lab on time. This project would also not have been possible without the guidance of our dear and learned professors. It would probably have just about become additional dead weight on the head.

Enough with the credits, now, I need to dive right into noise cancellation and how it works.

The essence of sound is a pressure wave. The pressure wave, when incident on the eardrum sets into motion the complex mechanisms inside the ear, and after a long path, rather like the Cog advertisement, ends up making some nerves vibrate. The nerves send electrical signals to the brain, and this is interpreted as sound.

Noise is just any kind of sound. Imagine that I am listening to a popular song by the duo, Simon and Garfunkel. I have a pressure wave originating due to the music, and another which is coming from the surroundings as noise. Now, the secret to cancelling noise is to generate an anti-noise pressure wave, a wave which is exactly inverted with respect to the noise wave. The inverted wave, when added to the original wave destructively interferes, which is a fancy way of saying that it cancels out the original wave. Now, there is no noise, and all that can be heard is the sound of silence.

Confused? Well, I would have put up graphics, but I do not feel like making and then putting up an image. Unfortunately, most of the websites do not have copyright information put up on them, and I doubt how many are actually aware of how useful a creative commons badge can be. Oh, and by the way, this blog is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

But I drift. The topic of this post is how to build noise cancelling headphones. Legal issues are significant only for organisations that have larger legal teams than engineering teams, and I certainly don't belong to any of those organisations.

All in all, the entire process of making those noise cancelling headphones is about finding the right electronics to generate that pesky anti-noise signal. In this post, I shall go through the various methods, and give my opinions on each of them.

The simplest method is to connect a microphone just outside each of the earcups of the headphone. The microphones would capture the external sound, and not so much of the music playing inside the headphones. This would give a reasonably good estimation of the noise.

There are issues with this approach. The microphone placed outside the headphone hears a much different sound than what passes inside the ear. The sound reaching the ear is modified because of the structure of the headphones, and the materials that make it up. Moreover, this method requires a precise tuning of the gain of the feed-forward path. Further, in experiments, it has been shown to be ineffective, and can allow for noise cancellation up to only around 10dB.

Another approach is to use a microphone located externally to detect the ambient noise, and to use microphones inside the ear cups to detect the amount of noise filtering through the headphones. An adaptive algorithm like the Least Mean Squares (LMS) can be used to generate the anti-noise signal.

Any method that we did not follow must have it's issues. So too does this method. The algorithm involves using a digital signal processing computer, which is an expensive piece of hardware. Moreover, the LMS algorithm has a certain training time associated, which means that it is able to work only for cyclic noise or noise signals that are periodic. This is generally not considered a major issue mainly because most of the noise sources involve rotating machinery, like engines, and motors; and noise from such machinery is periodic.

The last approach (and the one that we followed) is to use an analogue feedback controller. Another approach may be to use a digital feedback controller, but cost considerations keep it out of the equation. However, the principle of feedback remains the same.

A feedback controller has a number of benefits. Most headphones have a coloured frequency response, i.e. the frequency response is not flat, but the intensity of the output changes with the frequency. This is an undesired characteristic, and must be avoided. Typically, headphones have a very poor response at the lower end of the spectrum. A feedback controller effectively reduces the colouration in the output of the headphones making them much better. Also, analogue systems are fast, cheap and less prone to failure than digital systems.

So, let's dive into how to make those headphones!

One of the first things required in the design of a controller is a model. We need to know how does the system behave.

The simplest idea is to model the system as a delay. Since the microphone and the speaker are separated by a distance, we can consider the distance to lead to a constant delay. So, the phase response of the system should be linear with frequency.

In practice, this is not so. The ear cavity along with the ear cup on the headphone forms a cavity, and resonances can occur in the cavity. So, the frequency response is rather weird, and like this:

Magnitude response of the plant under two different conditions
Phase response of the plant under two different conditions

As can be seen from the images, the magnitude and phase response of the plant change under different conditions. The different conditions may be two different users, or the same user, with the headphones worn differently. This is the major roadblock in designing a feedback controller. The controller must be sufficiently robust to be stable under these variations of the plant.

The other tool that we had is the Nyquist criterion for stability, i.e., we could not allow the gain of the compensated plant to be more than 0dB when the phase went to 180 degrees.

I prefer to not go into the details of the compensator design, mainly because the design is very specific to the headphones that we were using. If you use another model, then the same compensator would not work.

Nevertheless, I can just mention the main components of the compensator, and the reasons for incorporating them. We used a damped second order lag, two high frequency lag networks, and a low frequency lead network.

The high frequency lag networks are needed to reduce the gain at high frequencies (>1kHz). However, they completely mess up the phase at low frequency consequentially making the system unstable. The second order damped lag network is used to boost the phase over a small range of frequencies that would remove the instability of the system.

While testing, it was observed that the headphones were being overdriven at low frequencies, i.e., a large input was being fed to the headphones, but they were not able to reproduce those frequencies faithfully. To correct this, we added a low frequency lead network, to reduce the compensation at low frequencies.

Magnitude response of the compensation network
Phase response of the compensation network

The open loop characteristic of the compensated plant is shown below:

Magnitude response of the compensated plant
Phase response of the compensated plant

The noise cancellation was measured using an external speaker playing a tone generated by a laptop computer. The following figure shows the noise cancellation characteristics.

Level of noise cancellation

While I am on the topic, let me inform you of some salient features of the design. We had aimed for a cancellation of over 20dB at 100Hz, but we obtained cancellation of only 17dB at 100Hz. However, this is sufficient to silence all the noisy air conditioning units in the lab to give a quiet environment. The circuit runs off two dry cells, and can be made extremely small with proper SMD components. Our prototype was made on a large general purpose board.

I leave you with the schematics of our circuit and a picture of the entire setup. I do know that this post may not have been informative enough for anyone to just make a pair of noise cancelling headphones immediately, the design of the controller is such that it cannot be generalized to other headphones. Maybe, when I get some time later, I could put in a DIY on making analogue feed-forward noise cancelling headphones/earbuds with around 10dB of noise cancellation.

Complete schematic of the circuit
Final setup!

Comments

Popular posts from this blog

On Harry Potter and why I dislike the series

There could not be a better time for this post. There could not have been a worse time for this post. Now that the penultimate movie of the series is out, and my facebook wall filled with people who loved the movie. But this is something I really wanted to say, and I shall say it anyway. Harry Potter is pathetic literature. Now, you must be wondering why I say that. There are many reasons. Firstly, the storyline itself is flawed. When a writer sits down to write anything, he/she must set up some essential rules about what is happening. These rules must remain constant irrespective of how many times he/she changes his/her mind. This is so that the readers are allowed to have some sensibility in what they are reading. In the fourth book, Rowling goes ahead and kills Cedric. Then, at the end of the book, the horseless carriages are there again. Nothing special. We all knew that they are horseless. But then comes the fifth book, and BAM, the horses are actually winged beasts that only thos

ERROR_SUCCESS

ERROR_SUCCESS. This macro would be familiar to all those who have done some programming in WIN32. It is the output of the GetLastError() function to check the thread's last error state when no error has occurred. Weird, isn't it? I mean, if it is a success, then why is it marked as an error in the macro? This is one example of a badly made API. APIs are considered bad when programming in them becomes non-intuitive. Software is said to be bad (or said to suck) when it seems counter-intuitive to the user. There is one very simple example of this. Start notepad. Type in any text. Click on close. The message that you see is: This makes no sense to me as a user. Of course, the programmer follows the approach that he creates a temporary file called Untitled , and in that file he allows the user to make all his changes. But how am I, as a user to understand that? A similar disconnect occurs even between two different programmers. That is why it takes a whole lot of effort to make

Elements of a Story: The Whispers

I'm compelled to begin each post with a meta. That way, my blog posts seem less like essays or dissertations, and more like diary entries, or web logs. So here goes... I started this blog a little over a year ago. The main purpose of this blog was to experiment with styles of writing, and find an effective outlet for all the subjects I wish to rant about; saving my classmates the agony of having to listen to them. As I wrote this blog, I've experimented with so many styles, and have received comments claiming that my work is a shameless copy greatly inspired by so-and-so author/work. Fact is that I simply chanced upon that style. I read, so obviously, my work shall reflect the styles of those I admire, but I've worked out so many styles without even knowing that they exist, only to be informed of them later. Recently, I've been struck with the seeming absence of whispers as an element of a story. The more I've thought of the subject, the more I've been convince