| 1 | <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=euc-jp"> |
| 5 | <meta name="GENERATOR" content="emacs"> |
| 6 | <meta name="Author" content="kacchan"> |
| 7 | <title>KXL_InitSound</title> |
| 8 | </head> |
| 9 | <body text="#000000" bgcolor="#f0f0dc" link="#3366FF" vlink="#3366FF" alink="#FF0000"> |
| 10 | |
| 11 | <a href="kxlgetbutton.html">Prev</a> |
| 12 | <a href="KXL.html">Top</a> |
| 13 | <a href="kxlplaysound.html">Next</a> |
| 14 | <hr> |
| 15 | |
| 16 | <b>Name</b><br><br> |
| 17 | <font size=+2>KXL_InitSound</font><br><br> |
| 18 | |
| 19 | <b>Synopsis</b><br> |
| 20 | <pre>KXL_InitSound -- A sound server is started. |
| 21 | A wav file is read. |
| 22 | It checks to see /dev/dsp is effective. |
| 23 | The sampling rates of a wav file must be 8000Hz and a monophonic |
| 24 | recording. |
| 25 | A wav file is to 16 files. |
| 26 | </pre><br> |
| 27 | |
| 28 | <b>Description</b><br> |
| 29 | <pre>void KXL_InitSound(Uint8 *path, Uint8 **filename);</pre><br> |
| 30 | |
| 31 | <b>Arguments</b><br><br> |
| 32 | <table border="1"> |
| 33 | <tr><td>path</td><td>The path with which the wav file is placed.<br> |
| 34 | Ex. In the case of a current directory, it is ".".</td></tr> |
| 35 | <tr><td>filename</td><td>Arrangement which described the file name.</td></tr> |
| 36 | </table> |
| 37 | <br><br> |
| 38 | |
| 39 | <b>Return Value</b><br><br> |
| 40 | Nothing. |
| 41 | <br><br><br> |
| 42 | |
| 43 | <b>Exsample</b><br> |
| 44 | <pre> |
| 45 | <a href="./sound1.wav">sound1.wav</a> |
| 46 | <a href="./sound2.wav">sound1.wav</a> |
| 47 | <a href="./sound3.wav">sound1.wav</a> |
| 48 | |
| 49 | #include <KXL.h> |
| 50 | |
| 51 | int main(void) |
| 52 | { |
| 53 | Bool flag = False; |
| 54 | <b>Uint8 *wavlist[] = { |
| 55 | "sound1", // The sound of No. 0 |
| 56 | "sound2", // The sound of No. 1 |
| 57 | "sound3", // The sound of No. 2 |
| 58 | "" // Indispensable |
| 59 | };</b> |
| 60 | |
| 61 | KXL_CreateWindow(200, 100, "kxl.org", |
| 62 | KXL_EVENT_EXPOSURE_MASK | |
| 63 | KXL_EVENT_KEY_PRESS_MASK); |
| 64 | <b>KXL_InitSound(".", wavlist);</b> |
| 65 | |
| 66 | while (flag == False) { |
| 67 | while (KXL_CheckEvents() == False); |
| 68 | switch (KXL_GetEvents()) { |
| 69 | case KXL_EVENT_EXPOSE: |
| 70 | KXL_ClearFrameImm(0, 0, 200, 100); |
| 71 | KXL_PutText(8, 20, "[1] - sound1"); |
| 72 | KXL_PutText(8, 40, "[2] - sound2"); |
| 73 | KXL_PutText(8, 60, "[3] - sound3"); |
| 74 | KXL_PutText(8, 99, "[4] - exit"); |
| 75 | KXL_UpDateImm(0, 0, 200, 100); |
| 76 | break;; |
| 77 | case KXL_EVENT_KEY_PRESS: |
| 78 | switch (KXL_GetKey()) { |
| 79 | case KXL_KEY_1: |
| 80 | KXL_PlaySound(0, KXL_SOUND_PLAY); |
| 81 | break; |
| 82 | case KXL_KEY_2: |
| 83 | KXL_PlaySound(1, KXL_SOUND_PLAY); |
| 84 | break; |
| 85 | case KXL_KEY_3: |
| 86 | KXL_PlaySound(2, KXL_SOUND_PLAY); |
| 87 | break; |
| 88 | case KXL_KEY_4: |
| 89 | flag = True; |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | KXL_EndSound(); |
| 95 | KXL_DeleteWindow(); |
| 96 | return 0; |
| 97 | } |
| 98 | </pre> |
| 99 | |
| 100 | </body> |
| 101 | </html> |