Specifications
3 ENHANCED SOUND OUTPUT
3-5
•
sound can be played on only one channel by passing the other channel a length of zero for the
note buffer - i.e. zero notes.
•
the
P_FSET
service sets
both
the volume and the beats per minute. The
P_FSENSE
service can
be requested first to ensure that one or other parameter remains unchanged.
To create a
sound.img
file simply type
make sound
in the appropriate directory. This file can then be
copied to a
m:\img
directory on the Series 3a and run via the RunImg application in the usual manner.
The code in
sound.c
is as follows:
#include <p_std.h>
#include <p_file.h>
#include <epoc.h>
GLDEF_C VOID waitstat2(WORD *pstat1, WORD *pstat2)
/* Wait for *pstat!=E_FILE_PENDING and *pstat2 != E_FILE_PENDING */
{
INT i;
i = -1;
do
{
p_iowait();
i++;
}
while (*pstat1 == E_FILE_PENDING && *pstat2 == E_FILE_PENDING);
if (*pstat2 == E_FILE_PENDING)
pstat1 = pstat2;
p_waitstat(pstat1);
while (i--)
p_iosignal();
}
GLDEF_C VOID play_notes(WORD *buf1, WORD *buf2, WORD l1, WORD l2, INT volume, INT
beatsPerMinute)
{
VOID *pcb;
WORD sndstat1,sndstat2;
E_SOUND sound;
INT err;
if ((err=p_open(&pcb,"SND:",-1))<0)
{
p_close(pcb);
p_exit(err);
}
if ((err=p_iow3(pcb,P_FSENSE,&sound))<0)
{
p_close(pcb);
p_exit(err);
}
if (beatsPerMinute >= 0)
sound.beatsPerMinute = (UBYTE) beatsPerMinute;
if (volume >= 0)
sound.volume = (UBYTE) volume;
if ((err=p_iow3(pcb,P_FSET,&sound))<0)
{
p_close(pcb);
p_exit(err);
}










