Reputation: 21
I want to making a game with allegro4 on ubuntu.So I improving myself whit tutorials. Today I want to add a sound in my game.
However I can't run the sound. When I compile my code and run the "output" program the terminal give that message:
ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC0D0 failed: No such file or directory
But Program still run.Then When I press the up button(for listening the sound) the program screen is shut down and the terminal give that message :
Shutting down Allegro due to signal #11
Segmentation fault (core dumped)
Here is my code:
#include <allegro.h>
void start();
void finish();
int main(){
start();
SAMPLE *soundfile=load_sample("sound.wav");
while(!key[KEY_ESC]){
if(key[KEY_UP]){
play_sample(soundfile,255,128,1000,0);
}
}
finish();
return 0;
}
END_OF_MAIN()
void start(){
int depth,res;
allegro_init();
depth = desktop_color_depth();
if(depth == 0) depth=32;
set_color_depth(depth);
res=set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480,0,0);
if(res!=0){
allegro_message("%s\n", allegro_error);
exit(-1);
}
install_timer();
install_keyboard();
install_mouse();
install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"A");
}
void finish(){
clear_keybuf();
}
Upvotes: 0
Views: 199