• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Essentials v15] Music and Sound Volume Controller

76
Posts
8
Years
    • Seen Oct 6, 2017
    [Essentials v15] Music and Sound Volume Controller


    Difficulty: Medium

    -----​

    First, in PScreen_Options copy and paste this
    Code:
      attr_accessor :volume #VOLUME
      attr_accessor :soundvolume #VOLUME
    right after this
    Code:
      attr_accessor :language
    Next, you're going to want to search for
    Code:
    @PokemonOptions=[
    Right after that, paste this:
    Code:
           NumberOption.new(_INTL("Music Volume"),_INTL("%d\%"),0,100, #VOLUME
             proc { $PokemonSystem.volume }, #VOLUME
             proc {|value| #VOLUME
               $PokemonSystem.volume=value #VOLUME
               if $game_system.playing_bgm != nil #VOLUME 
                 $game_system.playing_bgm.volume=value #VOLUME
                 $game_system.bgm_memorize #VOLUME
                  $game_system.bgm_stop #VOLUME
                  $game_system.bgm_restore #VOLUME
              end #VOLUME
             
              }
          ),
           NumberOption.new(_INTL("Sound Volume"),_INTL("%d\%"),0,100, #VOLUME
             proc { $PokemonSystem.soundvolume }, #VOLUME
             proc {|value| #VOLUME
               $PokemonSystem.soundvolume=value #VOLUME
               if $game_system.playing_bgs != nil #VOLUME
                 $game_system.playing_bgs.volume=value #VOLUME
                 $game_system.bgs_memorize #VOLUME
                  $game_system.bgs_stop #VOLUME
                  $game_system.bgs_restore #VOLUME
               end #VOLUME
             
              }
          ),
    That is all for PScreen_Options. Next, you are going to want to go into Game_System.
    Right BEFORE this:
    Code:
    Audio.bgm_play(name,volume,pitch,position)
    You are going to want to paste this:
    Code:
      def bgm_play_internal2(name,volume,pitch,position) #VOLUME
      volume=$PokemonSystem.volume if $PokemonSystem #VOLUME
    begin #VOLUME
    Now search for
    Code:
    def bgs_play(bgs)
    You are going to want to replace this:
    Code:
      def bgs_play(bgs)
        @playing_bgs = bgs==nil ? nil : bgs.clone
        if bgs != nil and bgs.name != ""
          if FileTest.audio_exist?("Audio/BGS/"+ bgs.name)
            Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch)
          end
    with this:
    Code:
      def bgs_play(bgs)
        $PokemonSystem.soundvolume=100 if !$PokemonSystem.soundvolume #VOLUME
        volume=$PokemonSystem.soundvolume #VOLUME
        @playing_bgs = bgs==nil ? nil : bgs.clone
        if bgs != nil and bgs.name != ""
          if FileTest.audio_exist?("Audio/BGS/"+ bgs.name)
            Audio.bgs_play("Audio/BGS/" + bgs.name, volume, bgs.pitch) #VOLUME
          end
    Now search for this:
    Code:
    def setDefaultBGM(bgm,volume=80,pitch=100)
    And paste this right after it:
    Code:
      volume=$PokemonSystem.volume if $PokemonSystem #VOLUME
    Search for this:
    Code:
    def me_play(me)
    And paste this right after it:
    Code:
        $PokemonSystem.soundvolume=100 if !$PokemonSystem.soundvolume #VOLUME
        volume=$PokemonSystem.soundvolume #VOLUME
    Search for this:
    Code:
    Audio.me_play("Audio/ME/" + me.name, me.volume, me.pitch)
    And replace it with this:
    Code:
    Audio.me_play("Audio/ME/" + me.name, volume, me.pitch) #VOLUME
    Search for this:
    Code:
    def se_play(se)
    And paste this right after it:
    Code:
        $PokemonSystem.soundvolume=100 if !$PokemonSystem.soundvolume #VOLUME
        volume=$PokemonSystem.soundvolume #VOLUME
    Next search for this:
    Code:
    Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
    And replace it with this:
    Code:
    Audio.se_play("Audio/SE/" + se.name, volume, se.pitch) #VOLUME
    That is all for Game_System. Finally the last script we have to edit is Audio.
    In Audio, search for this:
    Code:
    @seVolume=100.0
    And paste all of this right after it:
    Code:
      def self.setBgmVolume(volume) #VOLUME
        @bgmVolume=volume #VOLUME
      end #VOLUME
      def self.setMeVolume(volume) #VOLUME
        @meVolume=volume #VOLUME
      end #VOLUME
      def self.setBgsVolume(volume) #VOLUME
        @bgsVolume=volume #VOLUME
      end #VOLUME
      def self.setSeVolume(volume) #VOLUME
        @seVolume=volume #VOLUME
      end #VOLUME
    Now search for this:
    Code:
    def Audio_me_play(name, volume, pitch, position = 0)
    And paste this BEFORE that:
    Code:
    def audio_control_volume(volume) #VOLUME
      SoundEnvelope.changeDiscrete2(0,volume) #VOLUME
    end #VOLUME

    FINAL SCRIPTS:
    PScreen_Options
    Game_System
    Audio

    That should be all, and the Volume controller should be in the options menu. If you encounter any problems, post a reply.

    If you think I can improve on my tutorial please let me know. I'm not very good at writing tutorials.
     
    Last edited:
    1,224
    Posts
    10
    Years
  • Code:
    $PokemonSystem.volume=100 if !$PokemonSystem.volume #VOLUME
        volume=$PokemonSystem.volume #VOLUME
    This probably won't effect anything, but the logic is technically flawed. If $PokemonSystem isn't loaded, this will cause a crash.
    Your desired volume is already passed, so you don't need the first line, since the volume should be whatever the script says it is if $PokemonSystem is not been initialized.
    So it can be reduced to this
    Code:
    volume=$PokemonSystem.volume if $PokemonSystem #VOLUME
     
    76
    Posts
    8
    Years
    • Seen Oct 6, 2017
    Code:
    $PokemonSystem.volume=100 if !$PokemonSystem.volume #VOLUME
        volume=$PokemonSystem.volume #VOLUME
    This probably won't effect anything, but the logic is technically flawed. If $PokemonSystem isn't loaded, this will cause a crash.
    Your desired volume is already passed, so you don't need the first line, since the volume should be whatever the script says it is if $PokemonSystem is not been initialized.
    So it can be reduced to this
    Code:
    volume=$PokemonSystem.volume if $PokemonSystem #VOLUME

    Thanks for the advice. I'll fix the tutorial in a bit when I'm not in a League game.

    EDIT: Updated the post with your code.
     
    Last edited:

    Savordez

    It's time to end fangames.
    115
    Posts
    10
    Years
  • Can't you just go to SpriteWindow and edit pbBGMPlay (line 955) etc so that
    Code:
    def pbBGMPlay(param,volume=nil,pitch=nil)
    is
    Code:
    def pbBGMPlay(param,volume=$PokemonSystem.volume,pitch=nil)
    ?
     
    76
    Posts
    8
    Years
    • Seen Oct 6, 2017
    Can't you just go to SpriteWindow and edit pbBGMPlay (line 955) etc so that
    Code:
    def pbBGMPlay(param,volume=nil,pitch=nil)
    is
    Code:
    def pbBGMPlay(param,volume=$PokemonSystem.volume,pitch=nil)
    ?

    I guess you could, but I think it's more preferable to keep the amount of scripts edited down to a minimum.
     
    1,224
    Posts
    10
    Years
  • Can't you just go to SpriteWindow and edit pbBGMPlay (line 955) etc so that
    Code:
    def pbBGMPlay(param,volume=nil,pitch=nil)
    is
    Code:
    def pbBGMPlay(param,volume=$PokemonSystem.volume,pitch=nil)
    ?

    Could theoretically crash the game if you have a sound play before the load screen
     
    46
    Posts
    10
    Years
    • Seen Jan 19, 2017
    i dont know why my "music volume" value default is 0 and it has crash when load game or new game. "sound volume" is fine
    how can i fix it? thanks
     
    76
    Posts
    8
    Years
    • Seen Oct 6, 2017
    i dont know why my "music volume" value default is 0 and it has crash when load game or new game. "sound volume" is fine
    how can i fix it? thanks

    Hmm I don't know why this would happen other than a modified PScreen_Options.

    Have you edited your PScreen_Options before installing this?

    EDIT:

    Also, crash report?
     
    Back
    Top