You must be prepared to discuss your work at the beginning of your laboratory session on Tuesday, December 2, and to demonstrate your program to your TA during that period. This part of the assignment is worth 25 points.
The volume of the signal, heard through the headphones was determined by the input values. That is, the waveform was not changed before being sent to the D/A converter. If the waveform samples are scaled in some way, made larger or smaller, the output volume will change.
To increase the volume of the signal, we must multiply the value of each sample by a number greater than 1; to decrease the volume, we must multiply the value of each sample by a number less than 1. Remember, however, that there are limits on the accuracy of the samples. An attempt to change the volume of the signal by a really large amount in either direction would simply result in random noise. Thus we want to multiply each sample by a value relatively close to 1, requiring that we deal with operands that are not integers.
We are used to using a rotating knob to control volume, and thus we would like to have the computer sense the motion of a shaft and use that motion to set the value of the multiplier. A shaft encoder is the appropriate device for this purpose.
The position of the radix point in the result of a fixed-point multiplication is determined by the assumed positions of the radix point in the two operands. If both operands are assumed to have their radix points at the right end, then the result will have its radix point at the right end. If both operands have their radix points at the left end, then the result will have its radix point at the left end. Suppose that one operand has m digits following its radix point, and the other operand has n digits following its radix point. The result will then have m+n digits following its radix point:
400 .400 4.00 .300 3.00 * 500 * .500 * 50.0 * .200 * 20.0 --- ---- ---- ---- ---- 200000 .200000 200.000 .060000 060.000
The MC68000 signed multiply instruction multiplies two 16-bit, 2's complement values to get a 32-bit, 2's complement result. We can make any assumptions that we wish about the position of the binary point in each of the operands, and then deduce the position of the binary point in the result. Suppose that we assume the binary point to be at the right end of the multiplicand, and assume that the multiplier is a positive number that has eight bits to the right of the binary point:
Now if the multiplicand is the value of a sample, expressed as a 16-bit, 2's complement value, and the multiplier is a value controlled by a shaft encoder, then the result is the ``volume controlled'' value of the sample. Because the sample is defined to be an integer, we discard the bits of the result labeled f.xxxxxxxxxxxxxxxx. * 0yyyyyyy.yyyyyyyy ----------------- zzzzzzzzzzzzzzzzzzzzzzzz.ffffffff
Each sample is an 8-bit value in the range 0-255. Since a sample value of 128 represents 0, we convert the sample value to a 16-bit, 2's complement value by first making it a 16-bit value in the range 0-255 and then subtracting 128. After multiplying and discarding the fractional part of the result, the value must be converted back to a sample by adding 128. If the result is greater than 255 it must be set to 255; if it is less than 0 it must be set to 0.
The shaft on the MB5 must control the volume of your headphone output. You must be able to both increase and decrease the volume. It must not be possible for the multiplier to become negative.
If a user types the character 1 on the HP keyboard, the volume
control's multiplier must be set to 1.
Pressing this key should not change the state of the sound storage
and playback program.
(This requirement conflicts with the
original specification.)
Questions
| Instructor | Revision 1.9 (2007/08/27 00:15:44) |