Help with changing background music volume
#1
Hi,

I've been experimenting with a menu option to reduce / increase the background music volume in my game.

The code works but the changes only take effect when a new piece of background music plays (it does not effect the current background music playing).

Does any one know the script command to stop and start background music?

I want to have the msuic stop and start when the levels are adjusted so they take effect immediatley.

Many Thanks!
Reply }
#2
why would you need a script for this? just re-adjust the volume and pitch worh the "play BGM" event command.
Reply }
#3
I've created a menu screen which has a volume slider to increase and decrease the background music volume here is the script:



Code:
#--------------------------------------------------------------------------
  def update_se_regulation
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @se_regulation = false
      @command_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @se_regulation = false
      @command_window.active = true
      return
    end
    if Input.repeat?(Input::RIGHT) and $game_system.se_volume < 100
      $game_system.se_play($data_system.cursor_se)
      $game_system.se_volume += 1
      @option_window.refresh
    end
    if Input.repeat?(Input::LEFT) and $game_system.se_volume > 0
      $game_system.se_play($data_system.cursor_se)
      $game_system.se_volume -= 1
      @option_window.refresh
    end
  end
  #--------------------------------------------------------------------------

The menu is supposed to allow the user to decrease or increase the background music - the problem is it only takes affect when the background music stops and starts again - not if it is currently playing, which is why I need to try and incorporate a stop and start value into this.
Reply }
#4
do you have a demo? im curious to see how this is different from using events.
Reply }
#5
To speed things up here is a link to another version of the same game I'm working on already uploaded - it has the same script for you to look at.

http://www.mediafire.com/?vwa1yy2us7uvu5y

The script is under the OPZIONI section - to see it in action start the game from any continue - press X to go to the menu and go to "Options" - the sound selection is in there.

It works but just needs an interupt to stop the background music from playing and then to start it again so it is at the new volume - which I can't seem to do!
Reply }
#6
I can see why you'd want that feature; default RPG Maker XP music is LOUD.

Try:
$game_system.bgs_memorize
$game_system.bgs_restore

EDIT: Nope, sorry. it's:
$game_system.bgm_memorize
$game_system.bgm_stop
$game_system.bgm_restore
I added it to both Input.trigger?s in def update_me_regulation and it worked.
also, the option menu was missing text. Is that because I didn't install fonts?
Reply }
#7
You can decrease the volume of the track already playing too, there is no need to stop and re-start it. Besides that, if you use $game_system.<sound>_memorize or restore, it'll override whatever you've memorized via events.

Here's a sample of how you could do it...

Code:
bgm_flag = $game_system.playing_bgm.is_a?(RPG::AudioFile)
bgs_flag = $game_system.playing_bgs.is_a?(RPG::AudioFile)
$game_system.playing_bgm.volume = new_bgm_volume if bgm_flag
$game_system.playing_bgs.volume = new_bgs_volume if bgs_flag

@KasperKalamity: These volume systems are implemented for the player, not the developer. Let's say the player is listening to music (not the game's music), but they're having trouble playing it on mute with no sound effects. That player can go in the menu and turn off the BGM, leaving the sound effects on. Or maybe they really like your game's soundtrack but can't stand the little menu 'blip blips' and such, they can turn off the sounds and still enjoy the game's music.
[Image: Button-BOTB.png]
[Image: Save-Point.gif][Image: Button-You-Tube2.png][Image: Button-Sound-Cloud2.png][Image: Button-Audio-Mack2.png]
[Image: LS-Banner.gif]
NEW ALBUM OUT NOW!

Reply }
#8
At MechanicalPen and Kain Nobel - Thanks very much for your help - all working now!

Oh also at MechanicalPen yes text is missing because the game uses custom fonts which will need to be installed.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Map as Background in menus jreagan406 2 4,897 03-01-2017, 10:39 PM
Last Post: jreagan406
   [Brainstorming] Pallete Changing. MechanicalPen 6 7,780 02-14-2014, 09:46 PM
Last Post: DerVVulfman
  Changing Window Styles in Game JackMonty 8 11,045 03-22-2013, 11:54 PM
Last Post: JackMonty
   [Atoa SBS] Changing the command window font MegaPowerNinja 3 8,332 04-12-2011, 10:23 PM
Last Post: Victor Sant
   changing stat effects for the defualt batle system? corpsegirl 13 17,532 10-25-2010, 08:15 PM
Last Post: corpsegirl
   Changing the walking animation shadow040 8 11,188 01-30-2010, 04:20 PM
Last Post: shadow040
   XAS Battle System, changing Leader pez 6 9,532 09-17-2009, 06:28 PM
Last Post: Legacy



Users browsing this thread: 1 Guest(s)