home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
demo
/
dosound
/
thechip.lst
< prev
next >
Wrap
File List
|
1992-03-26
|
9KB
|
176 lines
The Sound Chip:
The Atari ST computers use a fairly common programmable sound chip. There
are three tone channels which can play simultaneously or independently.
The range of frequencies available are from 30Hz to 125,000Hz. This range
far exceeds the limits of the ST's speaker as well as the human ear (middle
C has a frequency of 261.6Hz). The desired frequencies must be passed to
the sound chip as a 12 bit period value. This value is derived from the
formula:
period = 125,000 / frequency (in Hz)
Therefore, to hear a middle C tone, a period value of 478 is needed
(478 = 125,000 / 261.6).
The first step to sounding a tone is to pass the period value to the
appropriate sound chip registers. They are as follows:
Register Bits Description
0 0-7 Low byte of tone period for Channel A
1 0-3 High nibble of tone period for Channel A
2 0-7 Low byte of tone period for Channel B
3 0-3 High nibble of tone period for Channel B
4 0-7 Low byte of tone period for Channel C
5 0-3 High nibble of tone period for Channel C
Notice that since the sound chip registers are byte sized, and the tone
period may be 12 bits (a value of 0 to 4096), 2 registers are needed to
store the tone period for each channel. To hear the tone of middle C on
channel A, register 0 would be loaded with the value of 222 (the lower byte
of 478) and register 1 would be loaded with a value of 256 (the high nibble
of 478).
The sound chip also has a register which controls a static type sound.
Any or all of the tone channels may be connected to this register, in which
case the static will sound when that channel is enabled for noise (see
below) and its volume is set to a value greater than 0.
Register Bits Description
6 0-4 Noise period
The range of values for this register are 0-31. A value of 0 creates a
static type sound similar to a snare drum while a higher value deepens the
sound to the point of sounding like rushing wind.
The next step to sounding a tone is to enable the appropriate channels
for sound and or noise. This is accomplished by setting the appropriate
bits in register 7 as follows:
Register Bits Description
7 0 Enabling for Channel A tone.
7 1 Enabling for Channel B tone.
7 2 Enabling for Channel C tone.
7 3 Enabling for Channel A noise.
7 4 Enabling for Channel B noise.
7 5 Enabling for Channel C noise.
7 6 Enabling for Channel A I/O.
7 7 Enabling for Channel B I/O.
A value of 0 in the desired bit will enable its function, while a value
of 1 (bit is set) will disable its function. Therefore, to enable all
channels for tone but not for noise requires a value of 56 to be passed to
register 7. Notice that bits 6 and 7 control the data flow for the ST's
two I/O ports and have nothing to do with sound functions. Because of this,
it is important not to change the settings of these bits or else you may
loose communication with your floppy drives. The correct way to write to
this register is to first read its value in and then OR its current value
with your desired value for bits 0-5.
The last step to hear a tone is to set the volume. There are 3 registers
which control the volumes for each of the three channels as follows:
Register Bits Description
8 0-4 Volume for Channel A
9 0-4 Volume for Channel B
10 0-4 Volume for Channel C
Since there are four bits for the volume, there is a range of 0-31 for
its value. However, when bit 4 is set in the volume register, the values
in bits 0-3 are ignored. Volumes of 0-15 will sound as a constant tone
(0 being off, 15 being the loudest), while a volume of 16 (bit 4 set) means
to use the wave envelope and the wave period as they are set in registers
11-13 to control the volume.
The wave period determines how many cycles of the wave envelope should
occur in one second. The range of values for this parameter are from 0 to
65535. The lower the value, the faster the wave envelope will cycle.
The higher the value, the slower the wave envelope will cycle.
Register Bits Description
11 0-7 Low byte of the wave period.
12 0-7 High byte of the wave period.
The eight wave envelopes are as follows:
Value Shape Description
8 \|\|\|\|\ From max volume to 0, instant to max, cycle
9 \________ From max volume to 0 and hold at 0
10 \/\/\/\/\ From max volume to 0, gradual back to max, cycle
11 \|------- From max volume to 0, instant to max and hold
12 /|/|/|/|/ From 0 volume to max, instant to 0, cycle
13 /-------- From 0 volume to max and hold at max
14 /\/\/\/\/ From 0 volume to max, gradual back to 0,cycle
15 /|_______ From 0 volume to max, instant to 0 and hold
Note that some of the wave envelopes cycle through their shapes while
others terminate at a volume of 0 or 15. To hear a tone with one of the
wave envelopes, first place the value of the desired wave envelope in
register 13, then set the wave period in registers 11 and 12, and finally
set the volume to 16.
The best way to experiment with these registers is via the DoEffect
program. In this program, all of the sound chip registers are presented
on one screen. The various values can be changed quickly and easily and
the results can be heard right away.
Limitations of the Sound Chip:
While quite capable of playing some very interesting music, the Sound
Chip does suffer from several limitations. From the above descriptions of
the various registers, some of these may be fairly obvious. For starters,
only 3 notes can be played at any one time. Second, the noise period
applies to all channels enabled for noise (each channel cannot have a
different noise period at any given time). Thirdly, the wave envelopes
come in standard pre-defined shapes and cannot be altered. Lastly, all
channels that use a wave envelope must use the same wave envelope. Other
less significant limitations exist, but do not become apparent until they
are experimented with.
For example, let us consider two notes that we intend to play using wave
envelope number 9. This envelope is particularly interesting because it
follows a pattern similar to most musical instruments. Initially the
volume is at its maximum value and slowly decays to a value of 0. We can
control how fast the volume decreases by adjusting the wave period
accordingly. Now in our example, the first note to sound is a whole note.
After a half note rest, we want another tone to begin sounding. Since the
first note is still active, and the wave form is starting to decay, when
we attempt to sound the second note, its volume will follow the wave
envelope which is already in progress and at a value less than maximum
volume. If the wave period was set to a relatively fast value, we may not
hear the second note at all since the wave envelope would be near or at a
volume of 0. This particular wave envelope (like some of the others) does
not cycle but rather sustains at its final value (0 in this case). In
order to cause additional notes to be heard with this wave envelope,
register 13 must be re-loaded with the value of this envelope (in this
case 9) each time you wish for the cycle of the envelope to start again.
Doing this however, has one side effect. Each note that is currently being
played will have its volume reset to the new value of the wave envelope.
So in our example, if before the second note is played we put the wave
envelope back into register 13, what we will actually hear is a half note
of the first tone, followed by a half note of the first and second tone.
There is an option within the DoSound program to control whether or not
you want the wave envelope to be placed back into register 13 whenever a
new note is encountered. This feature is provided by measures. If you
elect not to insert the wave for each note within the measure(s) in
question, and you are using a wave envelope that terminates at a value of
0 or 15, a large wave period may be in order. This will cause the wave
envelope to last longer over the measure(s). Obviously this particular
problem is not evident with the wave envelopes that repeat their patterns.
Additionally, it is worth noting that a complete song that requires many
registers 13 messages will require larger files than those that do not.
However, the sound quality provided by these particular waves, far out
weights the additional file lengths.
Another method which has been provided within the DoSound program to
control these wave envelope message is within the volume dialog box.
Often it is not necessary for very short notes to make use of the wave
envelopes. Therefore an option has been provided that will change the
volumes of all notes less than a specific length to a specific volume.
A common use of this feature would be to change all notes less than 13
clicks (an eighth note or shorter) to a volume of 14 or 15. When this
is done, these notes will not interfere with longer notes which are making
use of a wave envelope.