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.

DIGITAL TONE GENERATION TECHNIQUES 453<br />

each other. This is important because the actual number <strong>of</strong> multiplications<br />

required to evaluate the node pair can then be cut in half.<br />

After the first column <strong>of</strong> nodes has been processed, everything is back<br />

in storage in a partially transformed state, and processing <strong>of</strong> the next column<br />

<strong>of</strong> nodes can begin. When the rightmost column has been evaluated, the<br />

array contains the N complex harmonics. Note that for the first column the<br />

nodes that should be paired for calculation are adjacent. In the next column,<br />

the pair members are two apart, in the third column four apart, and so forth.<br />

Also note that the mass <strong>of</strong> crossing lines forms a group <strong>of</strong> two nodes in the<br />

first column, four nodes in the next column and so forth until there is only<br />

one mass in the final column. These and other symmetries discovered by<br />

examining the diagram should make the progression sufficiently clear so that<br />

generalization for other values <strong>of</strong>N can be understood. Since the progression<br />

is consistent from column to column, it is clear that a general FFT subroutine<br />

can be written for any value <strong>of</strong> N that is a power <strong>of</strong> two.<br />

Table 13-1 shows the actual sequence <strong>of</strong> intermediate results corresponding<br />

to the diagram. The example time samples are <strong>of</strong> a seven-harmonic<br />

approximation to a sawtooth wave with a few degrees <strong>of</strong> phase shift included<br />

to make life interesting. Note that the spectrum output starts with the dc<br />

component in the zero array position, fundamental in position 1, etc. up to<br />

the seventh harmonic in position 7. The Nyquist component is in position 8<br />

(the sine part is always zero), while higher array positions contain the first<br />

through the seventh harmonics again but in descending sequence and with<br />

the sign <strong>of</strong> the imaginary components (sines) flipped. Also note that the<br />

correct amplitudes <strong>of</strong> the frequency components have been multiplied by N/2<br />

except for the dc component, which is N times too large.<br />

An FFT Subroutine in BASIC<br />

Figure 13-17 is an FFT program written in BASIC. Although BASIC<br />

and fast are contradictory terms, the program serves to illustrate the algorithm<br />

and to allow the reader to become familiar with it. The array <strong>of</strong><br />

complex input samples is actually stored and handled as two arrays <strong>of</strong> normal<br />

numbers; D 1 being the real part and D2 being the imaginary part. Note that<br />

the array subscript starts at zero. When the transformation is complete, the<br />

spectrum is stored in the same two arrays. To insure that N is a power <strong>of</strong> two,<br />

the record size is specified by K, which is 10gzN and must be a positive<br />

integer.<br />

In the program itself, statements 3110 to 3125 scramble the naturally<br />

ordered time samples into bit-reversed order using the method illustrated<br />

earlier. N3 being the "for" loop index counts naturally from 1 to N. Nl in<br />

conjunction with statements 3114 to 3117 acts like a bit-reversed counter<br />

taking on successive values <strong>of</strong> 0, 8, 4, 12, 2, etc. (for the N= 16 case).<br />

Whenever N 1 is greater than N3, the samples pointed to by N 1 and N3 are<br />

swapped.

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

Saved successfully!

Ooh no, something went wrong!