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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DIGITAL TONE GENERATION TECHNIQUES 441<br />

phase, the average is proportional to the cosine <strong>of</strong> the phase difference.<br />

Fortunately, this procedure works even when one <strong>of</strong> the signals has many<br />

frequency components; if one component matches it will contribute a de<br />

component to the product samples. Thus, by using two "probe" waves 90°<br />

apart in phase at all <strong>of</strong> the possible harmonic frequencies <strong>of</strong> the data record,<br />

one may determine its complete harmonic amplitude and phase makeup.<br />

The program segment below, which is remarkably similar to the inverse<br />

transform segment, performs discrete Fourier analysis. The C, S, and T<br />

arrays and N are as before and C and S are assumed to be initially zeroes.<br />

1000 FOR 1=0 TO N-l<br />

1001 FOR ]=0 TO N/2-1<br />

1002 LET CO)=CO)+T(l)*COS(3.14159*I*]/N)/(N/2)<br />

1003 LET SO)=SO)+T(I)*SIN(3.14159*I*]/N)/(N/2)<br />

1004 NEXT]<br />

1005 NEXT I<br />

The outer loop in this case scans the time waveform, while the inner loop<br />

accumulates running averages <strong>of</strong> cosine and sine components <strong>of</strong> each harmonic.<br />

Note that the Nyquist frequency component is not computed. Therefore,<br />

if one transforms arbitrary random data and then transforms it back, the<br />

result will not be exactly equivalent. However, practical, unaliased data will<br />

be returned with only a slight round<strong>of</strong>f error. Note also that in both <strong>of</strong> these<br />

program segments that the inner and outer loops may be interchanged with<br />

no real effect on the results.<br />

Fast Fourier Transform<br />

Examination <strong>of</strong> the preceding two program segments reveals that N2<br />

useful multiplications and additions are required for the transformation. Useful<br />

is emphasized because a well-thought-out assembly language implementation<br />

<strong>of</strong> the programs could eliminate multiplications within the cosine and<br />

sine arguments by proper indexing through a sine table. Likewise, subscript<br />

calculations can be eliminated by use <strong>of</strong> index registers. The division by N/2<br />

in the forward transform may still be required, but it can be deferred until<br />

the computation is completed and then need only be a shift if the record size<br />

is a power <strong>of</strong> two. In the case <strong>of</strong> the inverse transform, the number <strong>of</strong><br />

multiplications may be cut in half by using the amplitude-phase form for the<br />

harmonics rather than cosine-sine.<br />

Even with the world's most efficient assembly language program, a<br />

tremendous amount <strong>of</strong> computation is needed for even a moderate number <strong>of</strong><br />

samples. For example, 20-msec blocks taken at a 25 ks/s sample rate would<br />

be 500 samples that, when squared, implies about a quarter <strong>of</strong> a million<br />

operations for the transform. Upping the sample rate to 50 ks/s quadruples<br />

the work ro a million operations. An efficient assembly language program on

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

Saved successfully!

Ooh no, something went wrong!