Open access peer-reviewed chapter

Attenuation of Environmental Noise through Digital Filtering

Written By

Juan Ríos and Celedonio Aguilar

Submitted: 25 October 2019 Reviewed: 17 February 2020 Published: 16 May 2020

DOI: 10.5772/intechopen.91784

From the Edited Volume

Noise and Environment

Edited by Daniela Siano and Alice Elizabeth González

Chapter metrics overview

888 Chapter Downloads

View Full Metrics


This chapter proposes the implementation of an environmental noise cancelation system using the least mean squares algorithm with noise amplitude modulation (NAMLMS). The system was implemented in a dsPIC3020F10 digital processor. The results obtained demonstrate that low- and high-frequency signals are attenuated allowing the passage of an audible range between 5 kHz and 18.9 kHz, the above using real-time processing.


  • noise
  • amplitude
  • attenuation
  • digital
  • filtering

1. Introduction

It is important to consider that, after vision, the ear is the most important sensory organ of the human body. The ear is an alarm sensor; that is, it is always active to perceive sounds. The sound consists in the change of air pressure that produces waves with a certain periodic frequency. However, within these there are also sound signals that are inarticulate to the human ear and also unpleasant, even damaging human health. Any sound pressure in the air is measured in decibels. A decibel is a logarithmic value (not linear, but exponential) that represents the relationship between a measured value and a reference value. In any environment there are audible signals that we need to perceive (talks, alarms, etc.) and other unwanted signals that cause the so-called noise pollution. The said contamination is defined as the presence of noise caused by an acoustic emitter that implies discomfort or harm to the health of people.

Some of the noises to which the human auditory system is exposed and that are part of the noise pollution are the following:

  1. Noises due to the use of musical instruments

  2. Use of household appliances such as washing machines, vacuum cleaners, etc.

  3. Noises of air conditioning equipment

  4. Discomfort caused by infrastructure

  5. Dogs barking in the absence of their master

  6. Alarms and sirens caused by fixed sources and mobile sources

Noise pollution significantly interferes with interpersonal communication and increases workplace accidents and traffic accidents. Table 1 shows the noise levels and their effects on the human ear.

Table 1.

Noise levels and their effects.

A filter may consist of hardware or software applied to a set of noisy or contaminated data in order to extract information of interest. Noise can be generated by any source. In this chapter, a digital solution is proposed that allows the attenuation of noise attached to audible signals that are perceived by the human ear. An adaptive filter is a device that is useful for processing an input signal by blocking and/or allowing some parts of it (unwanted noise or vibration).

On the other hand, the adaptive filter [1] has a feedback loop that has the ability to minimize the error produced by the comparison between the output signal (after processing) and a reference signal (expected signal). The above allows to guarantee that the human ear is not contaminated with the unwanted signals and only to rescue the information that needs to be received. Figure 1 shows the structure of an adaptive filter.

Figure 1.

Generic structure of an adaptive filter.

The signal d(n) is the expected audio signal to be perceived by the human ear, x(n) is the input signal to the filter (what is perceived from the environment), y(n) is the response signal that grants the filter, and e(n) is the error required to adapt the filter parameters by comparing the desired signal with that obtained. This comparison is the difference between the desired (reference) signal with respect to the signal obtained at the filter output.

The operation of the algorithm that will represent the filter [2] is as follows:

  1. The input signal will be picked up (in the scheme it is labeled as x(n)). This signal is the one that is in the environment and that contains what you want to be perceived and the adhered noise.

  2. There is a reference signal labeled with d(n). This signal is what is expected to be perceived by the human ear, for example, the conversation you have with the person with whom you are talking.

  3. The signal x(n) is processed in order to attenuate unwanted signals (noises that may be high or low frequencies) in order to obtain y(n).

  4. The output signal y(n) and the desired d(y) are compared in order to obtain an error that should be the minimum possible.

  5. Based on the error generated, the process will be carried out again to ensure that the signal obtained after the filter is as close as possible to the reference signal.

In general, the filter [3] will be used to inhibit signals that are not desired (technically this process is known as attenuating the amplitude of the noise signal) to “clean” the signal that must be perceived by the human ear. The proposed technique adapts to the conditions of the environment in which it is being implemented.

Section 2 shows the development of the proposal; the equipment required for its implementation and its constituent parts are defined.


2. Design of the proposed algorithm and scheme

The design of the proposal will be partitioned in stages. Each stage involves material and equipment required for the tests, measurements, and results obtained. Figure 2 shows the process diagram that will follow the treatment of the signal captured from the environment.

Figure 2.

General processing diagram.

The general processing diagram shown in Figure 2 consists of five stages which will be explained below:

Stage A. It consists of the acquisition of the audible signal that is recovered from the environment. The use of an omnidirectional microphone is feasible here, the foregoing because the audio signal can be obtained from any point but not from a specific one. A microphone is a transducer device that converts sound waves into electrical voltage changes. In simple words, the microphone will record all the signals captured from any side from where they are received since the entire microphone structure is sensitive to sound. Next, Figure 3 shows the pickup pattern of an omnidirectional microphone.

Figure 3.

Omnidirectional pickup pattern in a microphone.

It should be mentioned that an omnidirectional pickup pattern captures the sound obtained from any direction.

It is important to capture all the sounds of the environment. For example, if a person is going to cross the street, it is important that he consider the sounds of fenced cars and be attentive to all perceived sounds in order to avoid an accident. The proposal to be designed will minimize the sound intensity of these noises but not completely mitigate them.

The proposal will capture all the random noises in the environment and process them, and when it detects that there is one that exceeds the threshold of intensity allowed, it will multiply it by a reduction factor and thus decrease its volume. The process described above is purely adaptive, which means that “n” number of repetitions will be performed until it approaches the expected result.

Stage B. The signal captured in Stage A is of analog format since it was captured in its natural form. However, for this stage, it is necessary to convert the captured signal into digital format since the computer and the processor require scanning to perform its function. The original signal has to be subjected to three basic operations to digitize it: sampling, quantization, and coding.

Sound, by nature, is an analog signal. It is produced by vibrations in the air that force the union of nearby molecules in the air by slightly raising its pressure. Such pressure changes reach the ear by vibrating the receptors and decoding to produce the sound. Some of the characteristics of the vibrations (in waveforms) are the following:

  1. Amplitude: reflects the change in pressure from the highest peak to the minimum. A waveform with large amplitude has a volume of equal magnitude; otherwise, the volume is quieter.

  2. Cycle: describes a single repeated sequence of pressure changes.

  3. Frequency: describes the number of cycles produced in a second. If the frequency is high, the tone of the sound will be higher.

Figure 4 shows the representation of two analog signals of different frequencies each.

Figure 4.

Analogic signals with different frequencies.

If the frequency of a sound signals increases, the sound will be perceived as more acute because the wavelength decreases. Otherwise, when the frequency is low, the repetitions decrease, the wavelength increases, and, therefore, the sound tends to be a high-pitched tone.

The first step to digitize the original signal consists of the sampling operation. The sampling of a sound signal consists of taking small representative pieces of the signal so that they are then encoded in binary digits to digitize them.

The condition that the signal has to remain representative of the original must be considered. To cover the previous condition, the following equation known as Nyquist’s theorem must be followed:

fs 2 fo E1

It is worth mentioning that if the sampling frequency is high, that is, if more samples are taken from the original signal in a certain time, the collection of significant parts for later digitization will allow a better fidelity of the original signal but now in a digital format and ready for computational processing.

Figure 5 represents the two signals shown in Figure 4 but now applying the sampling theorem; that is, small samples (pieces) representative of the signal are taken to be the “objects” to which binary codes will be assigned and thus digitized.

Figure 5.

Sampled analogic signals.

The quantization is the second step. It consists in assigning amplitude values ​​to each sample obtained in the previous step, the foregoing in order to identify each sample that will be encoded.

Finally, and based on the amplitude assigned to each sample, a binary combination is correlated to each of them to be identified. Samples that have the same amplitude will have the same binary code.

Stage C. In this step the adaptive filter algorithm will be implemented in the dsPIC3020F10 in order to perform the tests in real time. The processor will receive the signal in digital format (under previous scanning in Stage B) in order to process it to block the noise and allow the desired signal to pass through.

A DsPIC is a type of microprocessor known as a digital signal processor. It is responsible for real-time processing, a feature that is essential when non-tolerance of delays is required. Basically, a DsPIC [4] acquires a digital signal and processes it to improve it (in the case of audio, a clearer and sharper sound).

The algorithm to be implemented is the noise amplitude modulation least mean square (NAMLMS) which consists in a modification of the LMS algorithm, the foregoing because the noise will have a modulation in its amplitude in order to eradicate it as well as possible.

There is a wide variety of algorithms that can be classified into algorithms of low computational complexity with low convergence speed and high convergence speed algorithms with high computational cost. Some of the most used algorithms due to their low computational complexity are the averaged least squares algorithm (LMS, least mean square) and its normalization (NLMS). These algorithms have been successfully implemented in different systems. However, the convergence speed of these algorithms is slow. This means that the processing turns out to be so slow that it reduces the tests in real time, which would be not feasible for noise reduction applications especially in people suffering from hearing loss.

Figure 6.

Scheme of the proposal to cancel environmental noise.

The proposed scheme of Figure 6 consists of the following stages for the process:

  1. Detection of the desired signal mixed with the ambient noise.

  2. Attenuation of the environmental noise signal at a rate of 1/x, in order to reduce its amplitude and thus mitigate it. The above will happen only if the signal amplitude exceeds the allowed threshold. The frequency of it is not a factor to consider because we do not intend to distort the noise, only adaptively manipulate its sound intensity.

  3. The desired signal is subtracted from the amplitude-modulated noise signal.

  4. The signal obtained after the process is compared with respect to the desired one in order to obtain an error.

  5. Based on the error obtained, the system is adapted to decide whether to reperform the process or has already converged to the permissible and minimum tolerated error.

Next, the process to follow for the mathematical analysis of the system is shown:

  1. The desired signal with the adhered noise is picked up by the system. It is worth mentioning that the desired sound signal is contaminated by the noise prevailing in the environment:

s n = d n + 1 x v n E2


s (n) = signal captured;

d (n) = desired signal;

v (n) = adhered environmental noise; and

x = modulation coefficient for attenuation.

It is worth mentioning that the modulation coefficient will also be submitted to the adaptation algorithm in order to serve to attenuate the noise signal generated in the environment.

  1. 2. The correlation between both signals must be equal to zero. The above explains the fact that both are linearly independent:

r sv = cov s v cov s cov v = 0 E3

  1. 3. Subsequently, the signal obtained is processed by the adaptive filter to produce the output:

y n = k = 0 M 1 w k n v n k E4


w (n) = the values of the adjustable coefficients of the adaptive filter; and.

k = iteration for each adaptation.

  1. 4. The filter output y (n) is subtracted from the main signal s (n). The above defines the error signal:

e n = s n 1 x v n E5

  1. 5. The error signal is the one used to adjust the coefficient values of the adaptive filter and control loop around filtering operations and subtraction are related. Minimizing the mean square value of the error signal means maximizing the signal to noise ratio of the system output.

  2. 6. The adaptive filtering operation is perfect when:

y n = d n and with e n = 0 E6

In this case, the system output is noise-free, and the noise cancelation is perfect. Correspondingly, the signal to noise ratio of the output is infinitely large.

Stage D. It consists of validating the filter response and also verifying that it inhibits unwanted frequencies (adhered noise). It is important to consider that the frequencies that will correspond to the desired signal must be the sounds that are desired and everything else must be blocked.

Stage E. It is the inverse process of Stage B. The sound has an analog nature, so it must be converted to that format so that the receiver can decode it.


3. Results of the implementation

In the environment, the desired sound signals are mixed with the unwanted signals (noise) [5]. Figure 7 shows the acquisition of the desired signal and the mixed noisy signal.

Figure 7.

Combination between the original (desired) signal and the noise signal.

The blue graph shows the desired audio signal and used as a reference to compare what you want the system to throw at the output. The green signal is a type of noise captured in the environment, it could be said to be a random signal since it does not have a defined pattern. Finally, the red signal is the mixture of the previous ones.

The objective is to submit the mixed signal (red) to the proposed adaptive system in order to attenuate the noise signal and allow the sound signal to pass through.

The designed filter adapts to the conditions of the environment in which it is implemented. Next, the following figures will show, in parts, the analysis obtained for the proposed algorithm and its comparison with others established in the existing literature related to the subject.

Figure 8 shows the frequency response obtained for the passage of frequencies above the 10 kHz frequency which, on average, is the frequency at which a desirable sound oscillates. It is worth mentioning that, as a result of the adaptation, there is a slope that could establish a tolerance margin at lower frequencies.

Figure 8.

Frequency response of the high-pass filter.

As can be seen in Figure 8, the response of the NAMLMS algorithm shows a slight hesitation in stability but achieves greater convergence with respect to the responses of the other algorithms. The proposed algorithm was based on the LMS algorithm that results in obvious instability and convergence, concluded, but showing latency.

Figure 9 shows the response for the part of the filter that allows low frequencies to pass through. The comparison with the responses of other filtering algorithms is visualized, and the rapid convergence and adaptation of the response offered by the proposed system stands out.

Figure 9.

Frequency response of the low-pass filter.

Figure 10 shows the response of the system in general. It can be seen that the union of the two previous frequency responses generates the response of a frequency range through the filter. The objective is to suppress very low frequencies and very high frequencies that can be considered as noise and distortions that affect the human ear causing hearing loss.

Figure 10.

Frequency response of the band pass filter.

Figure 11 shows the signal obtained as a response from the system. When compared with the reference signal, a correlation value of 0.912 is calculated which, according to the theory, indicates that there is a strong correlation between both signals and that, although the noise is slightly perceived, the desired signal is clearly perceived.

Figure 11.

Signal resulting.


4. Conclusion

This chapter proposes an ambient noise cancelation system that allows to attenuate the noise that is mixed with the desired audible signals. Based on the results obtained, it is verified that the convergence of the algorithm is rapid relative to other existing ones, so it can be useful for use in new-generation cochlear implants or as treatments against symptoms of hearing loss.

Subjectively, the algorithm has a slight perception of adhered noise but does not affect its acoustic apparatus or the decoding of the messages of the desired sound signal.

Objectively, the correlation between the signal obtained after the respective system was calculated to the reference signal (desired), and an almost perfect result was achieved. Obviously a 100% correlation is not possible because the noise adhered to the desired sound and it is impossible not to modify some samples of said signal.



We would like to thank the Universidad del Valle de México for providing us with the necessary means to carry out the research and provide part of the resources required.

On the other hand, we also thank the Instituto Politécnico Nacional that has provided us with its facilities for experimentation and subject to real tests of the system I proposed. Without this valuable help, the development of this work would have been practically impossible.


  1. 1. Bhupendra KA, Miles AC, Chong H. A new adaptive algorithm and its implementation in MOS LSI. IEEE Journal of Solid-State Circuits. 1979;14(4):747-753
  2. 2. Bhupendra KA, Miles AC, Chong HC. A sampled analog MOS LSI adaptive filter. IEEE Journal of Solid-State Circuits. 1979;14(1):148-154
  3. 3. Bogucka H, Wesolowski K. Frequency-domain Echo cancellation in digital multicarrier modulation systems. IEEE Transactions on Communications. 2000;48(2):333-342
  4. 4. Ávalos JG, González JM, Velázquez J, Sánchez JC. Implementación del algoritmo LMS con error codificado en el DSP TMS320C6713. In: Congreso Nacional de Ingeniería Electromecánica y de Sistemas, Ciudad de México, México, Noviembre 26–30, 2007; 2007
  5. 5. Garcia M, Diego P, Quintana R: DSP implementation of the FxLMS algorithm for active noise control: Texas instruments TSM320C6713DSK. In: Automatic Control (CCAC), IEEE 2nd Colombian Conference; 2015. pp. 1-6

Written By

Juan Ríos and Celedonio Aguilar

Submitted: 25 October 2019 Reviewed: 17 February 2020 Published: 16 May 2020