 |
| |
Adam Dabrowski received
an M.Sc. degree in electrical engineering from Poznan University of
Technology in 1976 and an M.Sc. degree in mathematics from Adam
Mickiewicz University in 1977. In 1983 he received a Ph.D. degree
in electronics. He is now a full professor at the Institute of
Electronics and Telecommunication and the head of the Division for
Signal Processing and Electronic Systems at Poznan University of
Technology.
More...
|
|
 |
This article shows how to do sampling-rate
conversion using a multi-channel audio DSP system. We will discuss
various aspects of hardware realizations of the conversion
circuitry using members of the Texas Instruments TMS320 family of
DSPs. A single processor can realize digital filters for the
real-time multi-channel sampling rate conversion of audio signals,
without the necessity of expensive multiprocessor systems. We
implemented and tested the algorithms using an experimental
hardware system composed of the TMS320C542 processor and the CS4226
20-bit converter.
Audio signals are currently represented digitally with various
sampling rates: 8, 16, 22.05, 24, 32, 44.1, 48, and 96
ksamples/s.
In order to achieve high spatial realism of audio
signals, you should use a multi-channel representation. Two typical
systems are stereo sound (two front channels) and 5.1 surround
sound (three front channels, two rear channels, and a subwoofer).
An online multi-channel sampling rate conversion is a very
important task that you can realize using modern DSPs, which
feature a host port interface (HPI) and a buffered serial port
(BSP).

Figure 1 presents an experimental DSP
hardware system for multi-channel sampling-rate conversion.
Figure 1: A DSP audio system with a TMS320C542
signal processor. The CS4226 audio CODEC is connected using the
BSP. Data is transferred to and from the host computer via HPI.
Frequency Domain Conversion
For audio digital processing, sampling rate alteration with a
rational factor M/N is often necessary (Table 1). Generally,
two different approaches are possible:
- The frequency-domain approach based on discrete Fourier
transformation (DFT) or on frequency selective filtering with
interpolation by M and then decimation by N
- The time-domain approach based on direct interpolation in time,
in other words, on the realization of a sequence of non-integer
delays.
You can also mix these two approaches, resulting in a reduction
of the required intermediate sampling rate. In this article, we
concentrate on the frequency-domain approach you implement with
filtering.
Figure 1 shows a block diagram of a simple system to
realize sampling-rate conversion.
Output samples are calculated using difference
equations, which utilize the up- and down-sampling and the
filtering in-between. Table 1 presents the respective up-
and down-sampling factors for the sampling rate conversions under
consideration. These factors are equal to the least common multiple
of a pair of sampling rates, divided by the respective rate of this
pair.
Figure 2: Sampling-rate conversion using an
up-sampler with factor M, a low-pass filter, and a down-sampler
with factor N
Conversion Rate
(ksamples/s)
|
Up-Sampling
Factor M
|
Down-Sampling
Factor N
|
Least Common
Multiple of a
Sampling Rate Pair
|
|
16 to 48
|
3
|
1
|
48000
|
|
32 to 48
|
3
|
2
|
96000
|
|
16 to 44.1
|
441
|
160
|
7056000
|
|
32 to 44.1
|
441
|
320
|
14112000
|
|
44.1 to 48
|
160
|
147
|
7056000
|
Table 1: Sampling rate conversion factors
Since the up- and down-sampling factors for the rate conversion
to/from 44.1 ksamples/s are too large, we accepted a slightly lower
sampling rate, 44 ksamples/s (Table 2). This introduces a small
error with a relative value of d =
0.22676% which, in most cases, is inaudible.
Conversion Rate
(ksamples/s)
|
Up-Sampling
Factor M
|
Down-Sampling
Factor N
|
Least Common
Multiple of a
Sampling Rate Pair
|
|
16 to 44
|
11
|
4
|
176000
|
|
32 to 44
|
11
|
8
|
352000
|
|
44 to 48
|
12
|
11
|
528000
|
Table 2: Sampling rate conversion to and from 44
ksamples/s
You can realize the filtering operation using an interpolator
and decimation by a low-pass filter with gain M and a normalized
cutoff frequency wc=min(p/M, p/N) .
You can design the respective FIR filter using
the Parks-McClellan algorithm (Figure 3). Table 3
presents the lengths of FIR filters and the numbers of effective
taps depending on the converted rates and the desired signal
resolution (16- or 20-bit word length, corresponding to the
stop-band attenuation of 96 or 120 dB, respectively).
Figure 3: Illustrative frequency responses of FIR
filters for two conversions: 32 to 48 ksamples/s and 32 to 44
ksamples/s
Conversion Rate
(ksamples/s)
|
Length L of FIR
Filter
|
Average Number of Calculated
Taps
L/(2M)
|
16-Bit
Resolution
|
20-Bit
Resolution
|
16-Bit
Resolution
|
20-Bit
Resolution
|
|
16 to 48
|
154
|
183
|
25.67
|
30.50
|
|
32 to 48
|
154
|
183
|
25.67
|
30.50
|
|
16 to 44
|
168
|
196
|
7.64
|
8.91
|
|
32 to 44
|
168
|
196
|
7.64
|
8.91
|
|
44 to 48
|
168
|
197
|
7
|
8.21
|
Table 3: Low-pass FIR filters
Interpolation in Time Domain
You can calculate the output signal of arbitrary sampling rate
using the time-domain approach. The following relationships
determine the output signal sample:
where Tin = ti+1 - ti input
sampling interval, Tout - output sampling interval,
ti - instant for a new output sample. These
relationships are illustrated in Figure 4.
Figure 4: Time relationship between input (red) and
output (blue) samples
One of the simplest time-domain sampling-rate conversion methods
consists of high oversampling and then choosing an appropriate
output sample with the nearest time position to the required
position. Figure 5 presents a multi-stage approach for this
high oversampling.
The time-analysis unit controls interpolators
with factors 64 and 128, which computes the appropriate sampling
instants. The main advantage of this approach (in comparison with
the considered frequency-domain method) is the possibility of using
the same filter coefficients for different sampling-rate ratios
and, thus, a simplified realization of the interpolation
filters.
Figure 5: Multistage oversampling and choosing the
output sample nearest to the required position in time
Time domain conversion can also be based on typical numerical
methods such as polynomial interpolation, Lagrange interpolation,
or spline interpolation.

In the case of an Nth-order spline with a
function defined in interval [xk,..., xk+m]
as
6th-order interpolation is used with simple FIR filter to
compensate sync7-distortion in the frequency domain
caused by the spline interpolator.
Data Managing
In our algorithm, input samples received from the HPI and output
samples transferred to the BSP (after conversion to Format 5 of the
CS4226 crystal converter) are organized in blocks of 16-bit samples
with length 60.
Figure 6 presents the sampling rate
conversion procedure.
Figure 6: The sampling-rate conversion procedure
consists of producing M data blocks from the received N data
blocks, where M and N are the up- and down-sampling factors,
respectively
The filter output is calculated only for these taps, for which
input samples are non-zero. Using FIRS instruction and indirect
addressing, the total number of multiplications is equal to L/(2M),
where L is the filter length (Table 2). Table 4
presents the time requirements for conversion to and from the
sampling rate of 48 ksamples/s, assuming 25 ns instruction cycles
and 16-bit precision. For 60 samples, the conversion procedure
needs 3180 cycles. From Table 4 we conclude that for 16-bit
precision, a single DSP can additionally compute an FFT, which
needs about 33,000 cycles for the 512-point FFT.
Number of
Converted Channels
|
Number of
Samples for
Each Channel
|
Number of
Instruction Cycles
Between Two Blocks
|
Use of CPU
by Conversion
Procedure (%)
|
|
2
|
30
|
24996
|
13
|
|
3
|
20
|
16664
|
19
|
|
4
|
15
|
12498
|
25
|
|
6
|
10
|
8333
|
38
|
Table 4: Time requirements during conversion to and
from 48 ksamples/s