/* functions - used to call to this library from other parts of engine */ unsigned int setupSound(void) { /* set up sound library for first use, and init allegro soundsystem */ music = NULL; voice = NULL; mixer = NULL; if (!al_install_audio()) { /* fail if audio does not load for some reason */ return 0; } if (!al_init_acodec_addon()) { /* fail if audio does not load for some reason */ return 0; } if (!al_reserve_samples(8)) { /* fail if audio does not load for some reason */ return 0; } mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); al_attach_mixer_to_voice(mixer, voice); return true; }
void init_audio(void) { al_reserve_samples(num_samples); // Sets up the default mixer // Set up the audio stream and mixer attachment if (stream) { if (al_get_mixer_attached(al_get_default_mixer())) { al_detach_mixer(al_get_default_mixer()); } al_destroy_audio_stream(stream); } stream = al_create_audio_stream( num_fragments, size_fragment, audio_rate, AUDIO_DEPTH, CHANNEL_CONF); al_attach_audio_stream_to_mixer(stream, al_get_default_mixer()); al_register_event_source(event_queue, al_get_audio_stream_event_source(stream)); }
AllegroEngine::AllegroEngine() : _gain(0.5) { al_install_audio(); al_init_acodec_addon(); al_reserve_samples(12); }
void SpaceSim::LoadAllegro() { al_init(); //allegro-5.0.10-monolith-md-debug.lib //Anti Aliasing al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST); //Creating screen screen_width = 1350; screen_height = 690; display = al_create_display(screen_width,screen_height); al_set_window_position(display,0,0); al_set_window_title(display, "Domitian Engine"); //Initializing Addons al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); al_install_keyboard(); al_install_audio(); al_init_acodec_addon(); al_reserve_samples(10); };
int main(int argc, char **argv) { al_init(); al_init_image_addon(); al_init_primitives_addon(); al_init_font_addon(); al_init_ttf_addon(); al_get_display_mode(al_get_num_display_modes()-1, &disp_data); //al_set_new_display_flags(ALLEGRO_FULLSCREEN); al_set_new_display_flags(ALLEGRO_WINDOWED); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); disp_data.width*=0.8; disp_data.height*=0.8; display=al_create_display(disp_data.width, disp_data.height); if(!display) { return -1; } al_clear_to_color(al_map_rgb(0, 0, 0)); al_flip_display(); al_install_keyboard(); al_install_mouse(); al_install_audio(); al_init_acodec_addon(); al_reserve_samples(5); al_rest(5.0); al_destroy_display(display); return 0; }
bool SoundInterface::initializeSounds() { if (!al_init_acodec_addon()) return false; if (!al_install_audio()) return false; if (!al_reserve_samples(512)) return false; return true; }
void mw2_Application::Initialize() { al_init(); al_init_image_addon(); al_install_keyboard(); al_install_mouse(); al_init_primitives_addon(); al_init_font_addon(); al_init_ttf_addon(); al_init_acodec_addon(); al_install_audio(); al_reserve_samples(20); // maximum 20 sounds at a time al_set_new_display_flags(ALLEGRO_WINDOWED); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); // this prevents random lag al_set_new_display_option( ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST ); mWindow = al_create_display(Settings::width, Settings::height); al_set_window_title(mWindow, Settings::title.c_str()); mw2_Input::Initialize(mWindow); srand( (unsigned int) std::time(0) ); }
int main(void) { int i; if (!al_init()) { abort_example("Could not init Allegro.\n"); } al_install_keyboard(); open_log(); display = al_create_display(640, 100); if (!display) { abort_example("Could not create display.\n"); } if (!al_install_audio()) { abort_example("Could not init sound.\n"); } al_reserve_samples(N); al_set_mixer_postprocess_callback(al_get_default_mixer(), update_waveform, NULL); mainloop(); close_log(false); for (i = 0; i < N; i++) { al_destroy_audio_stream(stream[i]); } al_uninstall_audio(); return 0; }
void initialize_sound(void) { al_install_audio(); al_init_acodec_addon(); al_reserve_samples(10); al_set_mixer_gain(al_get_default_mixer(), 1.0); }
bool GameLogic::LoadAssets() { Bitmap.Logo = al_load_bitmap("assets/images/daklutz.png"); Bitmap.Title = al_load_bitmap("assets/images/Bitmap.Title.png"); if(!Bitmap.Title || !Bitmap.Logo) { fprintf(stderr, "Failed to load image files!\n"); return false; } if(Debug) { fprintf(stderr, "Bitmaps loaded.\n"); } // actually load the font, I loaded the same font at different sizes. Font.Small = al_load_font("assets/fonts/Geo-Regular.ttf", 24, 0); Font.Medium = al_load_font("assets/fonts/Geo-Regular.ttf", 38, 0); Font.Big = al_load_font("assets/fonts/Geo-Regular.ttf", 70, 0); if(!Font.Small || !Font.Medium || !Font.Big) { fprintf(stderr, "Failed to load fonts!\n"); return false; } if (!al_reserve_samples(2)) { fprintf(stderr, "Could not reserve samples!\n"); return false; } if(Debug) { fprintf(stderr, "Samples reserved.\n"); } Sound.HitWall = al_load_sample("assets/sounds/wall_collision.ogg"); Sound.HitPaddle = al_load_sample("assets/sounds/paddle_collision.ogg"); Sound.BackgroundMusic = al_load_audio_stream("assets/sounds/Sound.BackgroundMusic-tech.ogg", 4, 2048); if (!Sound.HitWall || !Sound.HitPaddle || !Sound.BackgroundMusic) { fprintf(stderr, "Failed to load sound files!\n"); return false; } if(Debug) { fprintf(stderr, "Sound files loaded.\n"); } if(!al_attach_audio_stream_to_mixer(Sound.BackgroundMusic, Mixer) ) { fprintf(stderr, "Failed to attach stream to default Mixer!\n"); return 1; } if(Debug) { fprintf(stderr, "Stream attached to Mixer.\n"); } if(!al_set_mixer_playing(Mixer, true)) { fprintf(stderr, "Failed to play Mixer!\n"); } if(Debug) { fprintf(stderr, "Mixer playing.\n"); } if(!al_set_audio_stream_playmode(Sound.BackgroundMusic, ALLEGRO_PLAYMODE_LOOP)) { fprintf(stderr, "Failed to loop stream!\n"); } if(Debug) { fprintf(stderr, "Stream is set to loop.\n"); } if(!al_set_audio_stream_playing(Sound.BackgroundMusic, true)) { fprintf(stderr, "Failed to play stream!\n"); } if(Debug) { fprintf(stderr, "Stream playing.\n"); } return true; }
static int initialize(void) { if (!al_init()) { abort_example("Could not init Allegro.\n"); } al_init_primitives_addon(); al_init_image_addon(); al_init_font_addon(); if (!al_install_keyboard()) { printf("Could not init keyboard!\n"); return 0; } if (!al_install_mouse()) { printf("Could not init mouse!\n"); return 0; } al_init_acodec_addon(); if (!al_install_audio()) { printf("Could not init sound!\n"); return 0; } if (!al_reserve_samples(16)) { printf("Could not set up voice and mixer.\n"); return 0; } display = al_create_display(640, 228); if (!display) { printf("Could not create display!\n"); return 0; } basic_font = al_load_font("data/font.tga", 0, 0); if (!basic_font) { printf("Could not load font!\n"); return 0; } timer = al_create_timer(1.000 / 30); if (!timer) { printf("Could not init timer!\n"); return 0; } queue = al_create_event_queue(); if (!queue) { printf("Could not create event queue!\n"); return 0; } al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_mouse_event_source()); al_register_event_source(queue, al_get_display_event_source(display)); al_register_event_source(queue, al_get_timer_event_source(timer)); return 1; }
bool initializeAllegro() { // Install Addons if(!al_init()) { fprintf(stderr, "failed to initialize allegro!\n"); return false; } if(!al_init_image_addon()) { fprintf(stderr, "failed to initialize al_init_image_addon!\n"); return false; } if(!al_install_keyboard()) { fprintf(stderr, "failed to initialize the keyboard!\n"); return false; } if(!al_install_audio()) { fprintf(stderr, "failed to initialize audio!\n"); return false; } if(!al_init_acodec_addon()) { fprintf(stderr, "failed to initialize audio codecs!\n"); return false; } if (!al_reserve_samples(NUM_SAMPLES)) { fprintf(stderr, "failed to reserve samples!\n"); return false; } al_init_font_addon(); if( !al_init_ttf_addon()) { fprintf(stderr, "failed to init ttf!\n"); return false; } //for testing if (!al_init_primitives_addon()) { fprintf(stderr, "failed to init primitives!\n"); return false; } // All Addons Successfully Installed! return true; }
bool Framework::initialize(std::string config_filename) { if (initialized) return initialized; if (!al_init()) std::cerr << "al_init() failed" << std::endl; ALLEGRO_PATH *resource_path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_change_directory(al_path_cstr(resource_path, ALLEGRO_NATIVE_PATH_SEP)); al_destroy_path(resource_path); if (!al_install_mouse()) std::cerr << "al_install_mouse() failed" << std::endl; if (!al_install_keyboard()) std::cerr << "al_install_keyboard() failed" << std::endl; if (!al_install_joystick()) std::cerr << "al_install_joystick() failed" << std::endl; if (!al_install_audio()) std::cerr << "al_install_audio() failed" << std::endl; if (!al_init_native_dialog_addon()) std::cerr << "al_init_native_dialog_addon() failed" << std::endl; if (!al_init_primitives_addon()) std::cerr << "al_init_primitives_addon() failed" << std::endl; if (!al_init_image_addon()) std::cerr << "al_init_image_addon() failed" << std::endl; if (!al_init_font_addon()) std::cerr << "al_init_font_addon() failed" << std::endl; if (!al_init_ttf_addon()) std::cerr << "al_init_ttf_addon() failed" << std::endl; if (!al_init_acodec_addon()) std::cerr << "al_init_acodec_addon() failed" << std::endl; if (!al_reserve_samples(32)) std::cerr << "al_reserve_samples() failed" << std::endl; srand(time(NULL)); primary_timer = al_create_timer(ALLEGRO_BPS_TO_SECS(60)); al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR); // al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR | ALLEGRO_MIPMAP); builtin_font = al_create_builtin_font(); event_queue = al_create_event_queue(); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_mouse_event_source()); al_register_event_source(event_queue, al_get_joystick_event_source()); al_register_event_source(event_queue, al_get_timer_event_source(primary_timer)); al_register_event_source(event_queue, al_get_joystick_event_source()); al_register_event_source(event_queue, al_get_default_menu_event_source()); if (al_get_num_joysticks()) joystick = al_get_joystick(0); // make this better eventually else std::cerr << "no joystick(s) detected" << std::endl; instance = new Framework(config_filename); Attributes::create_datatype_definition( AllegroColorAttributeDatatype::IDENTIFIER, AllegroColorAttributeDatatype::to_val_func, AllegroColorAttributeDatatype::to_str_func ); initialized = true; return true; }
bool main_init_allegro_library() { /* allegro main library */ if(!al_init()) { error_message("fail to initialize allegro library"); return false; } /* inputs */ if(!al_install_mouse()) { error_message("fail to install mouse for allegro"); return false; } if(!al_install_keyboard()) { error_message("fail to install keyboard for allegro"); return false; } /* outputs */ if(!al_install_audio()) { error_message("fail to install audio for allegro"); return false; } /* addon */ if(!al_init_acodec_addon()) { error_message("fail to initialize audio codec addon for allegro"); return false; } al_init_font_addon(); if(!al_init_ttf_addon()) { error_message("fail to initialize font addon for allegro"); return false; } if(!al_init_image_addon()) { error_message("fail to initialize image addon for allegro"); return false; } if(!al_init_native_dialog_addon()) { error_message("fail to initialize dialog addon for allegro"); return false; } if(!al_init_primitives_addon()) { error_message("fail to initialize primitive addon for allegro"); return false; } /* * reserve sample for audio output * reserve amount of samples to 20 * there are 16 balls with different collision sound track * and 1 background music */ if(!al_reserve_samples(20)) { error_message("fail to reserve sample for audio output"); } return true; }
void init_misc() { al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); al_set_window_title(display, "Pikmin fangame engine"); if(smooth_scaling) al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR | ALLEGRO_MIPMAP); al_reserve_samples(16); srand(time(NULL)); // TODO the function is always returning 0. area_image_size = /*al_get_new_display_option(ALLEGRO_MAX_BITMAP_SIZE, NULL)*/ 800; }
bool loadResources(void) { ResourceManager& rm = ResourceManager::getInstance(); if (!rm.add(new DisplayResource())) { printf("Failed to create display.\n"); return false; } /* For some reason dsound needs a window... */ if (!al_install_audio()) { printf("Failed to install audio.\n"); /* Continue anyway. */ } else { al_reserve_samples(16); } if (!rm.add(new Player(), false)) { printf("Failed to create player.\n"); return false; } if (!rm.add(new Input())) { printf("Failed initializing input.\n"); return false; } // Load fonts if (!rm.add(new FontResource(getResource("gfx/large_font.tga")))) return false; if (!rm.add(new FontResource(getResource("gfx/small_font.tga")))) return false; for (int i = 0; BMP_NAMES[i]; i++) { if (!rm.add(new BitmapResource(getResource(BMP_NAMES[i])))) { printf("Failed to load %s\n", getResource(BMP_NAMES[i])); return false; } } for (int i = 0; SAMPLE_NAMES[i]; i++) { if (!rm.add(new SampleResource(getResource(SAMPLE_NAMES[i])))) { /* Continue anyway. */ } } for (int i = 0; STREAM_NAMES[i]; i++) { if (!rm.add(new StreamResource(getResource(STREAM_NAMES[i])))) { /* Continue anyway. */ } } return true; }
void Sound::prepare(){ if(soundsLoaded){ al_reserve_samples(2); soundsPrepared = true; songInstance = al_create_sample_instance(backgroundSong); al_set_sample_instance_playmode(songInstance, ALLEGRO_PLAYMODE_LOOP); al_attach_sample_instance_to_mixer(songInstance, al_get_default_mixer()); } else throw MyException("Sounds was not attached."); }
// Sets up game void setup(){ // Init allegro 5 al_init(); // Input al_install_keyboard(); al_install_mouse(); al_install_joystick(); // Fonts al_init_font_addon(); al_init_ttf_addon(); // Graphics al_init_image_addon(); al_init_primitives_addon(); // Audio al_install_audio(); al_init_acodec_addon(); al_reserve_samples( 20); // Initializing timer = al_create_timer(1.0 / MAX_FPS); display = al_create_display( SCREEN_W, SCREEN_H); // Events event_queue = al_create_event_queue(); al_register_event_source( event_queue, al_get_display_event_source(display)); al_register_event_source( event_queue, al_get_timer_event_source(timer)); al_register_event_source( event_queue, al_get_keyboard_event_source()); al_register_event_source( event_queue, al_get_joystick_event_source()); al_clear_to_color( al_map_rgb(0,0,0)); al_flip_display(); al_start_timer(timer); // Creates a random number generator (based on time) srand( time(nullptr)); // Game state stateID = STATE_NULL; nextState = STATE_NULL; // Clear settings for( int i = 0; i < 11; i++) settings[i] = false; // Clear frams array for( int i = 0; i < 100; i++) frames_array[i] = 0; }
bool init(int samples) { al_init(); if (!al_install_audio()) return false; if (!al_init_acodec_addon()) return false; // reserva samples para serem tocados simultaneamente if (!al_reserve_samples(samples)) return false; return true; }
int main() { load_configuration_file(); // ŁADOWANIE BIBLIOTEK al_init(); al_init_image_addon(); al_init_primitives_addon(); al_install_keyboard(); al_init_font_addon(); al_init_ttf_addon(); al_install_audio(); al_init_acodec_addon(); al_reserve_samples(100); // WYŚWTIETLANIE EKRANU display.view = NULL; // al_get_display_mode(al_get_num_display_modes() -3, &disp_data); // al_set_new_display_flags(ALLEGRO_FULLSCREEN); display.view = al_create_display(display.width, display.height); // TIMER main_timer = NULL; main_timer = al_create_timer(1.0 / display.FPS); GAME_MODE = MENU; Exit_game = false; al_start_timer(main_timer); while (!Exit_game) { switch (GAME_MODE) { case MENU: menu(); break; case GAMEPLAY: gameplay(); break; case AFTER_GAMEPLAY: menu(); break; default: break; } } al_destroy_display(display.view); al_destroy_timer(main_timer); return 111; }
void LoadSamples(Audio* const audio) { al_reserve_samples(10); audio->song_sample = al_load_sample("song.ogg"); audio->song_sample_instance = al_create_sample_instance(audio->song_sample); al_set_sample_instance_playmode(audio->song_sample_instance, ALLEGRO_PLAYMODE_LOOP); al_attach_sample_instance_to_mixer(audio->song_sample_instance, al_get_default_mixer()); audio->samples[AT_EXPLOSION] = al_load_sample("explosion.wav"); audio->samples[AT_RESTART] = al_load_sample("restart.wav"); audio->samples[AT_TRANSPORT] = al_load_sample("transport.wav"); audio->samples[AT_WHIZ] = al_load_sample("whiz.wav"); }
void init(int width, int height) { danmakux.width = width; danmakux.height = height; if (!al_init()) al_show_native_message_box(display, "Error", "Error", "Failed to initialize Allegro!", NULL, ALLEGRO_MESSAGEBOX_ERROR); if (!al_install_keyboard()) al_show_native_message_box(display, "Error", "Error", "Failed to install keyboard!", NULL, ALLEGRO_MESSAGEBOX_ERROR); if (!al_install_audio()) al_show_native_message_box(display, "Error", "Error", "Failed to install audio!", NULL, ALLEGRO_MESSAGEBOX_ERROR); if (!al_reserve_samples(10)) al_show_native_message_box(display, "Error", "Error", "Failed to reserve samples!", NULL, ALLEGRO_MESSAGEBOX_ERROR); timer = al_create_timer(1.0 / FPS); if (!timer) al_show_native_message_box(display, "Error", "Error", "Failed to create timer!", NULL, ALLEGRO_MESSAGEBOX_ERROR); al_set_new_display_flags(ALLEGRO_WINDOWED); al_set_new_window_position(700, 200); display = al_create_display(danmakux.width, danmakux.height); if (!display) al_show_native_message_box(display, "Error", "Error", "Failed to create display!", NULL, ALLEGRO_MESSAGEBOX_ERROR); event_queue = al_create_event_queue(); if (!event_queue) al_show_native_message_box(display, "Error", "Error", "Failed to create event queue!", NULL, ALLEGRO_MESSAGEBOX_ERROR); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_display_event_source(display)); redraw = false; danmakux.fireBomb = false; danmakux.lives = 2; danmakux.bombsRemain = 2; danmakux.weaponLevel = 1; danmakux.done = false; danmakux.state_menu = true; danmakux.state_paused = false; danmakux.state_playing = false; danmakux.state_dialog = false; danmakux.menuChoice = 0; danmakux.currentLevel = 1; danmakux.player = &playerset; UI = danmakux.resources.get_image("ui.png"); al_start_timer(timer); loadMenu("mainmenu"); /*danmakux.state_menu = false; danmakux.state_playing = true; danmakux.state_paused = false; loadLevel("level1");*/ al_play_sample(danmakux.bgm, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL); }
int main(int argc, char *argv[]) { ALLEGRO_DISPLAY *display; unsigned int ticks = 0; if (!al_init()) { std::cerr << "[ERROR] Error initializing Allegro" << std::endl; } display = al_create_display(SCREEN_WIDTH, SCREEN_HEIGHT); if (!display) { std::cerr << "[ERROR] Error creating Allegro display" << std::endl; } al_install_audio(); al_install_keyboard(); al_init_primitives_addon(); al_init_acodec_addon(); al_init_font_addon(); al_init_ttf_addon(); al_init_image_addon(); al_reserve_samples(10); srand(time(NULL)); ALLEGRO_TIMER *timer = al_create_timer(1.0 / FPS); ALLEGRO_EVENT_QUEUE *timerQueue = al_create_event_queue(); al_register_event_source(timerQueue, al_get_timer_event_source(timer)); al_start_timer(timer); Tetris *game = new Tetris(SCREEN_WIDTH, SCREEN_HEIGHT, timerQueue); while (game->update(ticks)) { game->render(); ++ticks; } delete game; al_destroy_display(display); al_destroy_timer(timer); al_destroy_event_queue(timerQueue); return 0; }
void inquisition(al_defs* al) { al_install_audio(); al_init_acodec_addon(); al_reserve_samples(1); ALLEGRO_SAMPLE *sample = al_load_sample("res/spanish.wav"); if(!sample) fprintf(stderr, "nie :< \n"); al_clear_to_color(al_map_rgb(0,0,0)); ALLEGRO_BITMAP* bmp = al_load_bitmap("res/troll.jpg"); al_draw_bitmap(bmp, (al->width-500)/2, (al->height-360)/2, 0); al_flip_display(); al_play_sample(sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL); wait_for_key_enter(al); al_destroy_bitmap(bmp); al_destroy_sample(sample); }
InitializationStatus AllegroFlasher::AllegroInit() { //const int FPS = 60; // initialise Allegro itself if(!al_init()) return ALLEGRO_INITIALISATION_ERROR; // initialise primitives addon (for drawing shapes) if(!al_init_primitives_addon()) return PRIMITIVES_ADDON_ERROR; // install the keyboard if(!al_install_keyboard()) return KEYBOARD_ERROR; //install the mouse if(!al_install_mouse()) return MOUSE_ERROR; // initialise font and ttf addon (for drawing text) al_init_font_addon(); if (!al_init_ttf_addon()) return TTF_ADDON_ERROR; //initialise audio if(!al_install_audio()) return AUDIO_ERROR; //initialise audio codecs if(!al_init_acodec_addon()) return CODEC_ERROR; //reserve samples if (!al_reserve_samples(5)) return RESERVE_SAMPLES_ERROR; //event_queue = al_create_event_queue(); //display = al_create_display(width, height); //if(!display) // return DISPLAY_ERROR; //timer = al_create_timer(1.0 / FPS); // Set the period of the time // Register keyboard input, mouse input, display input, and timer as event source on event_queue //al_register_event_source(event_queue, al_get_keyboard_event_source()); //al_register_event_source(event_queue, al_get_mouse_event_source()); //al_register_event_source(event_queue, al_get_timer_event_source(timer)); return OKAY; }
Audio::Audio() { #ifdef WRITE_LOG fprintf( FRAMEWORK->LogFile, "Framework: Initialise Audio\n" ); #endif if( !al_install_audio() ) { fprintf( FRAMEWORK->LogFile, "Audio_Initialise: Failed to install audio\n" ); return; } if( !al_init_acodec_addon() ) { fprintf( FRAMEWORK->LogFile, "Audio_Initialise: Failed to install codecs\n" ); return; } // Allow playing samples al_reserve_samples( 10 ); audioVoice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); if( audioVoice == 0 ) { fprintf( FRAMEWORK->LogFile, "Audio_Initialise: Failed to create voice\n" ); return; } audioMixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); if( audioMixer == 0 ) { fprintf( FRAMEWORK->LogFile, "Audio_Initialise: Failed to create mixer\n" ); al_destroy_voice( audioVoice ); audioVoice = 0; return; } if( !al_attach_mixer_to_voice( audioMixer, audioVoice ) ) { fprintf( FRAMEWORK->LogFile, "Audio_Initialise: Failed to attach mixer to voice\n" ); al_destroy_voice( audioVoice ); audioVoice = 0; al_destroy_mixer( audioMixer ); audioMixer = 0; return; } musicStream = nullptr; }
bool Sound :: open(char *path2) { if( !al_is_audio_installed() ) { al_install_audio(); al_init_acodec_addon(); al_reserve_samples(MAX_SAMPLES); } path = (char *)malloc(StringLengh(path2) + 1); strcpy(path, path2); audio = al_load_sample(path); if(audio == NULL) return (false); return (true); }
void gdp_init(){ // aloca limites de exibicao listlifeless = calloc(LIFELESS,sizeof(Lifeless*)); listchars = calloc(CHARS,sizeof(Char*)); // configurações iniciais ncanaisaudio = 3; // numero de canais de audio connecterro = 0; //nao existe erro ntotlifeless = 0; // numero de objetos ntotchars = 4; // numero de personagens ntotenemies = 0; // numero de inimigos opmap = 1; // mapa escolhido scale = 1.5; //escala do mapa boss_char_id = gdp_files_quick_getint("Configs//server.txt","boss_char_id"); //id do boss // Inicializa a Allegro al_init(); // Inicializa o add-on para utilização de imagens al_init_image_addon(); // Inicializa o add-on para utilização de teclado al_install_keyboard(); // Inicialização do add-on para uso de fontes al_init_font_addon(); al_init_ttf_addon(); // Inicialização do add-on para uso de sons al_install_audio(); al_init_acodec_addon(); al_reserve_samples(ncanaisaudio); //inicia addons de primitivas al_init_primitives_addon(); // Configura a janela al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW|ALLEGRO_FULLSCREEN); SCREEN = al_create_display(wigth, height); // define o titulo al_set_window_title(SCREEN, title); ambient = NULL; }
void Audio::Init(){ //// RESERVE SOUNDS, SET MUSIC, INSTANCE al_reserve_samples(3); //// CAN PLAY 3 SOUNDS AT ONCE //// LOAD IN SOUNDS bMusic = al_load_sample("Sounds/background.ogg"); endGame = al_load_sample("Sounds/endGame.ogg"); caught = al_load_sample("Sounds/caught_01.ogg"); respawn = al_load_sample("Sounds/respawn_01.ogg"); collect = al_load_sample("Sounds/collect_01.ogg"); //// SET UP INSTANCE MusicInstance = al_create_sample_instance(bMusic); al_set_sample_instance_playmode(MusicInstance, ALLEGRO_PLAYMODE_LOOP); al_set_sample_instance_gain(MusicInstance, 1.0f); al_attach_sample_instance_to_mixer(MusicInstance, al_get_default_mixer()); };
void install() { // setup allegro init = al_is_system_installed() && al_install_audio() && al_init_acodec_addon() && al_reserve_samples(0); // create bgm channel bgm_channel = al_create_sample_instance(NULL); al_attach_sample_instance_to_mixer(bgm_channel, al_get_default_mixer()); al_set_sample_instance_playmode(bgm_channel, ALLEGRO_PLAYMODE_LOOP); // create sample channels for (int i=0; i<SAMPLE_MAX; i++) { effects.push_back( al_create_sample_instance(NULL) ); al_attach_sample_instance_to_mixer(effects[i], al_get_default_mixer()); } // setup volume set_volume(master_vol); }