¡Ä¡Ä¤Ç¡¤¤³¤Î¤Þ¤Þ¤À¤È¤É¤¦¤ß¤Æ¤â¡¤Æ±»þ¤ËÌĤ餹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó
¥Á¥ã¥ó¥Í¥ë¤ò»ØÄꤹ¤ëºÆÀ¸ÊýË¡¤¬¤¢¤Ã¤¿¤Î¤Ç¡¤»î¤·¤Æ¤ß¤¿
#include <SDL.h>
#include <SDL_mixer.h> //SDL_mixer¥Ø¥Ã¥À
int main(int args,char *argp[]){
SDL_Surface *screen;
SDL_Event event;
//½é´ü²½
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0){
return -1;
}
screen=SDL_SetVideoMode(854,480,32,SDL_HWSURFACE);
if(screen == NULL){
SDL_Quit();
return -1;
}
//SDL_mixer:¥é¥¤¥Ö¥é¥ê³«»Ï
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);
//SDL_mixer:ÊÑ¿ôÄêµÁ
Mix_Chunk *music;
Mix_Chunk *music2;
int channel;
int channel2;
//SDL_mixer:¥µ¥¦¥ó¥É¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É
music = Mix_LoadWAV("test.ogg");
music2 = Mix_LoadWAV("test2.ogg");
//SDL_mixer:ºÆÀ¸
channel = Mix_PlayChannel(-1, music, -1);
channel = Mix_PlayChannel(-1, music2, -1);
//¥á¥¤¥ó¥ë¡¼¥×
int done = 0;
while(done == 0){
if(SDL_PollEvent(&event)){
//ºÇ½é¤Ë¾ï¤Ë¥·¥¹¥Æ¥à½ªÎ»µ½Ò¤ò¤¹¤ë
if(event.type == SDL_QUIT){
done= 1;
}
}
SDL_Delay(16); //CPU¤ò°ìö³«Êü
}
//SDL_mixer:Ää»ß
Mix_HaltChannel(channel);
Mix_HaltChannel(channel2);
//SDL_mixer:¥µ¥¦¥ó¥É³«Êü
Mix_FreeChunk(music);
Mix_FreeChunk(music2);
//SDL_mixer:¥é¥¤¥Ö¥é¥ê½ªÎ»
Mix_CloseAudio();
//½ªÎ»½èÍý
SDL_Quit();
}
Ʊ»þ¤ËÌĤê¤Þ¤·¤¿
´Ø¿ô̾¤¬ LoadWAV¤Ê¤Î¤Ç¾éÃ̤Ǥä¤Ã¤Æ¤ß¤¿¤À¤±¤À¤Ã¤¿¤Î¤Ç¤¹¤¬(*'-')
¥Á¥ã¥ó¥Í¥ë¤ò»ØÄꤹ¤ëºÆÀ¸ÊýË¡¤¬¤¢¤Ã¤¿¤Î¤Ç¡¤»î¤·¤Æ¤ß¤¿
#include <SDL.h>
#include <SDL_mixer.h> //SDL_mixer¥Ø¥Ã¥À
int main(int args,char *argp[]){
SDL_Surface *screen;
SDL_Event event;
//½é´ü²½
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0){
return -1;
}
screen=SDL_SetVideoMode(854,480,32,SDL_HWSURFACE);
if(screen == NULL){
SDL_Quit();
return -1;
}
//SDL_mixer:¥é¥¤¥Ö¥é¥ê³«»Ï
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);
//SDL_mixer:ÊÑ¿ôÄêµÁ
Mix_Chunk *music;
Mix_Chunk *music2;
int channel;
int channel2;
//SDL_mixer:¥µ¥¦¥ó¥É¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É
music = Mix_LoadWAV("test.ogg");
music2 = Mix_LoadWAV("test2.ogg");
//SDL_mixer:ºÆÀ¸
channel = Mix_PlayChannel(-1, music, -1);
channel = Mix_PlayChannel(-1, music2, -1);
//¥á¥¤¥ó¥ë¡¼¥×
int done = 0;
while(done == 0){
if(SDL_PollEvent(&event)){
//ºÇ½é¤Ë¾ï¤Ë¥·¥¹¥Æ¥à½ªÎ»µ½Ò¤ò¤¹¤ë
if(event.type == SDL_QUIT){
done= 1;
}
}
SDL_Delay(16); //CPU¤ò°ìö³«Êü
}
//SDL_mixer:Ää»ß
Mix_HaltChannel(channel);
Mix_HaltChannel(channel2);
//SDL_mixer:¥µ¥¦¥ó¥É³«Êü
Mix_FreeChunk(music);
Mix_FreeChunk(music2);
//SDL_mixer:¥é¥¤¥Ö¥é¥ê½ªÎ»
Mix_CloseAudio();
//½ªÎ»½èÍý
SDL_Quit();
}
Ʊ»þ¤ËÌĤê¤Þ¤·¤¿
´Ø¿ô̾¤¬ LoadWAV¤Ê¤Î¤Ç¾éÃ̤Ǥä¤Ã¤Æ¤ß¤¿¤À¤±¤À¤Ã¤¿¤Î¤Ç¤¹¤¬(*'-')


