22.09.2015 Views

of Microprocessors

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

524 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

Using the table for interpolation is really quite simple. First we will<br />

restrict the unknown point to be within one-half <strong>of</strong> a sample period, either<br />

side, <strong>of</strong> the middle tabulated point as shown in Fig. 14-32. This middle<br />

point will be designated So while those on the left are numbered S- 1, S- 2,<br />

etc., and conversely for those on the right. Next, the position <strong>of</strong> the unknown<br />

point with respect to the central point will be expressed to the nearest<br />

1/32 <strong>of</strong> a sample interval and will be called A. Thus, in the example, A will<br />

always be between -16/32 and + 15/32 inclusive. To compute the unknown<br />

sample value, one simply iterates i through the 13 tabulated points from -6<br />

through +6 multiplying each point value by the contents <strong>of</strong> the table at A +i<br />

and adding up the products. The sum is the interpolated value! When<br />

looking into the table the sign <strong>of</strong> the argument is ignored, which implements<br />

the symmetry. If the argument is greater than 6 or less than -6, zero<br />

should be returned.<br />

Note that the location <strong>of</strong> the unknown point is quantized to 1/32 <strong>of</strong> a<br />

sampling interval. Abiding by this restriction limits the variety <strong>of</strong> samplerate<br />

ratios. One could reduce this restriction by increasing the size <strong>of</strong> the<br />

table or by linear interpolation in the table, which is now allowable because<br />

the tabulated function is densely sampled. One could also apply the table to<br />

compute two interpolated samples, one on either side <strong>of</strong> the arbitrary unknown<br />

sample and linearly interpolate between them, thus reducing interpolation<br />

effort. This is permissible because now the waveform is grossly oversampled<br />

(by a factor <strong>of</strong> 32 in the example) and linear interpolation will not<br />

add nearly as much noise as before. The two methods are in fact exactly<br />

equivalent but the second only requires one linear interpolation rather than<br />

13.<br />

Actually writing a sample-rate-conversion program is somewhat tricky<br />

because both "future" and "past" input samples are needed and because <strong>of</strong> the<br />

different input and output sample rates. The problem is generally solved by<br />

using an input buffer, an output buffer, and a simulated shift register for the<br />

samples used in the interpolation. The routine would also accept a sample<br />

rate ratio, R, which would be a mixed number either greater than or less than<br />

unity.<br />

In practice, the routine would initially be given a full input buffer, an<br />

empty output buffer, and a shift register full <strong>of</strong> zeroes. It would also keep<br />

track <strong>of</strong>a time variable, A , which corresponds to the A used in the interpolation<br />

example and which is constrained to the range <strong>of</strong> - o. 5 to +o. 5. To<br />

generate the next output sample, R is added to A. If the sum is between<br />

-0.5 and +0.5, an interpolation is performed and the computed sample is<br />

put into the output buffer. If the sum is greater than +0.5, the shift<br />

register is shifted one position, the next input sample is taken from the input<br />

buffer and put into the vacant shift register slot, and 1.0 is subtracted ftom<br />

A. This is repeated if necessary until A is less than +0.5, at which point an<br />

interpolation is performed generating another output sample and so forth.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!