KXL_InitSound -- A sound server is started. A wav file is read. It checks to see /dev/dsp is effective. The sampling rates of a wav file must be 8000Hz and a monophonic recording. A wav file is to 16 files.
void KXL_InitSound(Uint8 *path, Uint8 **filename);
| path | The path with which the wav file is placed. Ex. In the case of a current directory, it is ".". |
| filename | Arrangement which described the file name. |
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;
}