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!

Popular posts from this blog

Progressive Snapshot: Is it worth it?

I turned 25 last year, which in the highly mathematical and calculating eyes of the US insurance industry meant that I had suddenly matured into a much more responsible driver than I was at 24 years and 364 days of age. As a result, I expected my insurance rates to go down. Imagine my surprise when my insurance renewal notice from GEICO actually quoted a $50 increase in my insurance rates. To me, this was a clear signal that it was time to switch companies.Typically, I score really high on brand loyalty. I tend to stick with a brand for as long as possible, unless they really mess up. This qualified as a major mess up. As a result, I started shopping for insurance quotes.Two companies that quoted me significantly lower rates (30%–40% lower) were Progressive and Allstate. Both had an optional programme that could give me further discounts based on my consenting to the companies tracking my driving habits. Now, I am a careful driver – I hardly ever accelerate hard. I hate using the brak…

Cornell Graduate Students United: At What Cost?

On Monday and Tuesday, we graduate students at Cornell will be voting on whether or not we want to unionise. Actually, scratch that, only graduate students who hold a TA, RA, or GRA appointment can unionise.This is a shitty arrangement, and I will be voting against it.For those of you who are not aware of how graduate school works at Cornell, you could be on one of many appointments.FellowshipA graduate student on a fellowship gets a stipend and tuition paid without associated teaching or research opportunities. Graduate students on a fellowship typically work towards their own theses, but will be excluded from the unionGraduate research assistantshipsA GRA gives a graduate student stipend and tuition without teaching responsibilities. However, this money comes out of a specific project grant, and the students typically work on their own theses. Students on GRAs magically qualify to join the union, whereas there is virtually no difference between a GRA and a fellowship for the most pa…

De-addicting

I’m on a process to break away from the distractions of social media, primarily Facebook, and spend the time to pursue other interests. This is an interesting experiment, and it has required significant dedication and effort on my part. At the end, though, I’m not certain if I’ll be successful.I realised that I had a problem when Facebook became the most visited sites in my browser. I should have been working, not scrolling through Facebook like a, well, you know what Jerry Seinfeld has to say. I further noticed that I would tend to log on to Facebook every time I was stuck at work, so that my capacity to tackle problems was reduced to only those that involved cracking a walnut shell. Anything more complex, and I would procrastinate and end up on Facebook.What I needed was a swift kick in the arse to get off Facebook and into the real world. It came through the means of my latest project which required all my attention. At this time, I logged out of Facebook from my work computer and …