What The Tech

Hacking Headphones

Experiments with Active Noise Cancelling

Daniel Koch

Issue 31, February 2020

We hack a pair of Active Noise Cancelling headphones to explore how they work and whether or not they can be scaled.

Active Noise Cancelling (ANC) headphones are now commonplace and popular. Originally loved by frequent air travellers, they have become popular in offices, worksites, and homes. Because they target low-frequency constant noise, ANC systems still allow conversations to take place, or unusual noises to be heard. This is why they are allowed on worksites - even the radio playing from the corner will have more of an effect on safety than the ANC. What they do achieve is the reduction of impact from low, constant sounds, like aircraft or plant engines, buses out the front of the office, generators, air conditioning compressors, or anything else that produces such sounds.

With this in mind, we have been toying with the idea of building an ANC system based on an amplifier and a pair of speakers. The aim is to achieve noise reduction for an entire room. While this is for the future, we decided to first look into what makes ANC systems work, and then investigate a pair of headphones and what results we could achieve with them.

HOW DOES ACTIVE NOISE CANCELLING WORK?

The core of an ANC system has three components: A microphone, which picks up the target ambient noise; an amplifier, which inverts the noise and boosts its level to around the same as the target noise; and a speaker, which emits the inverted signal so that it can reach the ear. The signal from the microphone is inverted because sound is a wave travelling through the air. The wave has high and low points, with zero in the middle. Anything below zero is negative, while anything above zero is positive. If you add a negative number to a positive number, the negative number will subtract from the positive.

If you add a negative wave to an equivalent positive wave (let’s just say negative five to positive five, to have something to work with) you have zero. When two waves are not in exactly the same place in time (or when graphed), they are said to be ‘out of phase’. Sound waves are sine waves. A full cycle is 360°, a half wave is 180°, etc. Because half of 360° is 180°, the waves need to be 180° out of phase in order for the positive peaks to line up with the negative peaks. If they do, the mathematical total is zero, and this results in no sound.

ANC systems are also usually sealed. This means that there is physical shielding so that noise generally enters the listening environment through known paths. ANC headphones are a great example - the only way noise can enter is through the ear cups. Some cars now use ANC systems, with microphones placed strategically outside the cabin lining to pick up road and engine noise. Being a controlled environment like this improves the effectiveness of ANC.

EXPERIMENTS WITH COMMERCIAL HEADPHONES

The first thing that occurred to us to do was to measure the relative sound pressure levels between the outside and inside of a pair of ANC headphones. A pair was obtained and duly charged up, and two identical sound meters were chosen.

We chose to use sound meters because they were cheaper and more accessible to makers compared to an oscilloscope.

The challenge was how to set up the measuring system. The only retail display heads we had on hand were glass, and problematic to drill through. So, we marked and cut a cardboard box, inserted the sound meter, clapped on the headphones, and went to work.

We tried dB A weighting and dB C weighting, the latter being more suited to low-frequency noise, but found no difference in the trends in the readings with the ANC switched on or off. We say trends because the readings dance around like a Staffy puppy, but do tend to cluster around a general point. This point moves depending on what’s going on. When a bus pulls up outside, the trend increases. We were a little surprised by the lack of impact from the ANC system, particularly because pulling the headphones off the box and wearing them showed a very noticeable difference between ANC on or off. All was revealed when the sound meter again showed no shift in trend without the headphones installed on the cardboard box. So much noise was coming through the cardboard box that the ANC was having no effect. This isn’t an issue with most human heads.

Cardboard tube cut to reduce the surface area of the enclosure, and wrapped with bubble wrap

After a re-think, a length of cardboard tube was cut in an attempt to reduce the surface area of the enclosure, and wrapped with bubble wrap to reduce its permeability to sound. This would render the plastic cups of the headphones the primary source of noise ingress. The performance was better with this rig, but far from conclusive. The headphones are designed to cancel noise right next to each speaker, where the ear sits, so perfect results were not expected.

A further rethink moved the test from near the windows at the front of the building, to the concrete bunker at the back where 3D printers and CNC equipment is used. With printers active, the room is filled with a low buzz from several stepper motors, reverberating from metal frames and panels. A railway line is also closer to this side of the building, being more constant in effect than passing road traffic.

In the new setting, a definite impact was visible. With ANC off, the sound pressure level (SPL) inside the tube was consistently three to four decibels quieter, C-weighted, than the meter on the outside of the tube. A moving blanket ensured the surface was not reflecting sound waves. Switching on the ANC function showed a consistent average of nine to ten decibels quieter inside the tube. This was the effect we were looking for, and showed that the ANC effect would be measurable with the equipment we had. It also gave an important benchmark when going large-scale.

One final experiment was to fill the hole in the middle of the tube, and drill a new one close to the headphone cup on one side, where an ear would normally be. Being closer to the intended use, we hoped this might bring an even better result, but the trends stayed largely the same, with no real difference compared to the previous test position.

WHAT’S IN THE BOX?

With that done, it was time to dismantle the headphones. The aim here was to separate the microphone and electronics, which contain the preamplifier for the microphones but also the Bluetooth and audio input mixing circuits. We could then measure the amplifier output, to determine if it could be fed directly to a stand-alone amplifier via RCA input, or if it would need conditioning.

Inside the headphones, we found a small microphone mounted right next to each speaker, completely within the enclosure. Further to this, another was mounted on one side in a bracket that held it facing out of the enclosure, and toward the ground when the headphones are on the head. The purpose of the two small microphones near the speakers will be impossible to confirm. The circuit cannot be reverse-engineered, as it is a multi-layer board with a blob of resin covering a chunk of it. Sources variably report similar microphones being used to monitor the effect of the noise cancellation, while some suggest these microphones monitor the frequency of the sound coming from the speakers and compare it to the incoming audio signal. These microphones connect to the opposite side of the circuit board to the external mic, so we would say the external one pictured here measures the outside sound, while the speaker-mounted electret compares the noise with the cancellation signal played through the speaker.

In the end, it was pretty clear that the inside of the headphones wasn’t going to be a lot of help to us. Instead, a small length of shielded cable was soldered to the right-hand speaker at the terminals, and passed through a close-fitting hole we drilled in the case. Then, the headphones were carefully reassembled. This allowed an oscilloscope to be connected to the headphones to display the cancellation waveform. The result was a wave that typically reached 0.4V peak to peak. RCA signals are generally specified at 1V peak to peak, but of course, this is for maximum signal, leaving our signal in the ‘comfortable’ range. It was certainly worth soldering an RCA plug on and finding an old amplifier. We settled on a pair of active speakers, of which we used the amplified left-hand side.

SCALING UP

We set up the sound meters on tripods and placed one of them one metre behind the speaker, and the other one metre in front. We placed the headphones about thirty centimeters diagonally behind and to the side of the speaker, plugged in the RCA lead, and turned on the active speaker. We were immediately deafened with feedback. This is logical, as when the headphones are worn on the head, the ear cup becomes a sealed environment with the microphone outside of it. The position of the microphone facing perpendicular to the headphone speaker and being behind the widest part of the ear cup, rather than flush with or in front of it, means that the microphone is shielded quite effectively from feedback sources. Not the case with our set-up!

This might seem to make little sense at first: Why do the headphones feedback now and not normally when sitting on the table and switched on? Because the microphone is now picking up the inherent noise from the powered speaker as well as any from the headphone speakers. This is routed, albeit inverted, through the headphone speakers, meaning there is a lot more signal going through the system than before, bringing it to and past the point of feedback. We confirmed this by returning the headphones to their test state, taped to a bubble-wrap covered cardboard tube to seal them. In this arrangement, feedback only occurs with the headphones (and microphone) in front of the active speaker. If the headphones are behind or beside, there is no feedback. It is worth noting that we were moving the DIYODE office at this time, and the room was full of hard surfaces and echoes. The rubber floor mats in the photos were about the only soft thing in the room.

Note: The second speaker is unconnected and used as a stand for the headphones.

The SPL meters were set to C weighting, and the one behind the speaker consistently read around 2dB higher than the one in front. The noise source in the room largely comes from the front windows, which were behind the test speaker. With that noted, the powered speaker was switched back on. The SPL meter in front of the speaker showed a slightly higher reading, which was not what we really wanted. To make the experiment more controlled and less to chance, the PC speakers at the work station next to the aforementioned window were turned on and a web application used to run an audio sweep from 50Hz to 500Hz. Again, the SPL meter in front of the speaker showed an increase in volume.

We hypothesise that this is because the system is not sealed. The ANC headphones were indeed picking up and inverting the noise signal before sending it to the active speaker, which was amplifying it. This was confirmed by turning the ANC off: The SPL reading on the speaker’s meter dropped, and dropped again when we powered down the speaker. The cheaper amplified speakers have a fair amount of white noise when idle. Because the system is not sealed, the SPL meter is picking up the inverted, noise-cancelling signal from the speaker, but also picking up all the ambient noise from the unsealed environment.

Add to that the additional delay in running the ANC signal through the amplifier, and it may well not be 180° out of phase anymore. Combined with the white noise hiss from the amplifier, the net result was actually an increase in SPL. Looking around at other ANC applications, the sealed environment is important. Cars with ANC use multiple microphones outside the cabin lining to pick up the engine and road noise, and multiple speakers rather than one so that the inverted signal is distributed. The same can be said for ANC systems fitted to some room spaces. These use multiple microphones sealed against walls or windows to pick up only ambient noise, or carefully placed microphones to pick up internal noise sources such as fan motors. Again, they use multiple speakers to effectively cancel the signal.

CONCLUSION

While this experiment has not succeeded, we have found it informative, and hope you have too. This time around, we didn’t get the result we were after to proceed to a full-room ANC system, but that does not mean we’re giving up. There is a solution, and while we have no idea how long the development will take, watch this space.

WHERE TO FROM HERE?

The next port of call will be to establish a more controlled space - the cardboard box from a fridge or water heater, a cupboard, something like that. To this, we will attach more than one microphone, build our own inverter amplifier, and have multiple speakers inside. While it may end up looking like a kids’ cubby house, it should be a good next step on our path to a silent room.

Why Are Failures Valuable?

Looking back at the history of science, from the earliest records to the present day, rarely is a great scientific discovery made when things went exactly according to plan. Some are made when anomalies are noticed when things go mostly as they're expected to. Others, however, result from asking 'why?' after a total failure. Comparing experimental results with expectations often leads to disappointment in many makers and others engaging in scientific exploration, but we should instead view this as an opportunity to gather new information, question our assumptions and existing knowledge, and learn new things.

vAs long as a 'failure' is analysed carefully and thoughtfully, it is not a negative thing. Always look on a failure as a set of new data, not a disappointment. It is a set of new discoveries waiting to be made, or a reminder of what we've forgotten to think about. Some failures are face-palm, 'how-did-I-overlook-that?' moments, which are still valuable thinking exercises. Others are the next big addition to our understanding and knowledge.