> From: Ng Wei Gee
>
> SndCommandType snd;
>
> snd.cmd = sndCmdFrqOn;
> snd.param1 = 2400;
> snd.param2 = 150;
> snd.param3 = sndMaxAmp;
> SndDoCmd(NULL, &snd, false);
>
> snd.cmd = sndCmdFrqOn;
> snd.param1 = 1500;
> snd.param2 = 100;
> snd.param3 = sndMaxAmp;
> SndDoCmd(NULL, &snd, false);
>
> ...
When you use sndCmdFrqOn, the meanings of the parameters are not what you
seem to expect. (You probably meant to use sndCmdFreqDurationAmp.) For
sndCmdFrqOn:
param1 = MIDI key index (0-127)
param2 = maximum duration in milliseconds
param3 = velocity (0 to 127) to be interpolated as amplitude
Also, it will play the sound and return immediately, without waiting for
playback to complete. Any other sound play
request made before this one completes will interrupt it. (So you only hear
1 note.)
To do what I think you are trying to do, I use this:
static void PlaySound( Int32 hz, UInt16 ms, UInt16 amp )
{
Err err;
SndCommandType sndcmd;
sndcmd.cmd = sndCmdFreqDurationAmp;
sndcmd.param1 = hz;
sndcmd.param2 = ms;
sndcmd.param3 = amp;
err = SndDoCmd( NULL, &sndcmd, 0 );
}
Or, to play stacatto notes, I might use:
static void PlayChoppySound(Long hz, UInt ms, UInt amp)
{
Err err;
SndCommandType sndcmd;
sndcmd.cmd = sndCmdFreqDurationAmp;
sndcmd.param1 = hz;
sndcmd.param2 = ms;
sndcmd.param3 = amp;
err = SndDoCmd(NULL, &sndcmd, 0); // play the note
sndcmd.param2 = 50;
sndcmd.param3 = 5;
err = SndDoCmd(NULL, &sndcmd, 0); // pause (play real quiet) briefly
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/