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 457<br />

derived from the de term in the complex spectrum according to the "/'<br />

function. Next the pairs <strong>of</strong> harmonics that would have been conjugates if the<br />

even-odd storage arrangement were not done are combined according to the<br />

"g" function to produce a pair <strong>of</strong> real harmonics. Finally, the "h" function is<br />

applied to the remaining N/2th spectral component. Note that cosines and<br />

sines <strong>of</strong> angle increments half the size <strong>of</strong> the smallest increment used in the<br />

FFT are utilized in evaluating g much like an extra step in the FFT. In fact,<br />

the whole procedure can be regarded as an extra column <strong>of</strong> nodes in the FFT<br />

algorithm.<br />

Figures 13-19 and 13-20 are BASIC subroutines for complex-to-real<br />

and real-to-complex conversion, respectively. The complex-to-real routine<br />

also scales the spectrum output so that all <strong>of</strong> the harmonics, including the de<br />

component, are <strong>of</strong> the correct amplitude. Except for scaling, the real-tocomplex<br />

routine undoes what the complex-to-real routine does.<br />

The conversion adds essentially 2N multiplications to the FFT, which<br />

gives a total <strong>of</strong> 2N+2NlogzN for 2N data points. IfM = 2N = the number<br />

<strong>of</strong> real data points, this is equal to MlogzM multiplications, which is the<br />

4000 REM COMPLEX TO REAL TRANSFORMATION FOR FOURIER TRANSFORM<br />

4001 REM IF REAL DATA POINTS ARE ALTERNATELY STORED IN D1 AND 02<br />

4002 REM ARRAYS, I.E. TO->01(0), T1->02(0), T2->01(I), T3->02(1),<br />

4003 REM THEN THIS ROUTINE CONVERTS THE COMPLEX SPECTRUM INTO A<br />

4004 REM REAL COSINE-SINE SPECTRUM.<br />

4005 REM THE ROUTINE ALSO DOES AMPLITUDE CORRECTION ON THE DC<br />

4006 REM COMPONENT AND THE HARMONICS SO THAT THE FINAL SPECTRUM OUTPUT<br />

4007 REM IS THE TRUE SPECTRUM OF THE WAVE.<br />

4008 REM THE SINE PART OF THE DC COMPONENT IS SET EQUAL TO THE NYQUIST<br />

4009 REM COMPONENT AND SHOULD BE NEAR ZERO IF THE SAMPLE RATE OF THE<br />

4010 REM DATA WAS ADEQUATE.<br />

4011 REM THIS ROUTINE USES THE SAME INPUT AS THE FFT ROUTINE<br />

4100 N=2**K<br />

4200 REM COMPUTE DC AND FOLDOVER COMP6NENTS<br />

4201 Tl=D1(0)<br />

4202 T2=D2(0)<br />

4203 D1(0)=(T1+T2)/(2*N)<br />

4204 D2(0)=(T1-T2)/(2*N)<br />

4300 REM COMPUTE REMAINDER OF FREQUENCY COMPONENTS<br />

4301 FOR N1=1 TO N/2<br />

4302 N2=N-N1<br />

4303 C=COS(-3.1415927*N1/N)<br />

4304 S=SIN(-3.1415927*N1/N)<br />

4305 T1=(D1(N1)+01(N2))/2<br />

4306 T2=(D1(N1)-D1(N2))/2<br />

4307 T3=(D2(N1)+D2(N2))/2<br />

4308 T4=(D2(N1)-D2(N2))/2<br />

4309 T5=T2*S-T3*C<br />

4310 T6=T2*C+T3*S<br />

4311 D1(N1)=(T1-T5)/N<br />

4312 D1(N2)=(T1+T5)/N<br />

4313 D2(N1)=(T4-T6)/N<br />

4314 D2(N2)=(-T4-T6)/N<br />

4315 NEXT N1<br />

4316 RETURN<br />

Fig. 13-19. Complex-to-real spectrum transformation routine in BASIC

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

Saved successfully!

Ooh no, something went wrong!