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.

458 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

5000 REM REAL TO COMPLEX TRANSFORMATION FOR INVERSE FOURIER TRANSFORM.<br />

5001 REM THIS ROUTINE CONVERTS A REAL COSINE-SINE SPECTRUM INTO A<br />

5002 REM COMPLEX SPECTRUM THAT WHEN INVERSE FOURIER TRANSFORMED WILL<br />

5003 REM PRODUCE REAL DATA POINTS STORED SUCH THAT EVEN NUMBERED<br />

5004 REM POINTS ARE IN THE REAL PART OF THE DATA ARRAY AND ODD<br />

5005 REM NUMBERED POINTS ARE IN THE IMAGINARY PART OF THE ARRAY.<br />

5006 REM THIS ROUTINE IS THE INVERSE OF THE COMPLEX TO REAL ROUTINE<br />

5007 REM EXCEPT FOR SCALING WHICH HAS BEEN SET FOR THE PROPER OUTPUT.<br />

5008 REM THIS ROUTINE FOLLOWED BY AN INVERSE FOURIER TRANSFORM IS THE<br />

5009 REM EXACT INVERSE OF A FORWARD FOURIER TRANSFORM FOLLOWED BY THE<br />

5010 REM COMPLEX TO REAL ROUTINE.<br />

5011 REM THIS ROUTINE USES THE SAME INPUT AS THE FfT ROUTINE<br />

5100 N=2**K<br />

5200 REM RESTORE DC AND FOLDOVER COMPONENTS<br />

5201 Tl=D1(0)<br />

5202 T2=02(0}<br />

5203 01(O}=T1+T2<br />

5204 D2(O}=T1-T.2<br />

5300 REM COMPUTE REMAINDER OF FREQUENCY COMPONENTS<br />

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

5302 N2=N-N1<br />

5303 C1=COS(-3.1415927*Nl/N}<br />

5304 Sl=SIN(-3.1415927*N1/N}<br />

5305 T1=(Ol(N1)+D1(N2}}/2<br />

53Q6 T4=(D2(N1}-02(N2})/2<br />

5307 T5=(D1(N2)-D1(N1}}/2<br />

5308 T6=( -02 (N1) -02 (N2) )/2<br />

5309 T2=T5*Sl+T6*C1<br />

5310 T3=T6*Sl-T5*C1<br />

5311 D1(N1}=T1+T2<br />

5312 01(N2}=T1-T2<br />

5313 D2(N1}=T3+T4<br />

5314 D2(N2)=T3-T4<br />

5315 NEXT N1<br />

5316 RETURN<br />

Fig. 13-20. Real-to-complex spectrum conversion routine in BASIC<br />

promised value. With clever programming to avoid multiplication by zero<br />

and one in the FFT and real conversion routines (especially in the first<br />

column <strong>of</strong> the FFT), one can ultimately reach a lower limit <strong>of</strong><br />

M[(logzM)-2] multiplications, which is a significant reduction when Mis<br />

small.<br />

Using the FFT for Synthesis<br />

Although the greatest value <strong>of</strong> the FFT is in sound analysis and modification,<br />

it is covered in this chapter because it is also a powerful "synthesisfrom-scratch"<br />

technique. Unfortunately, its record-oriented properties complicate<br />

application to changing spectra with arbitrary frequency components.<br />

However, if the required spectral detail is great, the FFT can be much more<br />

efficient in computing samples than a direct Fourier series evaluation in spite<br />

<strong>of</strong> these complications.<br />

In all FFT-based synthesis procedures, the general idea is to compute a<br />

sequence <strong>of</strong> sample records using the FFT and then combine them sequen-

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

Saved successfully!

Ooh no, something went wrong!