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.

672 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

temporary storage is in the machine registers (a big advantage <strong>of</strong> the 68000)<br />

and the stack, the routine could even be put into ROM if desired.<br />

In general, the subroutine is a literal translation <strong>of</strong> the BASIC program<br />

<strong>of</strong> Fig. 13-17. However, the first portion, in which the data arrays are<br />

scrambled into bit-reversed order, has been redone. Although the algorithm<br />

used in the BASIC version is reasonably efficient for a high-level language<br />

implementation, using bit manipulation instructions is much faster in<br />

assembly language. Essentially, two counters are incremented from 0 to N-l,<br />

one normal and one bit-reversed, and the corresponding array elements are<br />

swapped whenever the bit-reversed counter is larger.<br />

The second portion is reasonably straightforward except when multiplication<br />

by a sine or cosine is performed. What is actually needed is a 16-bit<br />

unsigned X 32-bit signed multiply to yield a 48-bit signed product,<br />

whereas the 68000 only provides 16 X 16-bit multiplies where both<br />

operands are either signed or unsigned. The desired result is achieved in the<br />

TRGMPY subroutine by treating the 32-bit signed multiplicand as an<br />

unsigned value, performing a 32 X 16-bit unsigned multiply using two <strong>of</strong><br />

the 16 X 16-bit machine instructions, and then correcting the product by<br />

subtracting the unsigned multiplier from the most significant 16 bits <strong>of</strong> the<br />

48-bit product if the multiplicand was negative. This routine also bypasses<br />

multiplication completely when the multiplier is zero or unity. If an inverse<br />

transform is required, the instruction in line 106 can be changed to a BSET<br />

instruction, which has the effect <strong>of</strong> negating the SIN multipliers.<br />

For efficient transformation <strong>of</strong> real data, a complex-to-real transform<br />

routine can be coded using these same techniques and the BASIC version in<br />

Fig. 13-19 as a guide. Note that the complex-to-real transform uses cosine<br />

and sine angle increments half the size <strong>of</strong> the corresponding complex FFT.<br />

Thus, to acrually transform 4096 real points using a 2048-point complex<br />

transform, either the cosine table will have to be made twice as large (and the<br />

given subroutine slightly modified to accommodate it), or the complex-toreal<br />

routine will have to interpolate in the given table. Of course, this<br />

problem does not arise for smaller transforms.<br />

As coded, this subroutine gives results as accurate as 16-bit input data<br />

allow. For many analysis tasks, particularly those in which the final result is a<br />

plot or display, less accuracy is needed. This routine (and a companion<br />

complex-to-real routine) could in fact be rewritten for the 12-bir data and<br />

multipliers, which would probably increase the speed two to three times for<br />

transform sizes up to 256 points. Real-time analysis <strong>of</strong> speech bandwidth<br />

data then would be possible even on an 8-MHz 68000.<br />

NOTRAN Music System<br />

After coming this far, it is about time to see how the various synthesis<br />

and processing techniques can be put together to form a usable music

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

Saved successfully!

Ooh no, something went wrong!