28825 Parallax Inc, 28825 Datasheet - Page 7

MINI SOUND PLAYER SOUNDPAL

28825

Manufacturer Part Number
28825
Description
MINI SOUND PLAYER SOUNDPAL
Manufacturer
Parallax Inc
Datasheet

Specifications of 28825

Accessory Type
Sound Player
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
BASIC Stamp®
For Use With
28824 - SERVOPAL SERVO PULSER TIMER
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
To play a sequence in ROM or EEPROM, include the play command (defined in the template) in the
calling sequence followed by the sequence’s address. For example, to play the Reveille bugle call, you
would use the following PBASIC code:
SEROUT iopin, baud, ["=", play, reveille, 0, "!"]
The play command can be inserted anywhere a note can be used, and multiple play commands can be
included in any sequence. A sequence that is played can even play other sequences, just as subroutines
in PBASIC can call other subroutines. As with repeats, you have to be careful about such “nesting” of
sequence calls, though. Like repeats, each nested play pushes two bytes onto the SoundPAL’s stack.
So, again, it’s important to balance sequence length and nesting complexity to keep the stack from
encroaching on a sequence in the RAM buffer.
Global and Local Settings
When a sequence is played, the octave, tempo, and style settings extant before play is encountered are
saved and then restored when the played sequence returns. Therefore, it is not possible for a sequence
to influence the octave, tempo, or style of any sequence that calls it. It can only affect its own settings
and those of the sequences it plays, assuming those sequences do not change those settings for
themselves. The tempo, octave, and style settings are thereby considered “local” settings, in that they do
not influence anything outside their “scope”. The glissando rate, on the other hand, is a “global” setting.
It is not saved upon playing a sequence, nor restored when the played sequence returns. Any change to
the glissando rate will persist until it is set to another value.
Local settings are local within an entire sequence. If a setting gets changed inside a repeat block, it is
not automatically restored when the block encounters an again and gets repeated. Therefore, any
octave, tempo, or style setting that gets changed inside a repeat block should be initialized inside the
block at its beginning.
Serial Handshaking
When the SoundPAL is playing a sound sequence, it is not listening to commands coming through its I/O
pin (except for long reset pulses). This makes it impossible to start a new sequence while one is still
playing. However, it is possible to poll the SoundPAL so you can tell when a sequence has finished. This
is done using the enquiry command (?). When the SoundPAL is playing a sequence, it won’t see this
command at all. But as soon as it has finished, it will respond to an enquiry with a byte equal to 255 ($FF
hex), indicating that it’s ready for more commands. Here’s a subroutine that you can call that will wait for
the SoundPAL to finish playing a sequence:
'----Wait for the SoundPAL to finish playing----
WaitDone:
In the following example, random 32-note sequences are sent to the SoundPAL and played. The PBASIC
program waits for each sequence to finish before sending the next one.
© Parallax, Inc. • SoundPAL (2007.10.29)
SEROUT iopin, baud, ["?"]
SERIN iopin, baud, 2, Waitdone, [WAIT($FF)] 'Wait 2msec for reply; else try again.
RETURN
'Send an enquiry.
'Reply received: return.
Page 7 of 12

Related parts for 28825