This description relates to filtering for detection of limited-duration distortion.
Various signal processing techniques can be used for noise reduction of signals that may have been distorted in certain ways due to noise sources. In some cases, the distortion corresponds to additive noise, such that an undesired noise signal is added to a desired signal to produce a signal that may still resemble the desired signal but has certain distortions caused by the added noise signal. When the noise signal has characteristics that enable it to be distinguished from the desired signal, certain techniques can be applied to reduce the distortions. For example, if the noise signal has a frequency spectrum that is concentrated in a frequency range that is higher or lower than the frequency spectrum of the desired signal, frequency filtering (e.g., high-pass or low-pass filtering) can be used to reduce the amplitude of the noise components of the distorted signal without substantially reducing the amplitude of the desired components of the distorted signal. In some cases, the distortion is linear, such that a linear filter (e.g., a frequency filter) could be used to reverse the distortion applied to the desired signal (if the characteristics of such a filter were known). Nonlinear distortion typically cannot be completely reversed by application of a linear filter.
In one aspect, in general, processing an input signal includes determining the presence of a predetermined signature in the processed input signal, in a frequency range in which a desired signal (e.g., an original signal being transmitted via the input signal) has no energy or relatively low energy, to detect a corresponding limited-duration nonlinear distortion of the desired signal. The processing can include, for example, linear filtering of the input signal. Determining the presence of the predetermined signature can include identifying a particular shape over a particular duration in the processed input signal. After the presence and location of the nonlinear distortion is located, techniques can be used to reduce or eliminate the nonlinear distortion.
In another aspect, in general, a method for processing a signal includes: receiving data that includes an input signal; filtering the input signal to generate a filtered signal, such that if the input signal includes at least one instance of a nonlinear distortion of a desired signal then the filtered signal includes a signature signal corresponding to the nonlinear distortion, the nonlinear distortion characterized by a time duration that is within a predetermined range; and detecting whether or not the filtered signal includes the signature signal.
In another aspect, in general, an apparatus for processing a signal includes: an input interface configured to receive data that includes an input signal; at least one processor configured to process the input signal. The processing includes filtering the input signal to generate a filtered signal, such that if the input signal includes at least one instance of a nonlinear distortion of a desired signal then the filtered signal includes a signature signal corresponding to the nonlinear distortion. The nonlinear distortion is characterized by a time duration that is within a predetermined range. The processing also includes detecting whether or not the filtered signal includes the signature signal.
Aspects can include one or more of the following features.
The time duration corresponds to a predetermined number of samples of the input signal.
The predetermined number of samples is a single sample.
The nonlinear distortion corresponds to the predetermined number of samples being absent from the input signal between adjacent samples of the input signal.
The nonlinear distortion corresponds to the predetermined number of samples with approximately the same amplitude being repeated in succession within the input signal.
Filtering the input signal comprises applying a linear filter to a series of samples of the input signal.
The linear filter is based on a transform that is evaluated at a predetermined frequency.
The filtered signal is based on successive values of the transform evaluated at the predetermined frequency for different respective subsets of the series of samples.
The filtered signal is based on the successive values of the transform filtered with a high-pass filter.
The signature signal is characterized by a time duration that is within a predetermined range.
The time duration of the signature signal corresponds to a predetermined number of samples of the filtered signal.
Detecting whether or not the filtered signal includes the signature signal comprises applying a matched filter to the filtered signal.
The matched filter comprises a series of samples that includes a repeating pattern having a period of two samples.
The signature signal indicates that the nonlinear distortion is associated with a frequency in a predetermined region of a spectrum of the input signal.
The desired signal has a spectrum with signal energy predominantly outside of the predetermined region of the spectrum of the input signal.
The predetermined region of the spectrum of the input signal comprises a region that includes a frequency corresponding to a sampling rate associated with the input signal.
Compensation is applied to the input signal based on detecting whether or not the filtered signal includes the signature signal to provide a processed input signal to an output interface.
The compensation comprises inserting a predetermined number of samples between adjacent samples of the input signal to provide the processed input signal.
Inserting the predetermine number of samples comprises interpolating amplitudes of the predetermined number of samples based on amplitudes of the adjacent samples.
The compensation comprises removing a predetermined number of samples with approximately the same amplitude repeated in succession within the input signal to provide the processed input signal.
The compensation comprises locating a sample of the input signal associated with onset of the signature signal in the filtered signal.
The compensation comprises comparing amplitudes of samples in proximity to the located sample to determine whether the nonlinear distortion corresponds to: a predetermined number of samples with approximately the same amplitude being repeated in succession within the input signal, or a predetermined number of samples being absent from the input signal between adjacent samples of the input signal.
Providing the processed input signal to the output interface comprises applying asynchronous sample rate conversion to the compensated input signal.
The received data comprises a portion of a streamed signal.
The output interface comprises a speaker.
The data is received over a wireless receiver.
The data is received from a storage device.
Aspects can have one or more of the following advantages.
The signal processing techniques described herein enable audio artifacts caused by certain types of nonlinear distortion to be reduced or eliminated. Some nonlinear distortion arises due to limited-duration distortions of a digital audio signal. For example, some systems for streaming digital audio signals (e.g., over a wireless network) introduce errors that result in a digital audio receiver occasionally receiving an extra sample in the digital audio stream that is a repeat of an adjacent previous sample, and which was not present in the original digital audio signal. Another type of error that may be introduced results in the digital audio receiver occasionally receiving a digital audio stream that is missing a sample that was present in the original digital audio signal.
These missing or repeated sample errors can manifest as artifacts such as a clicking or ticking noise that can be heard on top of the content (e.g., music) of the original digital audio signal. The desired original digital audio signal can be recovered if missing or repeated samples can be reliably detected. Signal processing techniques, as described in more detail below, can be used to detect the presence of limited-duration nonlinear distortions such as these missing or repeated sample errors, and to determine the location of specific samples to be corrected. Other types of limited-duration nonlinear distortions that can be detected include phase discontinuities in sinusoidal waveforms (e.g., in audio signals or communication system carrier waveforms), or distortions due to clock-jitter, for example. The signal processing techniques used in a module of an audio system can improve the quality of the sound reproduced by the system. The signal processing techniques can also be used in various types of devices or modules that transform signals, such as asynchronous sample rate converters or analog-to-digital converters, and for various types of applications such as digital audio watermarking or recursive improvements to sample interpolation.
Other features and advantages of the invention are apparent from the following description, and from the claims.
The techniques described below for processing signals can be used in any of a variety of devices and systems that transport and/or play digital audio signals. Some devices play audio signals from digital data that has been stored locally. In some systems, the audio signals are transported as a stream from a transmitter device to one or more receiver devices in a distributed system.
Referring to
Referring to
When an audio signal contains a distortion, various factors determine whether or not that distortion will be audible. Generally, the distortion due to a missing or repeated sample is most audible when the audio signal is dominated by a sustained note with a dominant fundamental frequency approximately 800 Hz or greater. The audibility also depends on the sample rate of the signal and the amplitude of the signal. The distortion becomes more audible as the time between adjacent samples becomes a more significant portion of the period of the sinusoidal waveform at the dominant fundamental frequency.
Any signal can be represented as a sum of sinusoidal waveforms at different frequencies. Over a period of one of these sinusoidal waveforms represented by N samples, the phase changes monotonically by (360/N)° per sample.
These discontinuities in the phase relative to an ideal sinusoidal waveform can be detected using a linear filtering technique, which is described below for the case of a single missing or repeated sample. To illustrate aspects of the linear filtering to be performed by the module 204, the mathematical representations of an ideal signal and a distorted signal are shown below along with an analysis in the frequency domain using a discrete Fourier transform (DFT) of each signal.
The ideal sinusoidal signal can be expressed as follows.
This is a time-dependent signal where the discrete time index variable n (for n=0 . . . N−1) represents successive samples in time that occur at multiples of a regular sampling interval, A is the amplitude, k0/N is the frequency of the sinusoid in cycles per sample, and θ0 is a constant phase shift. This sinusoidal signal, representing a dominant fundamental frequency within the spectrum of an input signal, is assumed to have been sampled at grater than the Nyquist rate such that k0<N/2.
An N-point DFT of the ideal signal can be expressed as follows.
DFTs of a time-dependent signal are frequency-dependent, where frequency corresponds to the discrete variable k (for k=0 . . . N−1), with the largest frequency corresponding to the Nyquist frequency k=N/2 (also known as the “Nyquist bin”). This DFT is also time-dependent, corresponding to performing the DFT operation over a window of N samples whose position relative to the signal x(n) shifts in time according to the discrete time index variable m. The DFT calculation can be updated as new samples of the signal x(n) are received. As each new sample of the signal x(n) is received, the DFT Xm(k) is calculated based on a new set of samples with one old sample sliding out of the window and one new sample sliding into the window.
The distorted signal with a missing sample can be expressed as follows.
In this example, there is a single missing sample within the window of N samples over which the DFT is calculated. The missing sample occurs between the values of n=N0−1 and n=N0. The DFT of the distorted signal can be expressed as shown above, except with this new value of x(n). The DFT of the ideal signal will be denoted as Xm(k), and the DFT of the distorted signal will be denoted as X′m(k). As the window over which the DFT X′m(k) is calculated slides in time, the value of N0 progresses from N−1 to 0 (so N0=N−m−1).
When the DFT is evaluated at a particular frequency (in this example, at the Nyquist bin k=N/2), there is a qualitative distinction between the resulting time-dependent DFT Xm(k) of the ideal signal and the DFT X′m(k) of the distorted signal. The value of the DFT at the Nyquist bin can be efficiently calculated during signal processing as the difference between the sum of all even index samples and the sum of all odd-index samples.
For the ideal signal, the DFT at the Nyquist bin can be expressed as follows.
For the distorted signal, the DFT at the Nyquist bin can be expressed as follows.
The function IM{ } takes the imaginary part of its argument. These expressions are based on the following additional assumptions. The value of the frequency variable k is assumed to be different from the value of the frequency constant k0, which is true when k0 is not an integer. The value of N is assumed to be an even integer.
A qualitative distinction between these two DFT signals is their dependence on successive values of the time variable m. For the distorted signal, the amplitude of the complex value whose imaginary part is extracted has same dependence on m as the ideal signal except for the following factor.
This factor includes a term with a first m-dependent phase that varies as
for each incremental change in m, and a second m-dependent phase that varies as π for each incremental change in m. Since k0<N/2, the first phase varies more slowly with m than the second phase, which yields a value ejπm that changes back and forth between +1 and −1 as m goes from 0 to N−1. So, the amplitude of this factor oscillates with m under some envelope determined by the value of k0. This oscillation signature signal has a predetermined length of N samples and can be detected using additional linear filtering (e.g., a high-pass filter and a matched filter). Since the DFT is also a linear filter, the total effect of the filtering can be applied by the module 204 using a single linear filter. In other examples, the moving DFT can be calculated at other frequency bins since the oscillation signature due to a missing (or repeated) sample is a wide-band distortion, but the Nyquist bin enables efficient detection if the spectrum of the input signal is band-limited below the Nyquist frequency.
In some implementations, the time-dependent DFT signal X′m
is high-pass filtered to better isolate the oscillation signature that occurs at the Nyquist frequency of k/N=½ cycles per sample (or 1 cycle per 2 samples). The Nyquist component of the DFT signal extracted by high-pass filtering can be expressed as follows.
This component can be obtained, for example, by filtering the DFT signal using a 3rd order high-pass filter with a zero cut-off frequency (i.e., a filter with three zeroes at the origin).
The oscillation signature can be detected using a matched filter consisting of samples that match the signature to be detected. For example, a matched filter Hm=(−1)m for m=0 . . . N−1 can be used to detect the oscillation signature. (This particular matched filter also corresponds to performing another DFT operation evaluated at the Nyquist frequency.) The resulting detection signal is the convolution of the high-pass filtered signal with the matched filter, as follows.
If the input signature includes an instance of the missing or repeated sample distortion, then the detection signal will indicate the presence of the oscillation signature. In this example, where there is a single missing sample, the magnitude of the detection signal
will include a signature signal comprising a series of values having a monotonic rise of length N followed by a monotonic fall of length N, with a single-sample local maximum in the middle (corresponding to the matched filter passing through the oscillation signature). When this signature signal is detected, the corrupted sample location is determined by subtracting (N+HPF_Order−1) from the time index at which the local maximum magnitude occurred. For example, with a DFT window of N=32 and a 3rd order high-pass filter, the value 34 is subtracted from the local maximum index to obtain the time index immediately following a missing sample or the time index of a repeated sample. Some limitations to reliable detection of the distortion may occur in some cases. For example, because only the imaginary portion of the complex argument is observed, there may be some limitations in some cases due to a blind spot and/or polarity uncertainty. In some cases, the frequency and phase of components of the input signal may lead to collapse of the oscillation signature.
Since the same signature signal occurs for either a missing sample or a repeated sample, the module 204 compares amplitudes of samples on either side of the time index to determine whether the distortion was caused by a missing sample or a repeated sample. The processing involved with correcting the detected distortion in the input signal depends on whether there was a missing or repeated sample. If the module 204 determines that there is a repeated sample in the input signal, the repeated sample at the determined time index is removed from the input stream before playing the processed input signal or sending the processed input signal to an output interface. If the module 204 determines that the input signal is missing a sample, the module 204 performs an interpolation process to insert a sample immediately before the determined time index. Any of a variety of interpolation techniques can be used. The selection of an interpolation method may depend on the processing resources of the module 204. In some implementations, the average of sample values on either side of the missing sample is used.
For nodes that receive a streamed signal from another node, the module 204 may also be configured to perform an asynchronous sample rate conversion (ASRC) on the processed signal to avoid a clock timing misalignment that may otherwise occur by removing or adding samples. Such a clock timing misalignment could also cause audio artifacts like clicking or popping. The ASRC processing would also ensure that a receiver node doesn't get too far ahead or behind if the addition or removal of samples to correct the missing or repeated sample errors build up over time resulting in a significant net increase or decrease in samples relative to a number of samples in a buffer, for example. This ASRC processing may be unnecessary for nodes that process a signal from a local storage medium.
Referring to
The techniques described above can be implemented using a program comprising instructions for execution on a device or module including one or more processors or other circuitry for executing the instructions. For example, the instructions execute procedures of software or firmware that runs on one or more programmed or programmable computing devices or modules including at least one processor and at least one data storage system (e.g., including volatile and non-volatile memory, and/or storage media). The programs may be provided on a computer-readable storage medium, such as a CD-ROM, readable by a general or special purpose programmable computer or delivered over a communication medium such as network to a computer where it is executed. Each such program may be stored on or downloaded to a storage medium (e.g., solid state memory or media, or magnetic or optical media) readable by a computing device, for configuring and operating the device when the storage medium is read by the device to perform the procedures of the program.
It is to be understood that the foregoing description is intended to illustrate and not to limit the scope of the invention, which is defined by the scope of the appended claims. Other embodiments are within the scope of the following claims.