Specifications

SERIES 3/3A PROGRAMMING GUIDE
3-4
When to install and de-install the ldd file
Once
sndfrc.ldd
has been installed, it occupies about 1.7 K of RAM. For this reason, it would seem to be
best to de-install it, when the application terminates. The way to do this is to call (see the
Plib Reference
manual for more details)
p_devdel("MUS:",E_LDD);
This call will fail if another application currently has an open channel to
MUS:
. Applications should ignore
any errors from
p_devdel
.
Note however that if an application has:
called
p_loadldd
to ensure
MUS:
can be found
called
p_open
to open a channel to
MUS:
played some notes
called
p_close
to free up the sound channel
then it cannot rely on
MUS:
still being installed if it calls
p_open
again at a later stage. For another
application may have called
p_devdel
, successfully, in the meantime.
The upshot of this is that applications should call
p_loadldd
prior to
any
call to open a channel to
MUS:
.
Sound on the Series 3a
This section does not make reference to the recording and playing of digital sound - for details see the
General System Services
chapter of the
Plib Reference
manual.
The Series 3a's built-in
SND:
device driver can be used to simultaneously play two tunes on the built-in
speaker. Although the sound quality is not as high as with digital sound files, the memory requirements
are much less. For example to play a tune lasting six seconds would require a digital sound file of size
49,184 bytes. A comparable figure using the
SND:
device driver would be less than 1 Kb.
The demonstration program
sound.c
(in
\SIBOSDK\DEMO
on the supplied disks) plays two sequences of
notes using both channels of the built-in
SND:
sound device driver (only one application can have access to
these channels at any given time). The tune is the so-called "ice cream van" tune that you may already
have met in the
Sound
chapter of the
i/o Devices
manual - it is in any case recommended that you read
that chapter before proceeding.
The program demonstrates the following:
the opening and closing of a channel to the
SND:
device driver.
the sensing and setting of the volume level and the number of beats per minute.
the writing of notes to the two sound channels.
A number of points are worth making:
a side effect of opening a channel to the
SND:
device driver is to power up the speaker. As a
consequence the
SND:
channel should be closed as soon as the sound has been played - failure to
do so could unnecessarily drain the batteries.
the
SND:
device driver, and hence the speaker, can only be used by one application at a time. As
alarms and keyclicks will be disabled well written programs should close the
SND:
channel as
soon as the sound has been played.
a serious of notes separated by silences can be created by setting the frequency to zero during the
silent periods.
the sound will not play until a
P_FSSOUNDCHANNELn
request has been made on
both
channels. The
playing of sound on the two channels is thus automatically synchronised.
both
P_FSSOUNDCHANNELn
requests
must
be made asynchronously using
p_ioc
or the
p_ioc5
variant. On a low battery the request will fail to complete with an error message written to the
status word. Use of
p_iow
,
p_iow4
,
p_ioa
and/or
p_ioa5
would hang the machine on a low
battery - a very serious programming error.