diff --git a/demos/shooter/game.c b/demos/shooter/game.c index 0e3ce21e8c..269392cc23 100644 --- a/demos/shooter/game.c +++ b/demos/shooter/game.c @@ -132,26 +132,30 @@ static void move_everyone(void) if ((key[ALLEGRO_KEY_UP])) { // || (joy[0].stick[0].axis[1].d1)) { /* firing thrusters */ if (yspeed < MAX_SPEED) { - if (yspeed == 0) { - al_stop_sample(&engine); - al_play_sample(data[ENGINE_SPL].dat, 0.9, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0, - 1.0, ALLEGRO_PLAYMODE_LOOP, &engine); - } - else { - /* fade in sample while speeding up */ - ALLEGRO_SAMPLE_INSTANCE *si = al_lock_sample_id(&engine); - al_set_sample_instance_gain(si, yspeed * 64 / MAX_SPEED / 255.0); - al_set_sample_instance_pan(si, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0); - al_unlock_sample_id(&engine); - } + if (al_is_audio_installed()) { + if (yspeed == 0) { + al_stop_sample(&engine); + al_play_sample(data[ENGINE_SPL].dat, 0.9, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0, + 1.0, ALLEGRO_PLAYMODE_LOOP, &engine); + } + else { + /* fade in sample while speeding up */ + ALLEGRO_SAMPLE_INSTANCE *si = al_lock_sample_id(&engine); + al_set_sample_instance_gain(si, yspeed * 64 / MAX_SPEED / 255.0); + al_set_sample_instance_pan(si, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0); + al_unlock_sample_id(&engine); + } + } yspeed++; } else { - /* adjust pan while the sample is looping */ - ALLEGRO_SAMPLE_INSTANCE *si = al_lock_sample_id(&engine); - al_set_sample_instance_gain(si, 64 / 255.0); - al_set_sample_instance_pan(si, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0); - al_unlock_sample_id(&engine); + if (al_is_audio_installed()) { + /* adjust pan while the sample is looping */ + ALLEGRO_SAMPLE_INSTANCE *si = al_lock_sample_id(&engine); + al_set_sample_instance_gain(si, 64 / 255.0); + al_set_sample_instance_pan(si, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0); + al_unlock_sample_id(&engine); + } } ship_burn = TRUE; @@ -161,17 +165,19 @@ static void move_everyone(void) /* not firing thrusters */ if (yspeed) { yspeed--; - if (yspeed == 0) { - al_stop_sample(&engine); - } - else { - /* fade out and reduce frequency when slowing down */ - ALLEGRO_SAMPLE_INSTANCE *si = al_lock_sample_id(&engine); - al_set_sample_instance_gain(si, yspeed * 64 / MAX_SPEED / 255.0); - al_set_sample_instance_pan(si, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0); - al_set_sample_instance_speed(si, (500 + yspeed * 500 / MAX_SPEED) / 1000.0); - al_unlock_sample_id(&engine); - } + if (al_is_audio_installed()) { + if (yspeed == 0) { + al_stop_sample(&engine); + } + else { + /* fade out and reduce frequency when slowing down */ + ALLEGRO_SAMPLE_INSTANCE *si = al_lock_sample_id(&engine); + al_set_sample_instance_gain(si, yspeed * 64 / MAX_SPEED / 255.0); + al_set_sample_instance_pan(si, -1 + 2 * PAN(player_x_pos >> SPEED_SHIFT) / 255.0); + al_set_sample_instance_speed(si, (500 + yspeed * 500 / MAX_SPEED) / 1000.0); + al_unlock_sample_id(&engine); + } + } } ship_burn = FALSE; @@ -343,7 +349,10 @@ void play_game(void) /* introduction synced to the music */ draw_intro_item(INTRO_BMP_1, 5); - play_midi(data[GAME_MUSIC].dat, TRUE); + + if (al_is_audio_installed()) + play_midi(data[GAME_MUSIC].dat, TRUE); + clear_keybuf(); if (fade_intro_item(-1, 2)) @@ -447,7 +456,8 @@ void play_game(void) } /* cleanup */ - al_stop_sample(&engine); + if (al_is_audio_installed()) + al_stop_sample(&engine); while (bullet_list) delete_bullet(bullet_list); diff --git a/demos/shooter/title.c b/demos/shooter/title.c index 5125e72b44..eac9074106 100644 --- a/demos/shooter/title.c +++ b/demos/shooter/title.c @@ -274,8 +274,10 @@ int title_screen(void) text_pix = 0; text_width = 0; - play_midi(data[TITLE_MUSIC].dat, TRUE); - play_sample(data[WELCOME_SPL].dat, 255, 127, 1000, FALSE); + if (al_is_audio_installed()) { + play_midi(data[TITLE_MUSIC].dat, TRUE); + play_sample(data[WELCOME_SPL].dat, 255, 127, 1000, FALSE); + } load_credits(); diff --git a/demos/skater/src/framework.c b/demos/skater/src/framework.c index 1a01c8c65b..fe9b674c72 100644 --- a/demos/skater/src/framework.c +++ b/demos/skater/src/framework.c @@ -116,7 +116,9 @@ int init_framework(void) sound or music (or both). */ al_install_audio(); al_init_acodec_addon(); - al_reserve_samples(8); + + if (al_is_audio_installed()) + al_reserve_samples(8); event_queue = al_create_event_queue(); diff --git a/demos/skater/src/game.c b/demos/skater/src/game.c index f77c47907a..ac7e7c01c5 100644 --- a/demos/skater/src/game.c +++ b/demos/skater/src/game.c @@ -150,14 +150,20 @@ static void GenericInit(void) WaterVoice = al_create_sample_instance(WaveNoise); al_set_sample_instance_playmode(WaterVoice, ALLEGRO_PLAYMODE_BIDIR); al_set_sample_instance_gain(WaterVoice, 0.5); - al_attach_sample_instance_to_mixer(WaterVoice, al_get_default_mixer()); + + if (al_is_audio_installed()) + al_attach_sample_instance_to_mixer(WaterVoice, al_get_default_mixer()); + al_play_sample_instance(WaterVoice); WaterVoice2 = al_create_sample_instance(WaveNoise); al_set_sample_instance_playmode(WaterVoice2, ALLEGRO_PLAYMODE_BIDIR); al_set_sample_instance_gain(WaterVoice2, 0.25); - al_attach_sample_instance_to_mixer(WaterVoice2, al_get_default_mixer()); + + if (al_is_audio_installed()) + al_attach_sample_instance_to_mixer(WaterVoice2, al_get_default_mixer()); + al_play_sample_instance(WaterVoice2); play_music(DEMO_MIDI_INGAME, true);