Tutorial Details:
Difficulty Level:
Basic
Topics Covered: Playing
sounds using Mindscript.
Assumed Knowledge:
THe Basics, My
First Program
Written By: BILL LANE
BACK
Spybot's are capable of an incredible range of sounds. They
have 64 pre-programmed sounds that can be called by name or
number and room for an additional 16 user defined sounds (maximum
size 63 bytes each). We won't be looking at defining our own
sounds today. Instead we'll just look at making sounds and
using those 64 pre-programmed sounds.
Let's start with the pre-programmed sounds. If you take a
look in globals.h you'll find that someone has gone to the
trouble to provide names for each of the 64 sound sequences.
If you include global.h at the top of your program (you'll
need to include spybot.h as well) you'll be able to use these
names to refer to the different sequences. But for this example
I'm just going to use the numbers. So here's an example program:
program SoundFx {
main {
sound 42
wait 250
}
}
This will play sndBoost. Note the use of wait so we can actually
hear the sound before the program closes down. To play any
of the available sound sequences just replace 42 with the
relevant number download and enjoy. The numbers run from 0
to 63 and you can use -1 to stop the current sound. Too easy
really and I imagine you could create programs for the next
10 years without even thinking about making your own sequences.
But you can create and play your own sequences using tone.
All you need to use tone is to supply a frequency and a duration
(in that order). Here's how:
tone 440 for 5
wait 5
Repeat these two lines with variations in frequency and duration
and you and your Spybot can make beautiful music together.
The documentation provides the following chart to assist would
be composers. Which is all I have on this topic right now.
Keep an eye out for an intermediate tutorial on creating your
own sound sequences and the special effects available for
Spybot.
|