TELLING THE SYSTEM ABOUT THE DATA
In order to retrieve the sound data for the audio channel, the system needs to know
where the data is located and how long (in words) the data is.
The location registers AUDxLCH and AUDxLCL contain the high three bits and the low
fifteen bits, respectively, of the starting address of the audio data. Since these two
register addresses are contiguous, writing a long word into AUDxLCH moves the audio
data address into both locations. The "x" in the register names stands for the number of
the audio channel where the output will occur. The channels are numbered 0, 1, 2,and 3.
These registers are location registers, as distinguished from pointer registers. You need to
specify the contents of these registers only once; no resetting is necessary when you wish
the audio channel to keep on repeating the same waveform. Each time the system
retrieves the last audio word from the data area, it uses the contents of these location
registers to again find the start of the data. Assuming the first word of data starts at
location "audiodata" and you are using channel 0, here is how to set the location
registers:
WHERE0DATA:
LEA CUSTOM,a0 ; Base chip address...
LEA AUDIODATA,a1
MOVE.L a1,AUDOLCH(a0) ;Put address (32 bits)
; into location register.
The length of the data is the number of samples in your waveform divided by 2, or the
number of words in the data set. Using the sample data set above, the length of the data
is 16 words. You write this length into the audio data length register for this channel. The
length register is called AUDxLEN, where "x" refers to the channel number. You set the
length register AUD0LEN to 16 as shown below.
SETAUDOLENGTH:
LEA CUSTOM,a0 ; Base chip address
MOVE.W #16,AUD0LEN(a0) ; Store the length...
SELECTING THE VOLUME
The volume you set here is the overall volume of all the sound coming from the audio
channel. The relative loudness of sounds, which will concern you when you combine
notes, is determined by the amplitude of the wave form. There is a six-bit volume register
for each audio channel. To control the volume of sound that will be output through the
selected audio channel, you write the desired value into the register AUDxVOL, where "x"
is replaced by the channel number. You can specify values from 64 to 0. These volume
values correspond to decibel levels. At the end of this chapter is a Table showing the
decibel value for each of the 65 volume levels.
- 136 Audio Hardware -