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...

On the Dvorak Simplified Keyboard

This is a post that I have been meaning to write from quite some time. Long hours spent typing code on my computer left my hands fatigued, and left me with a lot of pain in my wrists and fingers. That is when I decided to use the Dvorak. But I have got the same bad habit as Dr. Watson, to tell a story backwards. Of course, you must be wondering what the Dvorak is. The story of keyboards starts with the invention of the typewriter. Christopher Sholes, the inventor of the typewriter, tried with a two row piano style keyboard. But then, he got into many difficulties with the design. Then he finally settled for a four row design. This was similar to the QWERTY layout that most computers and typewriters today possess. The engineers at Remington, to whom Sholes had presented his design modified the layout a little further, and then the QWERTY was born. As typewriters became popular, people got used to the layout, and started practising touch typing, i.e. typing without looking at the keys...

The paradox of government

I'm fascinated by the concept of government, and the paradoxes it presents. On one hand, governments grant us a certain set of rights or liberties. On the other hand, they work to strip us of the very liberties they promise. Now, I don't mean that all governments strip people of liberties, but there are liberal regimes, and there are sufficiently restrictive and dictatorial ones. Both models may have results to show, it does not mean that people in a restrictive regime are unhappy (refer to Dan Dennett's TED talk , where he states that ideas or memes can be dangerous when taken from one part of the world, where they are widespread, and, using the virus analogy, where people are immune to the memes; to a part of the world where they are foreign, where people may not be immune to the memes and where people may get infected). History has shown that people were sufficiently satisfied with autocratic governments with a benevolent dictator, and that people in other parts of the ...