Added experimental makepkg-update-checksums.sh
[mirrors/Programs.git] / c / sdl-old / main.c
CommitLineData
8de51304
H
1#include <stdlib.h>\r
2#include <SDL.h>\r
3#include <SDL_mixer.h>\r
4\r
5const max_sounds=50;\r
6Mix_Chunk *sounds[max_sounds];\r
7Mix_Music *music;\r
8\r
9//kanaly\r
10enum {\r
11SNDT_0,\r
12SNDT_1,\r
13SNDT_2,\r
14SNDT_3,\r
15SNDT_4,\r
16SNDT_5,\r
17SNDT_6,\r
18SNDT_7\r
19};\r
20\r
21//zvuky\r
22enum {\r
23SND_ZVUK,\r
24SND_NUM\r
25};\r
26\r
27int main(int argc,char *argv[])\r
28{\r
29if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {\r
30 fprintf(stderr, "Problem: %s\n", SDL_GetError());\r
31 exit(1); \r
32}\r
33atexit(SDL_Quit);\r
34\r
35//frekvence 22050 Hz\r
36//MIX_DEFAULT_FORMAT - Signed 16-bit zvuky, v systemovem bytovem poradi (little,big endian)\r
37//mono-stereo: pro mono vlozte 1, pro stereo 2\r
38\r
39if (Mix_OpenAudio(22050/*frekvence [Hz]*/, MIX_DEFAULT_FORMAT, 2/*mono-stereo*/,1024/*velikost bloku*/)==-1)\r
40{\r
41 fprintf(stderr,"Mix_OpenAudio: %s\n", Mix_GetError());\r
42 exit(1);\r
43}\r
44\r
45 sounds[SND_ZVUK] = Mix_LoadWAV("zvuk.wav");\r
46if (sounds[SND_ZVUK]==NULL) \r
47{\r
48 fprintf(stderr,"zvuk [zvuk.wav] nebyl nahran\n");exit(2);}\r
49\r
50 //kanal: -1 pro prvni volny kanal\r
51//pocet opakovani x: zvuk se bude opakovat x+1 krat,x=-1 pro stale opakovani.\r
52Mix_PlayChannel(-1/*kanal*/,sounds[SND_ZVUK]/*Mix_Chunk*/,0/*pocet opakovani*/);\r
53\r
54 music=Mix_LoadMUS("music.mp3");\r
55if (!music) {\r
56 printf("Mix_LoadMUS(\"music.mp3\"): %s\n", Mix_GetError());\r
57 exit(2);\r
58}\r
59\r
60//pocet opakovani x: hudba se bude opakovat x krat,x=-1 pro stale opakovani.\r
61//postupne zvysuje hlasitost hudby od 0 do 100% za 2000 ms po spusteni\r
62\r
63Mix_FadeInMusic(music, -1/*pocet opakovani*/,2000 /*cas[ms]*/);\r
64\r
65//lze i jen provest pouhe spusteni hudby\r
66//Mix_PlayMusic(music, -1/*pocet opakovani*/);\r
67\r
68SDL_Delay(5000);\r
69\r
70 //ztlumi hudbu az do ticha a vypne\r
71Mix_FadeOutMusic(2000);\r
72\r
73SDL_Delay(1000);\r
74\r
75Mix_CloseAudio();\r
76return 0;\r
77}
This page took 0.479188 seconds and 4 git commands to generate.