Turbo Pascal Sound Generation
92 Bishop Drive
Framingham, MA 01701
SOUNDPAS.ARC demonstrates two ways to generate sounds using Turbo Pascal.
The simpler method uses tables to generate sound effects in real time.
The other method replaces the clock tick interrupt to handle sounds in
the background. This is also a good demonstration of Turbo Pascal
interrupts in general.
Turbo Pascal includes a Sound() function that allows simple tones to be
generated. With a little work, Sound() can be expanded to make sound
effects that are generated from simple tables. The first demonstration,
using the Pascal unit SOUNDEFF.PAS and the demo file DEMO1.PAS shows a
simple way to generate sounds from tables. Notice that execution of
the program stays in the sound generation procedure for the duration of
The second method uses an interrupt that is installed in place of the
normal clock tick interrupt. This allows a sound to be generated
without making the rest of the program stop. The table of sounds will
continue to be generated until the table ends even while the rest of
the program continues. This allows songs to be played while a program
is running for example. I use this method in my game EGATrek and I've left
in the sound tables that I use. There are two full songs plus a couple
of random sound effects. The demo program, DEMO2.PAS, just plays one
of the songs. Change the demo program around to hear the other sound
tables. The interrupt unit is called SOUNDER.PAS.
The units and demos have enough documentation in them that you should
be able to understand them if you're familiar with Turbo Pascal.
These routines are released to the public domain. However, if you do
use them I would like to hear from you about what you're doing with
them. I'd also be interested in any new sound effects that you come up
with. You can write me at the address on the top of this file, or
contact me on the Xevious BBS system (508-875-3618 or 617-449-7322,
use the FDBACK command). If you're connected to one of the minicomputer
nets (InterNet, uucp...) you can try reaching me at one of these addresses:
nja%[email protected] [email protected]