Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Adjustable Audio Version 1.1

Akin

Member

Adjustable Audio Script + Menu
Version 1.1
by Akin

Introduction

Ever wanted to have an options menu that allows you to adjust the volumes of the various sounds in the game? Well, thats just what this script allows you to do. The script sets up variables to adjust volume of the sounds in game. You can set the variables to any integer from 0 to 100 and the volumes of the associated sounds will be lowered by the percentage of the value. You can also adjust the music to not change when entering a battle.

Features

  • Background Music Volume adjustment
  • Background Sounds Volume adjustment
  • Musical Effects Volume adjustment
  • Event Sounds Volume adjustment
  • Sounds in battle adjusted
  • Ability to maintain currently playing BGM and BGS upon entering combat
  • The options menu and audio adjustment script are separate so you can customize how audio is adjusted.

Updates
1.0 - Initial release
1.1 - Added ability to maintain the currently playing BGM and BGS upon entering combat.

Screenshots
None

Demo
none

Scripts

This is the audio adjustment script
Code:
#################################################################
# Audio Adjustment Script version 1.1                           #
#################################################################
#   by Akin                                                     #
#    Credit to The Sleeping Leonhart who's XP Options script    #
#    helped me learn and to DerVVulfman who helped me find      #
#    an easy location to change battle sounds                   #
#################################################################
#   This script allows the the volumes of Background Music,     #
#   Background Sound, Sound Effects, and Music Effects          #
#   Though the use of the following variables from 0-100        #
#   $game_system.bgm_volume                                     #
#   $game_system.bgs_volume                                     #
#   $game_system.se_volume                                      #
#   $game_system.me_volume                                      #
#################################################################
#   Simpley use my GUI or someone else's to set the volumes     #
#   with lines like this                                        #
#   "$game_system.se_volume = 90"                               #
#   "$game_system.bgs_volume = 23"                              #
#   Just keep the value between 0 and 100                       #
#                                                               #
#   To reset the volumes of currently playing BGM and           #
#   BGS use the following lines.                                #
#   Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)   #
#   Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)   #
#                                                               # 
#   To continue playing the currently playing BGM and BGS upon  #
#   entering combat. Use the following command.                 #
#   "$game_system.battle_music_mode = 1"                        #
#                                                               #
#   Use "$game_system.battle_music_mode = 0" to return to the   #
#   traditional method of changing BGM's and BGS upon battle    #
#################################################################
#  Release Notes                                                #
#  1.0 - Initial Release                                        #
#  1.1 - Added ability to continue music playing though combat  #
#################################################################

# This adds on to the Audio module and adjusts playback volumes by the adjustment value
module Audio
  def self.play_adjust(sound_file, adjustment)  # accepts a sound file and an adjustment value from 0-100
    original_volume = sound_file.volume   # stores the original volume of the sound file
    sound_file.volume = Integer(original_volume * adjustment / 100)   # resets the sound volume to the adjustment %
    sound_file.play   # plays the sound file
    sound_file.volume = original_volume  # resets the volume of the orginal file
  end
end

# Replaces the current sound module so that all sound effects that are called for in
# the game and in scripts that use "Sound.play_X" play at the correct volume
module Sound

  # Cursor
  def self.play_cursor
    Audio.play_adjust($data_system.sounds[0], $game_system.se_volume)
  end

  # Decision
  def self.play_decision
    Audio.play_adjust($data_system.sounds[1], $game_system.se_volume)
  end

  # Cancel
  def self.play_cancel
    Audio.play_adjust($data_system.sounds[2], $game_system.se_volume)
  end

  # Buzzer
  def self.play_buzzer
    Audio.play_adjust($data_system.sounds[3], $game_system.se_volume)
  end

  # Equip
  def self.play_equip
    Audio.play_adjust($data_system.sounds[4], $game_system.se_volume)
  end

  # Save
  def self.play_save
    Audio.play_adjust($data_system.sounds[5], $game_system.se_volume)
  end

  # Load
  def self.play_load
    Audio.play_adjust($data_system.sounds[6], $game_system.se_volume)
  end

  # Battle Start
  def self.play_battle_start
    Audio.play_adjust($data_system.sounds[7], $game_system.se_volume)
  end

  # Escape
  def self.play_escape
    Audio.play_adjust($data_system.sounds[8], $game_system.se_volume)
  end

  # Enemy Attack
  def self.play_enemy_attack
    Audio.play_adjust($data_system.sounds[9], $game_system.se_volume)
  end

  # Enemy Damage
  def self.play_enemy_damage
    Audio.play_adjust($data_system.sounds[10], $game_system.se_volume)
  end

  # Enemy Collapse
  def self.play_enemy_collapse
    Audio.play_adjust($data_system.sounds[11], $game_system.se_volume)
  end

  # Actor Damage
  def self.play_actor_damage
    Audio.play_adjust($data_system.sounds[12], $game_system.se_volume)
  end

  # Actor Collapse
  def self.play_actor_collapse
    Audio.play_adjust($data_system.sounds[13], $game_system.se_volume)
  end

  # Recovery
  def self.play_recovery
    Audio.play_adjust($data_system.sounds[14], $game_system.se_volume)
  end

  # Miss
  def self.play_miss
    Audio.play_adjust($data_system.sounds[15], $game_system.se_volume)
  end

  # Evasion
  def self.play_evasion
    Audio.play_adjust($data_system.sounds[16], $game_system.se_volume)
  end

  # Shop
  def self.play_shop
    Audio.play_adjust($data_system.sounds[17], $game_system.se_volume)
  end

  # Use Item
  def self.play_use_item
    Audio.play_adjust($data_system.sounds[18], $game_system.se_volume)
  end

  # Use Skill
  def self.play_use_skill
    Audio.play_adjust($data_system.sounds[19], $game_system.se_volume)
  end
end

# Modifies the game system to add in the optional volume adjustments
class Game_System
  attr_accessor :bgm_volume
  attr_accessor :se_volume
  attr_accessor :bgs_volume
  attr_accessor :me_volume
  attr_accessor :battle_music_mode
  alias akin_sound_ini_game_system initialize
  
  def initialize
    akin_sound_ini_game_system
    # BGM, BGS, SE and ME Volume Values for storage
    @bgm_volume = 100; @se_volume = 100; @bgs_volume = 100; @me_volume = 100; @battle_music_mode = 0;
  end
end

# Edits the game_interpreter so that all event sounds are played at the correct volume
class Game_Interpreter
  def command_241
    Audio.play_adjust(@params[0], $game_system.bgm_volume) #BGM
    return true
  end
  def command_245
    Audio.play_adjust(@params[0], $game_system.bgs_volume) #BGS
    return true
  end
  def command_249
    Audio.play_adjust(@params[0], $game_system.me_volume) #ME
    return true
  end
  def command_250
    Audio.play_adjust(@params[0], $game_system.se_volume) #SE
    return true
  end
end

# Edits the game_map to play autoplayed BGS and BGM's at the correct volume
class Game_Map
  def autoplay
    Audio.play_adjust(@map.bgm, $game_system.bgm_volume) if @map.autoplay_bgm
    Audio.play_adjust(@map.bgs, $game_system.bgs_volume) if @map.autoplay_bgs
  end
end

# Edits game_vehicle to play the correct volume sound when mounting a vehicle
class Game_Vehicle < Game_Character
  def get_on
    @driving = true
    @walk_anime = true
    @step_anime = true
    if @type == 2                                    # If airship
      @priority_type = 2                             # Change priority to "Above Characters"
    end
    Audio.play_adjust(@bgm, $game_system.bgm_volume) # Start BGM
  end
end

# Edits game_player to play the correct volume sound after dismounting a vehicle
class Game_Player < Game_Character
  def get_off_vehicle
    if in_airship?                                # Airship
      return unless airship_land_ok?(@x, @y)      # Can't land?
    else                                          # Boat/ship
      front_x = $game_map.x_with_direction(@x, @direction)
      front_y = $game_map.y_with_direction(@y, @direction)
      return unless can_walk?(front_x, front_y)   # Can't touch land?
    end
    $game_map.vehicles[@vehicle_type].get_off     # Get off processing
    if in_airship?                                # Airship
      @direction = 2                              # Face down
    else                                          # Boat/ship
      force_move_forward                          # Move one step forward
      @transparent = false                        # Remove transparency
    end
    @vehicle_getting_off = true                   # Start getting off operation
    @move_speed = 4                               # Return move speed
    @through = false                              # Passage OFF
    Audio.play_adjust(@walking_bgm, $game_system.bgm_volume) # Restore walking BGM
    make_encounter_count                          # Initialize encounter
  end
end

# Edits sprite_base to play sound effects from battle animations at the correct volume
class Sprite_Base < Sprite
  def animation_process_timing(timing)
    Audio.play_adjust(timing.se, $game_system.se_volume)
    case timing.flash_scope
    when 1
      self.flash(timing.flash_color, timing.flash_duration * 4)
    when 2
      if viewport != nil
        viewport.flash(timing.flash_color, timing.flash_duration * 4)
      end
    when 3
      self.flash(nil, timing.flash_duration * 4)
    end
  end
end

# Edits scene_map to play the battle BGM at the correct volume
class Scene_Map < Scene_Base
  def call_battle
    @spriteset.update
    Graphics.update
    $game_player.make_encounter_count
    $game_player.straighten
    $game_temp.map_bgm = RPG::BGM.last
    $game_temp.map_bgs = RPG::BGS.last
    unless $game_system.battle_music_mode == 1 # Does not stop current must if battle_music mode is 1
      RPG::BGM.stop
      RPG::BGS.stop
    end
      Sound.play_battle_start
    unless $game_system.battle_music_mode == 1
      Audio.play_adjust($game_system.battle_bgm, $game_system.bgm_volume) # Does not play battle music if battle mode is 1
    end
    $game_temp.next_scene = nil
    $scene = Scene_Battle.new
  end
end

# Edits the scene_battle class to play the BGM and BGS of the returning map and
# the victory ME at the correct volumes
class Scene_Battle < Scene_Base
  def battle_end(result)
    if result == 2 and not $game_troop.can_lose
      call_gameover
    else
      $game_party.clear_actions
      $game_party.remove_states_battle
      $game_troop.clear
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call(result)
        $game_temp.battle_proc = nil
      end
      unless $BTEST or $game_system.battle_music_mode == 1 #does not restore BGM if battle music mode 1 is enabled
        Audio.play_adjust($game_temp.map_bgm, $game_system.bgm_volume)
        Audio.play_adjust($game_temp.map_bgs, $game_system.bgs_volume)
      end
      $scene = Scene_Map.new
      @message_window.clear
      Graphics.fadeout(30)
    end
    $game_temp.in_battle = false
  end

  def process_victory
    @info_viewport.visible = false
    @message_window.visible = true
    unless $game_system.battle_music_mode == 1 #does not play victory ME if battle music mode 1 is enabled
    RPG::BGM.stop
    Audio.play_adjust($game_system.battle_end_me, $game_system.me_volume)
    end
    unless $BTEST or $game_system.battle_music_mode == 1 #does not restore BGM if battle music mode 1 is enabled
      Audio.play_adjust($game_temp.map_bgm, $game_system.bgm_volume)
      Audio.play_adjust($game_temp.map_bgs, $game_system.bgs_volume)
    end
    display_exp_and_gold
    display_drop_items
    display_level_up
    battle_end(0)
  end
end

# Edits the scene_gameover to play the gameover ME at the correct volume
class Scene_Gameover < Scene_Base
  def start
    super
    RPG::BGM.stop
    RPG::BGS.stop
    Audio.play_adjust($data_system.gameover_me, $game_system.me_volume)
    Graphics.transition(120)
    Graphics.freeze
    create_gameover_graphic
  end
end

# Edits the scene_file so that music plays at the correct volume upon loading
class Scene_File < Scene_Base
  def do_load
    file = File.open(@savefile_windows[@index].filename, "rb")
    read_save_data(file)
    file.close
    $scene = Scene_Map.new
    RPG::BGM.fade(1500)
    Graphics.fadeout(60)
    Graphics.wait(40)
    Audio.play_adjust(@last_bgm, $game_system.bgm_volume)
    Audio.play_adjust(@last_bgs, $game_system.bgs_volume)
  end
end

This is a simple audio options menu I made
Code:
####################################################
# Custom Options Menu                              #
####################################################
#     by Akin                                      #
#       credit to 'L' who's custom menu helped     #
#       me figure out what to do                   #
####################################################
#   This script calls an audio options menu.       #
#                                                  #
#  Call using "$scene = Scene_Options.new"         #
#                                                  #
####################################################

module OptionCommand
	#Main Option Commands
	Audio			    = 'Audio'
	Controls		  = 'Controls'
	Exit_Options	= 'Back'
  #Audio Option commands
  Audiobgm      = 'Music Volume'
  Audiobgs      = 'Background Effects Volume'
  Audiome       = 'Musical Effects Volume'
  Audiose       = 'Sound Effects volume'
  #BGM Options
  Audiobgm0    = '0'
  Audiobgm1    = '1'
  Audiobgm2    = '2'
  Audiobgm3    = '3'
  Audiobgm4    = '4'
  Audiobgm5    = '5'
  Audiobgm6    = '6'
  Audiobgm7    = '7'
  Audiobgm8    = '8'
  Audiobgm9    = '9'
  Audiobgm10   = '10'
  #BGS Options
  Audiobgs0    = '0'
  Audiobgs1    = '1'
  Audiobgs2    = '2'
  Audiobgs3    = '3'
  Audiobgs4    = '4'
  Audiobgs5    = '5'
  Audiobgs6    = '6'
  Audiobgs7    = '7'
  Audiobgs8    = '8'
  Audiobgs9    = '9'
  Audiobgs10   = '10'
  #SE Options
  Audiose0    = '0'
  Audiose1    = '1'
  Audiose2    = '2'
  Audiose3    = '3'
  Audiose4    = '4'
  Audiose5    = '5'
  Audiose6    = '6'
  Audiose7    = '7'
  Audiose8    = '8'
  Audiose9    = '9'
  Audiose10   = '10'
  #ME Options
  Audiome0    = '0'
  Audiome1    = '1'
  Audiome2    = '2'
  Audiome3    = '3'
  Audiome4    = '4'
  Audiome5    = '5'
  Audiome6    = '6'
  Audiome7    = '7'
  Audiome8    = '8'
  Audiome9    = '9'
  Audiome10   = '10'
end

#==============================================================================
# ** Scene_Options
#------------------------------------------------------------------------------
#  This class performs the Options screen processing.
#==============================================================================

class Scene_Options < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(options_index = 0)
    @options_index = options_index
    options_init
  end
  #--------------------------------------------------------------------------
  # * Set Commands
  #--------------------------------------------------------------------------
  def options_init
    @options = []
    op1 = OptionCommand::Audio
    op2 = OptionCommand::Controls
    op3 = OptionCommand::Exit_Options
    @options.push(op1, op2, op3).flatten!
    
    @audio_options = []
	  aud1 = OptionCommand::Audiobgm
	  aud2 = OptionCommand::Audiobgs
	  aud3 = OptionCommand::Audiome
	  aud4 = OptionCommand::Audiose
    @audio_options.push(aud1, aud2, aud3, aud4).flatten!
    
      @bgm_options = []
      bgm0  = OptionCommand::Audiobgm0
      bgm1  = OptionCommand::Audiobgm1
      bgm2  = OptionCommand::Audiobgm2
      bgm3  = OptionCommand::Audiobgm3
      bgm4  = OptionCommand::Audiobgm4
      bgm5  = OptionCommand::Audiobgm5
      bgm6  = OptionCommand::Audiobgm6
      bgm7  = OptionCommand::Audiobgm7
      bgm8  = OptionCommand::Audiobgm8
      bgm9  = OptionCommand::Audiobgm9
      bgm10 = OptionCommand::Audiobgm10
      @bgm_options.push(bgm0, bgm1, bgm2, bgm3, bgm4, bgm5, bgm6, bgm7, bgm8, bgm9, bgm10).flatten!
      
      @bgs_options = []
      bgs0  = OptionCommand::Audiobgs0
      bgs1  = OptionCommand::Audiobgs1
      bgs2  = OptionCommand::Audiobgs2
      bgs3  = OptionCommand::Audiobgs3
      bgs4  = OptionCommand::Audiobgs4
      bgs5  = OptionCommand::Audiobgs5
      bgs6  = OptionCommand::Audiobgs6
      bgs7  = OptionCommand::Audiobgs7
      bgs8  = OptionCommand::Audiobgs8
      bgs9  = OptionCommand::Audiobgs9
      bgs10 = OptionCommand::Audiobgs10
      @bgs_options.push(bgs0, bgs1, bgs2, bgs3, bgs4, bgs5, bgs6, bgs7, bgs8, bgs9, bgs10).flatten!
      
      @se_options = []
      se0  = OptionCommand::Audiose0
      se1  = OptionCommand::Audiose1
      se2  = OptionCommand::Audiose2
      se3  = OptionCommand::Audiose3
      se4  = OptionCommand::Audiose4
      se5  = OptionCommand::Audiose5
      se6  = OptionCommand::Audiose6
      se7  = OptionCommand::Audiose7
      se8  = OptionCommand::Audiose8
      se9  = OptionCommand::Audiose9
      se10 = OptionCommand::Audiose10
      @se_options.push(se0, se1, se2, se3, se4, se5, se6, se7, se8, se9, se10).flatten!
      
      @me_options = []
      me0  = OptionCommand::Audiome0
      me1  = OptionCommand::Audiome1
      me2  = OptionCommand::Audiome2
      me3  = OptionCommand::Audiome3
      me4  = OptionCommand::Audiome4
      me5  = OptionCommand::Audiome5
      me6  = OptionCommand::Audiome6
      me7  = OptionCommand::Audiome7
      me8  = OptionCommand::Audiome8
      me9  = OptionCommand::Audiome9
      me10 = OptionCommand::Audiome10
      @me_options.push(me0, me1, me2, me3, me4, me5, me6, me7, me8, me9, me10).flatten!
  end
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_options_window
    create_audio_window
    create_bgm_window
    create_bgs_window
    create_se_window
    create_me_window
    create_controls_window
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
	  @help_window.set_text("Options")
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @options_window.dispose
    @audio_options_window.dispose
      @bgm_options_window.dispose
      @bgs_options_window.dispose
      @se_options_window.dispose
      @me_options_window.dispose
    @controls_window.dispose
	  @help_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @options_window.update
    @audio_options_window.update
      @bgm_options_window.update
      @bgs_options_window.update
      @se_options_window.update
      @me_options_window.update
    @controls_window.update
	  @help_window.update
    if @options_window.active
      update_options_selection
    elsif @audio_options_window.active
      update_audio_options_selection
    elsif @bgm_options_window.active
      update_bgm_options_selection
    elsif @bgs_options_window.active
      update_bgs_options_selection
    elsif @se_options_window.active
      update_se_options_selection
    elsif @me_options_window.active
      update_me_options_selection
    elsif @controls_window.active
      update_controls_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Create Main Option Selection
  #--------------------------------------------------------------------------
  def create_options_window
    @options_window = Window_Command.new(160, @options)
    @options_window.index = @options_index
	  @options_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Audio Options Window
  #--------------------------------------------------------------------------
  def create_audio_window
    @audio_options_window = Window_Command.new(277, @audio_options)
    @audio_options_window.visible = false
    @audio_options_window.active = false
    @audio_options_window.x = 160
    @audio_options_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Audio-BGM Options Window
  #--------------------------------------------------------------------------
  def create_bgm_window
    @bgm_options_window = Window_Command.new(62, @bgm_options)
    @bgm_options_window.visible = false
    @bgm_options_window.active = false
    @bgm_options_window.x = 437
    @bgm_options_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Audio-BGS Options Window
  #--------------------------------------------------------------------------
  def create_bgs_window
    @bgs_options_window = Window_Command.new(62, @bgs_options)
    @bgs_options_window.visible = false
    @bgs_options_window.active = false
    @bgs_options_window.x = 437
    @bgs_options_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Audio-SE Options Window
  #--------------------------------------------------------------------------
  def create_se_window
    @se_options_window = Window_Command.new(62, @se_options)
    @se_options_window.visible = false
    @se_options_window.active = false
    @se_options_window.x = 437
    @se_options_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Audio-ME Options Window
  #--------------------------------------------------------------------------
  def create_me_window
    @me_options_window = Window_Command.new(62, @me_options)
    @me_options_window.visible = false
    @me_options_window.active = false
    @me_options_window.x = 437
    @me_options_window.y = 56
  end
  #--------------------------------------------------------------------------
  # * Create Controls Options Window
  #--------------------------------------------------------------------------
  def create_controls_window
    @controls_window = Window_Base.new(161, 57, 292, 300)
    @controls_window.contents.draw_text(0, -2, 100, 24, "Controls")
    @controls_window.contents.draw_text(0, 24, 300, 24, "To Access the system controls")
    @controls_window.contents.draw_text(0, 48, 300, 24, "Press F1 at any time")
    @controls_window.contents.draw_text(40, 96, 300, 24, "A")
    @controls_window.contents.draw_text(40, 120, 300, 24, "B")
    @controls_window.contents.draw_text(40, 144, 300, 24, "C")
    @controls_window.contents.draw_text(40, 168, 300, 24, "L")
    @controls_window.contents.draw_text(40, 192, 300, 24, "R")
    @controls_window.contents.draw_text(40, 216, 300, 24, "X")
    @controls_window.contents.draw_text(40, 240, 300, 24, "Y")
    @controls_window.contents.draw_text(60, 96, 300, 24, "::  Dash")
    @controls_window.contents.draw_text(60, 120, 300, 24, "::  Cancel/Menu")
    @controls_window.contents.draw_text(60, 144, 300, 24, "::  Confirm/Talk")
    @controls_window.contents.draw_text(60, 168, 300, 24, "::  Menu Previous")
    @controls_window.contents.draw_text(60, 192, 300, 24, "::  Menu Next")
    @controls_window.contents.draw_text(60, 216, 300, 24, "::  Not Used")
    @controls_window.contents.draw_text(60, 240, 300, 24, "::  Not Used")
    @controls_window.visible = false
    @controls_window.active = false
  end
  #--------------------------------------------------------------------------
  # * Return to Original Screen
  #--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Menu.new(0) #-----------Change this number to the options spot -1 on main menu-----------------
  end
  #--------------------------------------------------------------------------
  # * Update Options Selection
  #--------------------------------------------------------------------------
  def update_options_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      main_options_input
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio Options Selection
  #--------------------------------------------------------------------------
  def update_audio_options_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @options_window.active = true
      @audio_options_window.active = false
      @audio_options_window.visible = false
      @audio_options_window.index = 0
      return
    elsif Input.trigger?(Input::C)
      audio_options_input
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-BGM Options Selection
  #--------------------------------------------------------------------------
  def update_bgm_options_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @audio_options_window.active = true
      @bgm_options_window.active = false
      @bgm_options_window.visible = false
      @bgm_options_window.index = 0
      return
    elsif Input.trigger?(Input::C)
      bgm_options_input
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-BGS Options Selection
  #--------------------------------------------------------------------------
  def update_bgs_options_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @audio_options_window.active = true
      @bgs_options_window.active = false
      @bgs_options_window.visible = false
      @bgs_options_window.index = 0
      return
    elsif Input.trigger?(Input::C)
      bgs_options_input
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-SE Options Selection
  #--------------------------------------------------------------------------
  def update_se_options_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @audio_options_window.active = true
      @se_options_window.active = false
      @se_options_window.visible = false
      @se_options_window.index = 0
      return
    elsif Input.trigger?(Input::C)
      se_options_input
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-ME Options Selection
  #--------------------------------------------------------------------------
  def update_me_options_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @audio_options_window.active = true
      @me_options_window.active = false
      @me_options_window.visible = false
      @me_options_window.index = 0
      return
    elsif Input.trigger?(Input::C)
      me_options_input
    end
  end
  #--------------------------------------------------------------------------
  # * Update Controls Selection
  #--------------------------------------------------------------------------
  def update_controls_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @options_window.active = true
      @controls_window.active = false
      @controls_window.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # * Update Main Options InputCheck
  #--------------------------------------------------------------------------
  def main_options_input
    option = @options[@options_window.index]
    Sound.play_decision
    # Checks Options Commands
    case option
    when OptionCommand::Audio  #calls Audio options subwindow
      @audio_options_window.active = true
      @audio_options_window.visible = true
      @options_window.active = false
    when OptionCommand::Controls #Controls
      @controls_window.active = true
      @controls_window.visible = true
      @options_window.active = false 
	  when OptionCommand::Exit_Options #Return to Main Menu
      return_scene
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio Options InputCheck
  #--------------------------------------------------------------------------
  def audio_options_input
    audio_option = @audio_options[@audio_options_window.index]
    Sound.play_decision
    # Checks Graphics Options Commands
    case audio_option
    when OptionCommand::Audiobgm  #Adjust BGM
      @bgm_options_window.index = Integer($game_system.bgm_volume / 10)
      @bgm_options_window.active = true
      @bgm_options_window.visible = true
      @audio_options_window.active = false
    when OptionCommand::Audiobgs  #Adjust BGS
      @bgs_options_window.index = Integer($game_system.bgs_volume / 10)
      @bgs_options_window.active = true
      @bgs_options_window.visible = true
      @audio_options_window.active = false
	  when OptionCommand::Audiome  #Adjust ME
      @me_options_window.index = Integer($game_system.me_volume / 10)
      @me_options_window.active = true
      @me_options_window.visible = true
      @audio_options_window.active = false
	  when OptionCommand::Audiose  #Adjust SE
      @se_options_window.index = Integer($game_system.se_volume / 10)
      @se_options_window.active = true
      @se_options_window.visible = true
      @audio_options_window.active = false
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-BGM Options InputCheck
  #--------------------------------------------------------------------------
  def bgm_options_input
    bgm_option = @bgm_options[@bgm_options_window.index]
    Sound.play_decision
    # Checks BGM Options Commands
    case bgm_option
    when OptionCommand::Audiobgm0  #BGM Volume 0%
      $game_system.bgm_volume = 0
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm1  #BGM Volume 10%
      $game_system.bgm_volume = 10
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm2  #BGM Volume 20%
      $game_system.bgm_volume = 20
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm3  #BGM Volume 30%
      $game_system.bgm_volume = 30
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm4  #BGM Volume 40%
      $game_system.bgm_volume = 40
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm5  #BGM Volume 50%
      $game_system.bgm_volume = 50
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm6  #BGM Volume 60%
      $game_system.bgm_volume = 60
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm7  #BGM Volume 70%
      $game_system.bgm_volume = 70
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm8  #BGM Volume 80%
      $game_system.bgm_volume = 80
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm9  #BGM Volume 90%
      $game_system.bgm_volume = 90
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    when OptionCommand::Audiobgm10  #BGM Volume 100%
      $game_system.bgm_volume = 100
      Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-BGS Options InputCheck
  #--------------------------------------------------------------------------
  def bgs_options_input
    bgs_option = @bgs_options[@bgs_options_window.index]
    Sound.play_decision
    # Checks BGM Options Commands
    case bgs_option
    when OptionCommand::Audiobgs0  #BGS Volume 0%
      $game_system.bgs_volume = 0
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs1  #BGS Volume 10%
      $game_system.bgs_volume = 10
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs2  #BGS Volume 20%
      $game_system.bgs_volume = 20
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs3  #BGS Volume 30%
      $game_system.bgs_volume = 30
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs4  #BGS Volume 40%
      $game_system.bgs_volume = 40
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs5  #BGS Volume 50%
      $game_system.bgs_volume = 50
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs6  #BGS Volume 60%
      $game_system.bgs_volume = 60
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs7  #BGS Volume 70%
      $game_system.bgs_volume = 70
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs8  #BGS Volume 80%
      $game_system.bgs_volume = 80
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs9  #BGS Volume 90%
      $game_system.bgs_volume = 90
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    when OptionCommand::Audiobgs10  #BGS Volume 100%
      $game_system.bgs_volume = 100
      Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-SE Options InputCheck
  #--------------------------------------------------------------------------
  def se_options_input
    se_option = @se_options[@se_options_window.index]
    Sound.play_decision
    # Checks BGM Options Commands
    case se_option
    when OptionCommand::Audiose0  #SE Volume 0%
      $game_system.se_volume = 0
    when OptionCommand::Audiose1  #SE Volume 10%
      $game_system.se_volume = 10
    when OptionCommand::Audiose2  #SE Volume 20%
      $game_system.se_volume = 20
    when OptionCommand::Audiose3  #SE Volume 30%
      $game_system.se_volume = 30
    when OptionCommand::Audiose4  #SE Volume 40%
      $game_system.se_volume = 40
    when OptionCommand::Audiose5  #SE Volume 50%
      $game_system.se_volume = 50
    when OptionCommand::Audiose6  #SE Volume 60%
      $game_system.se_volume = 60
    when OptionCommand::Audiose7  #SE Volume 70%
      $game_system.se_volume = 70
    when OptionCommand::Audiose8  #SE Volume 80%
      $game_system.se_volume = 80
    when OptionCommand::Audiose9  #SE Volume 90%
      $game_system.se_volume = 90
    when OptionCommand::Audiose10  #SE Volume 100%
      $game_system.se_volume = 100
    end
  end
  #--------------------------------------------------------------------------
  # * Update Audio-ME Options InputCheck
  #--------------------------------------------------------------------------
  def me_options_input
    me_option = @me_options[@me_options_window.index]
    Sound.play_decision
    # Checks BGM Options Commands
    case me_option
    when OptionCommand::Audiome0  #ME Volume 0%
      $game_system.me_volume = 0
    when OptionCommand::Audiome1  #ME Volume 10%
      $game_system.me_volume = 10
    when OptionCommand::Audiome2  #ME Volume 20%
      $game_system.me_volume = 20
    when OptionCommand::Audiome3  #ME Volume 30%
      $game_system.me_volume = 30
    when OptionCommand::Audiome4  #ME Volume 40%
      $game_system.me_volume = 40
    when OptionCommand::Audiome5  #ME Volume 50%
      $game_system.me_volume = 50
    when OptionCommand::Audiome6  #ME Volume 60%
      $game_system.me_volume = 60
    when OptionCommand::Audiome7  #ME Volume 70%
      $game_system.me_volume = 70
    when OptionCommand::Audiome8  #ME Volume 80%
      $game_system.me_volume = 80
    when OptionCommand::Audiome9  #ME Volume 90%
      $game_system.me_volume = 90
    when OptionCommand::Audiome10  #ME Volume 100%
      $game_system.me_volume = 100
    end
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
	def update_help
		@help_window.set_text("Options")
	end
end

Instructions

Put the scripts in the usual place above main

Use the following variables to change the sound in game. They can be any value from 0 to 100.
Code:
$game_system.bgm_volume
$game_system.bgs_volume
$game_system.se_volume
$game_system.me_volume

# Example.
$game_system.se_volume = 50

Use the following lines of code to adjust the volume of currently playing Background Music or sounds
Code:
Audio.play_adjust(RPG::BGM.last, $game_system.bgm_volume)
#for BGM

Audio.play_adjust(RPG::BGS.last, $game_system.bgs_volume)
# for BGS

Set these values to determine if you want the the currently playing BGM and BGS to stop playing upon entering a battle.

Code:
$game_system.battle_music_mode = 1
# To not change BGM/BGS

$game_system.battle_music_mode = 0
# To change BGM/BGS upon battle entry (default)

Compatibility

I don't know of any, but this does a total rewrite of the Sound Module and several rewrites to other game classes. Hopefully most conflicts can be resolved by placing this script higher.

Credits and Thanks

Thanks to Sleeping Leonhart, DerVVulfman, SephirothSpawn, and L.
I wouldn't have been able to write this without their help and previous work.

Author's Notes

This is my first script so any constructive feedback would be helpful.

Terms and Conditions

Use however you want just credit me. If you happen to put together a nice looking GUI send me a PM.
 

Akin

Member

Updated to allow BGM and BGS to not be stopped and changed upon entering a battle.
Default is
$game_system.battle_music_mode = 0
for traditional way of stopping BGM and BGS

and
$game_system.battle_music_mode = 1
to not stop the currently playing BGM and BGS upon entering combat.
 

Akin

Member

really I'd love to see it if you wouldn't mind. I looked around XP scripts alot before I wrote this but most of them were buggy. For example, if you adjust the volume to 0 the sound would turn off, or you could raise the volume of background BGM's and BGS's that were meant to be played low by repeatedly lowering and raise the volume levels. That or they just wouldn't function for sounds that we're called from events or sound effects durning combat.
 
well my script requires that you have all volumes at 100 and it will auto adjust depending on your options.

you were asked for effect and music levels (effect = BGS + SE and music = ME + BGM) and you could adjust them from off (0%) upwards in each percent to 100%.

It is just a simple script as i dont really find it neccessary to be anything but that... i work with lots of people in TIGSource so im not making many huge games and make many minigames and such... ive just reused my menu system over and over again... hopefully once my new resolution system is finished people will act more like me and go for small catchy minigames and such than the huge never to be completed games...
 

Akin

Member

well if thats all your script is its not really a fair compairison

Code:
module Audio
  def self.play_adjust(sound_file, adjustment)  # accepts a sound file and an adjustment value from 0-100
    original_volume = sound_file.volume   # stores the original volume of the sound file
    sound_file.volume = Integer(original_volume * adjustment / 100)   # resets the sound volume to the adjustment %
    sound_file.play   # plays the sound file
    sound_file.volume = original_volume  # resets the volume of the orginal file
  end
end

Thats the only part of this script that actually adjusts volume since 2 lines are for storing and restoring the volume. Thats 6 lines of code. I'm not trying to beef I'm just trying to make the point that it's not really a fair comparison to say that it takes "so much more code in VX over XP" the majority of the code comes from inserting the adjusted play values into the existing code. It would honestly take just as much coding to do the same for XP not just "3 lines".
 
its not as hard as it seems... and it doesnt have to be long...

most scripts are long because people want them plug-and-play and they want more than just 1 other option that you may have made specifically for your self... thats whats going on with my resolution script... ive made a tilemap class that allows 320*240 and new viewports, sprite resizers and windows compatible too... but because other peopl want different choices im having to add hundreds of new edits to make it to thier standards... same for this
 

Akin

Member

Yes exactly its long because its setting up to work "plug and play" so I don't have to keep calling it every time I need it. It has to be called whenever there is a sound played by the game, and by default the game calls ALOT of sounds, in both VX and XP.
 

shedt

Member

Sorry I'm new to scripting.

Call using "$scene = Scene_Options.new"

HUH?

I'm trying to learn and understand all the menu's and whatnot as it is. Thank you for any help. Anyone have some good links for learning?
 
shedt":1u2cwvls said:
Sorry I'm new to scripting.

Call using "$scene = Scene_Options.new"

HUH?

I'm trying to learn and understand all the menu's and whatnot as it is. Thank you for any help. Anyone have some good links for learning?

Just paste $scene = Scene_Options.new into the little box that pops up when you click on the script event (last page, under "advanced")

Nice script btw, I'd mostly just use it for the keep current BGM playing feature.
 

shedt

Member

Thank you!

I also added the script

#L's Custom Menu - Simple DMS Edit (RMVX ver.) Rev.1

And I added the line of code here (line 289):

  #--------------------------------------------------------------------------
  # * Update System Command Check
  #--------------------------------------------------------------------------
  def sys_command_input
    # Loads Current Command
    sys_command = @sys_commands[@sys_command_window.index]
    # Play decision SE
    Sound.play_decision
    # Checks Commands
    case sys_command
    when MenuCommand::Option  #option add $scene = Scene_Options.new for audio
      $scene = Scene_Options.new
      command_option
    when MenuCommand::Save  #save

Lucky first time guess. Just woke up not long ago, looked over the script(s) last night alot trying to learn.

Now all i want to do is add the options menu to the title screen.....

Thanks!
 

apkx24

Member

can u make it to where it SAVES the position of the bgm?
like ur in the middle of a long song, you fight a random battle, and after u win it RESUMES the song?
(basically a SAVE bgm position)
they hav this in TONS of regualr official rpgs. so im pretty sure this is possible
 
apkx24":t0reexxg said:
can u make it to where it SAVES the position of the bgm?
like ur in the middle of a long song, you fight a random battle, and after u win it RESUMES the song?
(basically a SAVE bgm position)
they hav this in TONS of regualr official rpgs. so im pretty sure this is possible

I was actually going to ask this as well.  It really sucks if the map's BGM is long, but has random encounters.
 
Sorry, but I didn't get the other poster a page back - so which part of which script do you need to change to add more animation frames?
Also, can you add more poses on the animation sheet?
 

Akin

Member

apkx24":vr35rnps said:
can u make it to where it SAVES the position of the bgm?
like ur in the middle of a long song, you fight a random battle, and after u win it RESUMES the song?
(basically a SAVE bgm position)
they hav this in TONS of regualr official rpgs. so im pretty sure this is possible

Nope, This was actually discussed in this thread here
http://rmxp.org/forums/index.php?topic=47138

phoenixxstarr":vr35rnps said:
I love the script, but I was wondering if you provide me with a code to add it to the menu. Thank you for your time.

I'm sorry I don't know the code off the top of my head and I don't have the time to be looking it up atm. Sorry about the late replies I've been busy lately.
 

yion

Member

Ok...it seems to have a problem with Dargor's Large Party Script.
His Script gets Syntax Error Line 76.
(happens after the Option Menu)
I also posted this problem in Dargor's Large Party Script Topic.

EDIT 2:
Compability Problem:
RPG Tenkentai Sideview Battle
(some sounds dont get their volume down)
Longer Victory Screen (final fantasy style)
(Win ME is not affected...but i fixed it myself, just
added
Audio.play_adjust($game_system.battle_end_me, $game_system.me_volume)
after the play ME thingy...

EDIT:
NVM. its just making mush Errors because of it opens the Menu after the Adjust-Menu.
Can you make it not-opening-the-Menu-after?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top