Active Noise Control – From Modeling to Real-Time Prototyping
Active noise control (ANC), also known as active noise cancellation, attempts to cancel unwanted sound using destructive interference. ANC systems use adaptive digital filtering to synthesize a sound wave with the same amplitude as the unwanted signal, but with inverted phase. This video first reviews the basic principles of ANC. It then shows how to use Simulink® to design and simulate an ANC system to cancel noise within a pipe model using a Filtered-X NLMS adaptive filter. Finally, you’ll see how to implement the ANC system using a real-world duct pipe and a Speedgoat real-time audio machine equipped with an ultra-low latency operating system and ultra-low latency A/D and D/A converters. The video shows how you can use automatic C code generation to go from the simulation model to the real-time prototype.
Explore the example used in this video: Adaptive Noise Control with Simulink Real-Time.
Have you ever wondered how active noise cancellation systems such as those found in headphones, cars, and HVAC systems are developed and prototyped?
Let me show you a prototype using MATLAB, Simulink, and the Speedgoat Real-Time Target Machine.
Using some simple PVC pipe, this system models the type of noise cancellation system that might be used in a duct for an HVAC.
Let`s talk about how we developed this system.
The principal of active noise cancellation is that when an audio wave is summed with its exact inverse, the resulting waveform is zero.
So how does one produce a waveform that is the exact inverse of the original noise source?
It is not trivial of course. However, using a few basic principles of acoustics and signal processing we can design a system that gets us very satisfying cancellation results.
Consider this diagram of our PVC pipe model. The noise source in our model is a speaker at one end of the PVC pipe. The noise cancellation, or “anti-noise”, source is another speaker connected via an elbow joint.
Here’s how our animation lines up with our real world PVC pipe model.
In addition to the noise and anti-noise sources, our system also uses two measurement microphones. The first measurement mic is our “reference mic”. This records the noise source close to its origin.
The second measurement mic is called the “error mic”. It is placed at the output of the PVC pipe. This mic is at the location where the noise cancellation will occur.
So, if the “anti-noise” signal is just the inverse of the noise source, why can’t we just invert the reference mic signal and play that out the loud speaker? The reason is that the noise source is going to propagate down the path from its origin to the end of the pipe. We measure the audio signal at the end of the pipe with our “error microphone”. As the signal propagates, the pipe acts as a filter that changes the sound of the noise. The propagation path of the noise from its origin to the end of the tube is called the “primary path”.
We can determine the characteristics of this “primary path” filter by using an “adaptive filter” algorithm. This filter will adapt until it has learned the filter weights that provide a digital representation of this filter.
The update algorithm that we use to update the filter weights is called “Normalized LMS”.
But wait, the anti-noise speaker has its own propagation path as well! We must also take that path into account. The propagation path from the anti-noise speaker to the error microphone is called the “secondary path”. We include an estimate of that secondary path in our system before the NLMS update.
So, are we finished now? Not quite! The final path to consider is the feedback path from the anti-noise speaker to the noise reference microphone. We need to subtract that anti-noise signal from our reference microphone or else we have a continuous feedback loop which will lead to incorrect results.
Okay, now we’re ready to simulate. Using Simulink, we created a simulated model of our real-world PVC tube system and our active-noise cancellation algorithm.
This model allows us to simulate a real-world system using a rapid prototyping environment.
For example, in this model we are simulating the primary and secondary propagation paths with digital filter equivalents. In addition, we simulate the acoustic summation of the noise and anti-noise signals with a summing block.
Now, anybody who has developed real-time audio hardware systems knows there can be inconveniences and technical difficulties that can often occur and get in the way of focusing on your algorithm. The great thing about this approach is that we can start off without hardware, test/debug the algorithm, then replace the simulated portions of our algorithm with the real-world equivalents once we’re confident it is working well.
This workflow is often referred to as model-based design.
When we run this model in simulation, we can listen in real-time to the audio signal.
We can also view how the signals change over time on the time scope. The yellow signal represents the input noise signal, so it stays constant. The blue signal represents the signal as measured at the error microphone. When we run the simulation, we see the blue signal reduce in amplitude over time as the filter adapts.
Here we see the filter weights that are changing over time as the filter adapts.
Once we are confident our algorithm is working in simulation, the next step is to replace the simulated acoustic environment by the actual real-world system. To do this, we need a tool that will allow us to get audio signals into and out of our Simulink model with ultra-low latency.
To achieve optimal latency performance, we deployed the model using the Simulink Real-Time and a Speedgoat real-time target machine.
This machine offers an ultra-low latency real-time kernel and ultra-low latency converters that allow signals to pass through much faster than a conventional desktop or laptop.
Why do we care about having low latency? Let’s return to our model. The system must record the reference microphone, compute the response and play it back on the ANC loudspeaker in the time it takes for sound to travel between these points. In this example, the distance between the reference microphone and the beginning of the “Y” section is 34 cm. The speed of sound is 343 m/s, thus our maximum latency is 1 ms.
The Speedgoat can be equipped with the necessary A/D and D/A converters to get the audio in and out of the machine with very low latency. In fact, with this solution the total latency is 2 samples. If we use an 8khz sampling rate, that’s a quarter of a millisecond!
We can make our Simulink model run on the Speedgoat hardware with a few simple modifications.
We’ll interface with the real-world audio signals going to and from our Speedgoat target machine using these custom Simulink blocks. These blocks allow us to specify things like the sample rate and voltage-range of our audio signals.
We can also access “target scopes” that allow us to visualize the signals on monitors connected to the target machine.
Here we see the Active Noise Control portion of model, adapted to run on the Speedgoat.
Because we have used a model-based-design approach, this model is very similar to the simulation model we built for testing our algorithm originally.
We have removed the blocks that simulate our acoustic filtering and acoustic summation because they are no longer needed. We are now interfacing directly with real-world signals.
Another capability we have added to our model is a block to perform “secondary path estimation”. This allows us to replace the estimate of our secondary path that was used during simulation with an actual measurement of the real-world secondary path.
This measurement will occur when the model first runs. After the measurement is complete, we will switch over to performing the active noise cancellation.
We do the same thing for the acoustic feedback.
Here is our model running in real-time on the Speedgoat machine.
We start off with the model measuring the Secondary Path Estimation and acoustic feedback. This is done by sending a white noise signal through the anti-noise speaker.
After that completes, we switch over to generation of noise. The generated noise source consists of synthesized tones that simulate the vibration of an HVAC fan or motor. Alternatively, we could use real-world recordings of similar noise types.
We start with the system off. We can monitor the measurement microphone signals on our real-time scope monitor. Also, we can view the level of the noise signal with the decibel meter we have placed next to the measurement microphone.
Now, we’ll turn on the active noise control using this dashboard switch on our model.
The noise level at the decibel meter starts to decrease. Within a few seconds, we see very noticeable results. The noise has reduced by 20 db!
We hope this video has offered some helpful insight into our methodology for rapidly prototyping an active noise cancellation system with real-time streaming audio.
We were able to create a realistic model of our system using Simulink and then apply that model to real-world implementation with Simulink Real-Time and the Speedgoat Real-Time target machine.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.