The invention relates to digital signal processing, and more particularly to circuitry and methods for conversion of sampling rates of digitally sampled data.
Audio systems currently are required to handle data with various sampling rates, from low rates found in many .WAV files such as 8 kHz to high rates of consumer audio equipment such as 48 kHz. Audio is a key feature of PC multimedia with system requirements approaching those of consumer high fidelity systems for a fraction of the cost. For example, the PC 2001 specification sets high quality audio requirements to play out audio streams at 44.1 and 48 kHz rates. A hardware vendor may choose to supply a codec that only supports 48 kHz. In this case, sample rate conversion between 44.1 and 48 kHz is needed.
Of course, sampling rate conversion for integer ratio sampling rates can be performed by the steps of interpolation, lowpass filtering, and decimation. However, filters for a digital sampling rate conversion (SRC), where input and output sampling rates have a very large least common multiple, or the conversion ratio is irrational or slowly changing can be cumbersome. The irrational or slowly changing case is typically called an asynchronous sampling rate conversion (ASRC), and a well-known conversion method oversamples an input signal, converts it to a continuous signal by zeroth-order hold (ZOH), and then samples the continuous signal at the output sampling period.
In order to sufficiently reduce ZOH distortion, the oversampling ratio has to be very large; some researchers claim the ratio of 216 is adequate to achieve 16-bit accuracy. The problem that arises is that a large oversampling ratio requires a large number of filter coefficients. In order to efficiently reduce the memory storage for the filter coefficients, methods have been proposed that make use of multistage implementations of FIR filters; for example, see cross-reference patent application Ser. No. 11/371,597. However, the ROM size reduction by such methods is still not sufficient because the size should be proportional to the oversampling ratio of the second stage oversampler. On the other hand, Ries, A Class of Sampling Rate Converters with Interesting Properties, Audio Engineering Society 114th Convention, convention paper 5827 (2003), introduced a method that first oversamples an input digital sample stream by a factor of M (e.g., inserts M−1 samples equal to 0 between pairs of input samples plus lowpass filters (Kaiser filter) to eliminate images), and then performs a sampling-theorem type reconstruction using these oversamples but with sin c( ) replaced by an optimal finite-duration kernel derived from a B-Spline and its derivatives. This reconstruction can be calculated in run-time because the kernels are finite-duration. This significantly reduces ROM size while enabling high oversampling ratios because the kernels are piecewise polynomials. However, an audio system using such reconstruction would suffer poor sound quality due to the frequency characteristics of the B-Spline filter.
However, the known sampling rate converters need further improvements.
The present invention provides a digital sampling rate converter and filter design method using polynomial approximations for a polyphase filter as part of a multistage oversampling filter.
Preferred embodiment methods provide digital Asynchronous Sample Rate Conversion (ASRC) with two-stage oversampling using polynomial approximations in the second stage polyphase filtering. Indeed, with a first stage oversampling filter prescribed, a design method for the second oversampling filter first establishes a prototype of an optimum oversampling polyphase filter that minimizes a norm of the error in the frequency domain. Then the target sequence for the prototype is approximated by polynomials. Since the input signal to the second stage oversampler has been bandlimited by the first stage oversampler, lower degree polynomials are sufficient for the approximation.
For the approximation, two methods, namely two-step and direct approximation, are presented. A modification to the preferred filter design is also presented that improves the stop-band attenuation level by allowing droop in the pass-band.
Analogous to conventional polynomial interpolators such as Lagrange and B-Spline, the preferred embodiment polynomial-derived polyphase oversampling filter enables any large oversampling ratio, up to infinity. This gets rid of ZOH distortion. The difference is that the preferred embodiment filter outperforms those conventional interpolators in terms of frequency response, which is also confirmed through experiments.
Preferred embodiment systems (e.g., digital audio players, personal computers with multimedia capabilities, et cetera) perform preferred embodiment methods with any of several types of hardware: digital signal processors (DSPs), general purpose programmable processors, application specific circuits, or systems on a chip (SoC) such as combinations of a DSP and a RISC processor together with various specialized programmable accelerators and variable length coding (VLC). For example, the 55× family of DSPs from Texas Instruments have sufficient power. A stored program in an onboard or external (flash EEPROM or FRAM) could implement the signal processing.
In order to describe the preferred embodiments, we first consider the “analog interpretation” of sampling rate conversion.
H(z)=H1(zM
can be understood as a class of interpolated FIR (IFIR) filters, where H1(z) and H2(z) are called the bandedge shaping and the masking filters, respectively.
The preferred embodiment methods provide for masking filter H2(z) design with efficient ROM size for coefficient storage. Note that H1(z) can be any filter, whether FIR or IIR, as long as it has a proper low-pass characteristic as shown in
Let H2(z) be a non-causal FIR filter with length 2M2L. Also, let the impulse response of H2(z) be h2(m) for m=−LM2, −LM2+1, . . . , LM2−1. Then the output signal y(m) is given as:
y(m)−Σ−LM
Apply index mapping: m=nM2+ρ with n=−L, . . . , L−1 and ρ=0, 1, 2, . . . , M2−1; and use the definition of s′(m) as mostly zeroes to get the polyphase structure of the filter:
where gρ(l)=h2(lM2+ρ) for −L≦l≦L−1. The gρ(l) can be said to form a set of length-2L polyphase filters that are obtained by downsampling h2(m).
As will be shown, the design problem for h2(m) can be reduced to the easier problem of designing individual gρ(l). To do this, we next derive the relationship of frequency response between h2(m) and the gρ(l).
Taking the z-transform of gρ(l) and changing summation index gives:
where q(k)=δk,1M
q(k)=(1/M2)Σ0≦λ≦M
Substituting this expression for q(k) in the above, factoring the exponentials, and switching order of summation gives:
G
ρ(z)=(1/M2)Σ0≦λ≦M
The frequency response of gρ(l) can be seen by setting z=ejω in the foregoing:
G
ρ(ejω)=(1/M2)Σ0≦λ≦M
This suggests that the filter design problem for H2(ez) can be reduced to another filter design problem, which is to design individual Gρ(ejω) for a given filter specification of H2(ejω).
and the value is unconstrained elsewhere (“don't care bands”).
Now applying scaling and translations to the frequency variable for the various values of λ gives for |ω|<π/M1:
and |ω|<π/M1 corresponds to the don't care bands.
Then substituting this ideal Ĥ2(ej(2πλ+ω)/M
Ĝ
ρ(ejω)=ejωρ/M
That is, Ĝρ(ejω)n acts as a fractional delay all-pass filter.
Prototype Design
There are two well-known ways to design the filters gρ(l) to approximate the ideal by minimizing the norm of the error ∥Ĝρ(ejω)−Gρ(ejω) ∥; namely, minimum mean squared error (MMSE) with the L2 norm and minimax approximation with the L∞ norm. In both cases the minimization of the error reduces to a system of 2L linear equations for each value of ρ:
Agρ=bρ
where, with the abbreviation f(x)=sin c(πx/M1), the 2L×2L matrix A and the 2L-component vectors gρ and bρ for the MMSE case are:
Analogously for the minimax case: the vector gρ is the same and the matrix A and vector bρ are, in terms of frequencies ω1, ω2, . . . , ωL at which a selected (4L−1)-tap equi-ripple halfband filter with bandedge at π/M1 has unity gain:
Then the filter coefficients are found as gρ=A−1 bρ; and these coefficients only depend upon L, M1, and M2.
So far, we have discussed well-known design methods for an oversampling filter, where the design problem was cast as solving a system of linear equations in the preceding section. By solving this system for each gρ with ρ=1, 2, . . . , M2−1, we will obtain a total of 2LM2 filter coefficients, which have to be stored in a ROM. In order to reduce the ROM size, the preferred embodiment methods approximate gρ with respect to the variable ρ by polynomials. From the preceding, it can be seen that A is independent of ρ; whereas, bρ depends upon ρ/M2. If we can approximate each of the 2L components of the gρ by an N-th degree polynomial with respect to ρ, the total ROM size will be reduced from 2LM2 filter coefficient as ROM entries to 2L(N+1) polynomial coefficients as ROM entries. Of course, the filter coefficients are computed from the polynomial coefficients and p values. For example, in the MMSE case, the first component polynomial approximation would be approximating sin c(π[−L−ρ/M2]/M1) as a function of the discrete variable ρ; that is, for each component a section of length π/M1 of the graph of sin c is approximated by a polynomial.
Preliminarily, we normalize the variable ρ to x=ρ/M2. Then we introduce a method that approximates the i-th component of bρ, which is written as bi(x), for i=1, 2, . . . , 2L. Thus for the MMSE filter, the first component is b1(x)=sin c((π(−L−x)/M1); and for the minimax filter, b1(x)=cos(ω1x).
Then let qi(x) denote the polynomial approximation of bi(x) with
q
i(x)=Σ0≦n≦Ncn(i)xn
where cn(i) are the polynomial coefficients. Obtain the polynomial coefficients using the least-square method as follows. Discretize x and determine K sample points xk, where k=1; 2; . . . ; K and 0≦xk<1. At each sample point, we calculate the target desired values bi(xk). Then the least-square solution is given as
c(i)=(XTX)−1XTbi
where the vectors and matrix are
Note that K has to satisfy K>>N. Typically, K=M2 and xk=k/M2 is sufficient. After c(i) is calculated for i=1; 2; . . . ; 2L by using X, the polynomial oversampling filter can be obtained as follows.
Thus the elements of the 2L×(N+1) matrix A′ are independent of ρ and are stored. Then the filter coefficients gρ(l) are approximated using A′. Section 5 below describes a direct polynomial approximation method for the MMSE case.
An alternative polynomial approximation method for the polyphase filter coefficients gρ(l) in the MMSE case directly substitutes an N-th degree approximation polynomial, pρ/M
p
ρ/M
(l)=Σ0≦n≦Ncl(n)(ρ/M2)n for l=−L, . . . , L−1, ρ=0, 1 . . . , M2−1
The cl(n) are the polynomial coefficients for the approximation of gρ(l) and differ from the section 4 coefficients cn(l). which are for polynomial approximation of the bρ(l). Obtain the polynomial coefficients cl(n) by expressing the error norm in the frequency domain and minimizing with respect to each of the cl(n) by setting the partial derivatives of the squared error norm to 0; this gives 2L(N+1) equations for 2L(N+1) unknowns:
Σ−L≦l′≦L−1Σ0≦n′≦N sin c((l−l′)/M1){Σ0≦ρ≦M
for n=0, . . . N and l=−L, . . . , L−1. The polynomial coefficients cl(n) can be calculated by solving this linear system.
In this case, a ROM stores the 2L(N+1) polynomial coefficients cl(n), and the polyphase filter coefficients, gρ(l), are approximated when needed for an output sample calculation by the polynomial as gρ(l)≈pρ/M
The sampling rate conversion use of the polyphase filter gρ(l) is explained as follows. When the time index m, at which an output sample is to be created, is determined, we map m to integer values n and ρ so that
m=nM
2+ρ where 0≦ρ<M2
where n and ρ specify the input time index and polyphase index, respectively. Then the polyphase filter coefficients gρ(l) are calculated using the polynomial approximations of the preceding section. Finally, the output sample y(m) is calculated by using the polyphase filtering.
The preferred embodiment polynomial-approximated polyphase filter can also be used for infinite oversampling ratio or continuous time interpolation, where the output time index t can have fractional values. In this case, t is mapped to
t=T+τ where 0≦τ<1
where T and τ are the integer and fractional parts of t, respectively. The output sample y(t) is calculated by a modified version of the foregoing:
y(t)=Σ−L≦l≦L−1s(T−l)gτ(l)
where the coefficient gτ(l) is computed from the l-th approximation polynomial with variable value equal to τ instead of ρ/M2. That is, compute the output sample with coefficients gτ(l)≈pτ(l)=Σ0≦n≦N cl(n)τn.
In short, the oversampling rate conversion for a rational rate ratio has input samples y(iTs) where Ts is the input sampling period, and computes output samples ŷ(t) for times t=mTs/M where M is the oversampling ratio as follows.
(a) Oversample the input sample stream with a first stage oversampling ratio M1 (for example, by 0 insertions and lowpass filtering or by other methods). Let y1(jTs/M1) denote these first stage oversamples which are stored in a FIFO buffer that is emptied during subsequent steps.
(b) Index map output sample time t by integers m(t)=k(t) M2+ρ(t) where ρ=0, 1, . . . , M2−1 and M2=M/M1; that is, t=m(t)Ts/M=k(t) Ts/M1+(ρ(t)/M2)Ts/M1 where 0≦ρ(t)/M2<1.
(c) Evaluate the 2L polynomial approximations (2L(N+1) polynomial coefficients cl(n) are stored in ROM) at ρ(t)/M2 to give the filter coefficients pρ/M
p
ρ/M
(l)=Σ0≦n≦Ncl(n)(ρ/M2)n
where sets of N+1 of the polynomial coefficients correspond to polynomial approximations with respect to polyphase index (ρ=0, 1, . . . , M2−1) for the length 2L polyphase filters constituting H2 which is the lowpass filter for a second stage oversampling with ratio M2.
(d) Compute the output sample at t as:
{circumflex over (y)}(t)=Σ−L≦l≦L−1y1((k−l)Ts/M1)pρ/M
For output sampling times t which are not multiples of the oversampling points, find τ(t) so that t=k(t) Ts/M1+τ(t)Ts/M1 for k(t) an integer and 0≦τ(t)<1; and then evaluate the approximation polynomials at τ to get filter coefficients pτ(l) as pτ(l)=Σ0≦n≦N cl(n)τn for computation of the output sample as:
{circumflex over (y)}(t)=Σ−L≦l≦L−1y1((k−l)Ts/M1)pτ(l)
The preferred embodiment polynomial-approximated second-stage oversampling filter was evaluated in the following condition. The oversampling ratio of the first stage oversamling filter M1 was assumed to be M1=4. Therefore, the input signal to the second stage oversampling filter was supposed to be cut-off at ¼ of the Nyquist frequency. Other conditions were chosen as follows.
Oversampling ratio M2=32
Polyphase filter length 2L=6
Polynomial degree N=4
Under the above conditions, we generated the polynomial coefficients based on both the two-step method of section 4 and the direct method of section 5.
The frequency response of the designed filter is shown in
As explained in section 3, H1(ejωM
H(ejω)=H1(ejωM
As can be seen, H1(ejωM
The preferred embodiment filter design method was also tested for various oversampling ratio much larger than M2=32. For the both (two-step and direct) methods, we confirmed that the worst case stop-band attenuation level stayed at −100 dB for any large oversampling ratio M2. On the other hand, it is important note that computational costs and ROM size are independent of M2. Therefore, under a certain design specifications regarding the first stage oversampling ratio M1, polyphase filter length 2L, polynomial degree Nand stop band ripple, the preferred embodiment second stage oversampling filter allows any large oversampling ratio M2 without any increase in computational cost nor ROM size. With this property, the preferred embodiment method is efficient for multistage oversampling filter systems that require huge oversampling ratios.
Comparison with Conventional Methods
The performance of the proposed filter was compared with Lagrange and B-Spline interpolators, which are well-known conventional polynomial filters. Since the polynomial degree N of these filters are restricted to be N=2L−1, we let 2L=6 and N=5. The other conditions were chosen same as the previous section. We calculated the entire frequency response of H(ejω) using the same first-stage oversampling filter shown in
It is also noted that, with these conventional methods, the stop-band width and stop-band attenuation level are determined uniquely once the filter length 2L (and therefore the degree N) is given. Contrarily, the preferred embodiment design methods allow flexibility to control the trade-off regarding stop-bands (narrower the bandwidth, better the attenuation). This is another benefit in using the preferred embodiment polynomial filter design. Furthermore, the preferred embodiment methods provide full flexibility of choosing the filter length L and the polynomial degree N independently unlike the Lagrange and B-Spline type polynomials.
8. Improvement with Pass-Band Droop
The previous section indicated that the B-Spline filter gives better stop-band attenuation, while it suffers from droop in the pass-band. Having droop in the second stage oversampling filter can be acceptable in the case where the first stage oversampling filter is capable of compensating for the droop. If this is the case, we can improve the stop-band attenuation level of the second stage polynomial filter by allowing its pass-band to have droop.
Modified Polyphase Filter Specification for Droop
To enable droop, we only have to modify the specification of the second stage filter response Ĥ2(ejω) to have
where W(ω), 0≦W(ω)≦1, corresponds to the droop curve. Typically, W(0)=1 and W(π/(M1M2) is the droop level at the pass-band edge. Thus the ideal polyphase filter response is modified to
Ĝ
ρ(ejω)=W2(ω)ejωρ/M
where W2(ω)=W(ω/M2). Noting that W2(0)=1 and W2(π/M1) is the droop level at the pass-band edge.
Polynomial Coefficient Based on the Direct Approximation Method
The new polyphase filter specification with droop can easily be adopted to the direct method (explained in section 5) for finding approximation polynomial coefficients. In particular, the p-th error component in the frequency domain Pρ(ejω)−ejωρ/M
where S(l+ρ/M2)=∫−π/M
Design Example and Result
We evaluated the approximation polynomial filter under the same condition as previously. We let W2(ω)=1.0−0.12ω2. Therefore, the target droop level at the pass-band edge is calculated to be
20 log(1.0−0.12(π/M1)2)=−0.67dB
which is smaller droop than that of the B-Spline filter which can go down to −1 dB.
We calculated H(ejω) using the same first stage oversampling filter as those in
This application claims priority from U.S. provisional patent application No. 60/972,445, filed Sep. 14, 2007. The following co-assigned, copending patent applications disclose related subject matter: application Ser. No. 11/371,597, filed Mar. 9, 2006. All of which are incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
60972445 | Sep 2007 | US |