Prev Top Next
Name

KXL_PlaySound

Synopsis
KXL_PlaySound -- A sound is controlled.

Description
void KXL_PlaySound(Uint16 no, KXL_Command command);

Arguments

noThe number of a sound.
commandControl command
KXL_SOUND_PLAYplay of a sound.
KXL_SOUND_PLAY_LOOPrepetition play of a sound.
KXL_SOUND_STOPstop of a sound.
KXL_SOUND_STOP_ALLall stop of a sound.


Return Value

Nothing.


Exsample
sound1.wav
sound1.wav
sound1.wav

#include <KXL.h>

int main(void)
{
  Bool flag = False;
  Uint8 *wavlist[] = {
    "sound1", // The sound of No. 0
    "sound2", // The sound of No. 1
    "sound3", // The sound of No. 2
    ""        // Indispensable
  };

  KXL_CreateWindow(200, 100, "kxl.org",
		   KXL_EVENT_EXPOSURE_MASK |
		   KXL_EVENT_KEY_PRESS_MASK);
  KXL_InitSound(".", wavlist);

  while (flag == False) {
    while (KXL_CheckEvents() == False);  
    switch (KXL_GetEvents()) {
    case KXL_EVENT_EXPOSE:
      KXL_ClearFrameImm(0, 0, 200, 100);
      KXL_PutText(8, 20, "[1] - sound1");
      KXL_PutText(8, 40, "[2] - sound2");
      KXL_PutText(8, 60, "[3] - sound3");
      KXL_PutText(8, 99, "[4] - exit");
      KXL_UpDateImm(0, 0, 200, 100);
      break;;
    case KXL_EVENT_KEY_PRESS:
      switch (KXL_GetKey()) {
      case KXL_KEY_1:
	KXL_PlaySound(0, KXL_SOUND_PLAY);
	break;
      case KXL_KEY_2:
	KXL_PlaySound(1, KXL_SOUND_PLAY);
	break;
      case KXL_KEY_3:
	KXL_PlaySound(2, KXL_SOUND_PLAY);
	break;
      case KXL_KEY_4:
	flag = True;
	break;
      }
    }
  }
  KXL_EndSound();
  KXL_DeleteWindow();
  return 0;
}