indexing description: "[ Access to Brick Breaker audio singletons ]" date: "$Date$" revision: "$Revision$" class BB_SHARED_AUDIO inherit SHARED_BB_SETTINGS BB_CONSTANTS feature {NONE} -- Singleton access sound_player: EM_SOUND_PLAYER is -- sound effect player singleton indexing once_status: global local sfx_files: DS_LINKED_LIST [STRING] once if Is_sound_enabled then create sfx_files.make sfx_files.force (Sound_menu_click_path, Sound_menu_click) sfx_files.force (Sound_block_hit_path, Sound_block_hit) sfx_files.force (Sound_block_destroy_path, Sound_block_destroy) sfx_files.force (Sound_block_grey_hit_path, Sound_block_grey_hit) sfx_files.force (Sound_border_path, Sound_border) sfx_files.force (Sound_angle_high_path, Sound_angle_high) sfx_files.force (Sound_angle_low_path, Sound_angle_low) sfx_files.force (Sound_artillery_path, Sound_artillery) sfx_files.force (Sound_bad_item_path, Sound_bad_item) sfx_files.force (Sound_ball_fast_path, Sound_ball_fast) sfx_files.force (Sound_ball_slow_path, Sound_ball_slow) sfx_files.force (Sound_bar_fast_path, Sound_bar_fast) sfx_files.force (Sound_bar_large_path, Sound_bar_large) sfx_files.force (Sound_bar_slow_path, Sound_bar_slow) sfx_files.force (Sound_bar_small_path, Sound_bar_small) sfx_files.force (Sound_destroy_all_path, Sound_destroy_all) sfx_files.force (Sound_destroy_all_off_path, Sound_destroy_all_off) sfx_files.force (Sound_destroy_random_path, Sound_destroy_random) sfx_files.force (Sound_disappear_path, Sound_disappear) sfx_files.force (Sound_fly_away_path, Sound_fly_away) sfx_files.force (Sound_fly_away_off_path, Sound_fly_away_off) sfx_files.force (Sound_good_item_path, Sound_good_item) sfx_files.force (Sound_input_freezed_path, Sound_input_freezed) sfx_files.force (Sound_input_freezed_off_path, Sound_input_freezed_off) sfx_files.force (Sound_input_inverted_path, Sound_input_inverted) sfx_files.force (Sound_invulnerable_path, Sound_invulnerable) sfx_files.force (Sound_life_up_path, Sound_life_up) sfx_files.force (Sound_loose_life_path, Sound_loose_life) sfx_files.force (Sound_loose_points_path, Sound_loose_points) sfx_files.force (Sound_points_path, Sound_points) sfx_files.force (Sound_split_to_2_path, Sound_split_to_2) sfx_files.force (Sound_split_to_4_path, Sound_split_to_4) sfx_files.force (Sound_split_to_6_path, Sound_split_to_6) sfx_files.force (Sound_stick_on_bar_path, Sound_stick_on_bar) sfx_files.force (Sound_stick_on_bar_ball_path, Sound_stick_on_bar_ball) sfx_files.force (Sound_stick_on_bar_off_path, Sound_stick_on_bar_off) sfx_files.force (Sound_transparent_ball_path, Sound_transparent_ball) sfx_files.force (Sound_transparent_ball_off_path, Sound_transparent_ball_off) sfx_files.force (Sound_transparent_bar_path, Sound_transparent_bar) sfx_files.force (Sound_transparent_bar_off_path, Sound_transparent_bar_off) sfx_files.force (Sound_next_level_path, Sound_next_level) sfx_files.force (Sound_drive_left_path, Sound_drive_left) sfx_files.force (Sound_drive_right_path, Sound_drive_right) sfx_files.force (Sound_divert_path, Sound_divert) sfx_files.force (Sound_add_block_path, Sound_add_block) create Result.make_with_list (sfx_files, False) Result.set_volume (bb_settings.sfx_volume) Result.preload_sounds set_are_sounds_muted (False) end ensure sound_player_not_void: Result /= Void end music_player: EM_MUSIC_PLAYER is -- background music player singleton indexing once_status: global once create Result.make_empty (False) end feature -- Status report are_sounds_muted: BOOLEAN -- are sounds played? feature -- Status setting set_are_sounds_muted (a_boolean: BOOLEAN) is -- set `are_sounds_muted' do are_sounds_muted := a_boolean ensure value_set: are_sounds_muted = a_boolean end feature -- Sound playback play_sound (a_sound_number: INTEGER) is -- play sound corresponding to `a_sound_number' do if Is_sound_enabled and not are_sounds_muted then sound_player.play_i_th (a_sound_number, 0) end end stop_sound (a_sound_number: INTEGER) is -- stop sound corresponding to `a_sound_number' do if Is_sound_enabled and not are_sounds_muted then sound_player.stop_i_th (a_sound_number) end end play_music (a_music_file: STRING) is -- load `a_music_file' do if Is_music_enabled then stop_music music_player.playlist.wipe_out music_player.playlist.extend (a_music_file) music_player.set_repeat (True) music_player.set_volume (bb_settings.music_volume) music_player.play end end stop_music is -- stop music do if music_player.is_playing then music_player.stop end end resume_music is -- resume music do music_player.resume end pause_music is -- pause music do if music_player.is_playing then music_player.pause end end feature -- Miscelanneous init_sound_player is -- initializes `sound_player' -- calls something on `sound_player' to forc it loading, should be used at game start local dummy_boolean: BOOLEAN do dummy_boolean := sound_player.did_initialize_subsystem end feature -- Sound constants -- sound effects Sound_menu_click: INTEGER is 1 Sound_menu_click_path: STRING is "./sfx/beep.ogg" Sound_block_hit: INTEGER is 2 Sound_block_hit_path: STRING is "./sfx/block.ogg" Sound_block_destroy: INTEGER is 3 Sound_block_destroy_path: STRING is "./sfx/block0.ogg" Sound_block_grey_hit: INTEGER is 4 Sound_block_grey_hit_path: STRING is "./sfx/block-1.ogg" Sound_border: INTEGER is 5 Sound_border_path: STRING is "./sfx/border.ogg" Sound_angle_high: INTEGER is 6 Sound_angle_high_path: STRING is "./sfx/angle_high.ogg" Sound_angle_low: INTEGER is 7 Sound_angle_low_path: STRING is "./sfx/angle_low.ogg" Sound_artillery: INTEGER is 8 Sound_artillery_path: STRING is "./sfx/artillery.ogg" Sound_bad_item: INTEGER is 9 Sound_bad_item_path: STRING is "./sfx/bad_item.ogg" Sound_ball_fast: INTEGER is 10 Sound_ball_fast_path: STRING is "./sfx/ball_fast.ogg" Sound_ball_slow: INTEGER is 11 Sound_ball_slow_path: STRING is "./sfx/ball_slow.ogg" Sound_bar_fast: INTEGER is 12 Sound_bar_fast_path: STRING is "./sfx/bar_fast.ogg" Sound_bar_large: INTEGER is 13 Sound_bar_large_path: STRING is "./sfx/bar_large.ogg" Sound_bar_slow: INTEGER is 14 Sound_bar_slow_path: STRING is "./sfx/bar_slow.ogg" Sound_bar_small: INTEGER is 15 Sound_bar_small_path: STRING is "./sfx/bar_small.ogg" Sound_destroy_all: INTEGER is 16 Sound_destroy_all_path: STRING is "./sfx/destroy_all.ogg" Sound_destroy_all_off: INTEGER is 17 Sound_destroy_all_off_path: STRING is "./sfx/destroy_all_off.ogg" Sound_destroy_random: INTEGER is 18 Sound_destroy_random_path: STRING is "./sfx/destroy_random.ogg" Sound_disappear: INTEGER is 19 Sound_disappear_path: STRING is "./sfx/disappear.ogg" Sound_fly_away: INTEGER is 20 Sound_fly_away_path: STRING is "./sfx/fly_away.ogg" Sound_fly_away_off: INTEGER is 21 Sound_fly_away_off_path: STRING is "./sfx/fly_away_off.ogg" Sound_good_item: INTEGER is 22 Sound_good_item_path: STRING is "./sfx/good_item.ogg" Sound_input_freezed: INTEGER is 23 Sound_input_freezed_path: STRING is "./sfx/input_freezed.ogg" Sound_input_freezed_off: INTEGER is 24 Sound_input_freezed_off_path: STRING is "./sfx/input_freezed_off.ogg" Sound_input_inverted: INTEGER is 25 Sound_input_inverted_path: STRING is "./sfx/input_inverted.ogg" Sound_invulnerable: INTEGER is 26 Sound_invulnerable_path: STRING is "./sfx/invulnerable.ogg" Sound_life_up: INTEGER is 27 Sound_life_up_path: STRING is "./sfx/life_up.ogg" Sound_loose_life: INTEGER is 28 Sound_loose_life_path: STRING is "./sfx/loose_life.ogg" Sound_loose_points: INTEGER is 29 Sound_loose_points_path: STRING is "./sfx/loose_points.ogg" Sound_points: INTEGER is 30 Sound_points_path: STRING is "./sfx/points.ogg" Sound_split_to_2: INTEGER is 31 Sound_split_to_2_path: STRING is "./sfx/split_to_2.ogg" Sound_split_to_4: INTEGER is 32 Sound_split_to_4_path: STRING is "./sfx/split_to_4.ogg" Sound_split_to_6: INTEGER is 33 Sound_split_to_6_path: STRING is "./sfx/split_to_6.ogg" Sound_stick_on_bar: INTEGER is 34 Sound_stick_on_bar_path: STRING is "./sfx/stick_on_bar.ogg" Sound_stick_on_bar_ball: INTEGER is 35 Sound_stick_on_bar_ball_path: STRING is "./sfx/stick_on_bar_ball.ogg" Sound_stick_on_bar_off: INTEGER is 36 Sound_stick_on_bar_off_path: STRING is "./sfx/stick_on_bar_off.ogg" Sound_transparent_ball: INTEGER is 37 Sound_transparent_ball_path: STRING is "./sfx/transparent_ball.ogg" Sound_transparent_ball_off: INTEGER is 38 Sound_transparent_ball_off_path: STRING is "./sfx/transparent_ball_off.ogg" Sound_transparent_bar: INTEGER is 39 Sound_transparent_bar_path: STRING is "./sfx/transparent_bar.ogg" Sound_transparent_bar_off: INTEGER is 40 Sound_transparent_bar_off_path: STRING is "./sfx/transparent_bar_off.ogg" Sound_next_level: INTEGER is 41 Sound_next_level_path: STRING is "./sfx/next_level.ogg" Sound_drive_left: INTEGER is 42 Sound_drive_left_path: STRING is "./sfx/drive_left.ogg" Sound_drive_right: INTEGER is 43 Sound_drive_right_path: STRING is "./sfx/drive_right.ogg" Sound_divert: INTEGER is 44 Sound_divert_path: STRING is "./sfx/divert.ogg" Sound_add_block: INTEGER is 45 Sound_add_block_path: STRING is "./sfx/add_block.ogg" end