Finding a Method - RGSS3 Cross-Fade Script

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
Referenced script can be found here:

https://forums.rpgmakerweb.com/index.php?threads/cross-fade-audio-script.2472.

In simple terms, the script allows you to cross-fade two BGMs, where one fades out while another fades in. The author rigged it in a way where the second BGM is played as a BGS instead, allowing two different "play" methods to be called at the same time.

I've dissected the script quite a bit because I'm not liking how long the second BGM takes to fade-in. So I decided to adjust two things; the time it takes to fade-out the current BGM and the time it takes to fade-in the changed one (the one being treated as a BGS). The fade-out time I found easily:

Code:
cp_bgm_fade(120) #1000
(Line 147)

As you can see I experimented by changing the fadeout time to 120 frames, which works. Obviously the fade-in time is still obnoxiously long so it still sounds bad.

Here is my trouble; I can't for the life of me find the method used to fade-in the audio. I'm guessing it's somewhere in here:

Code:
    def bgs_play(*args)  ## Changes method for ambient sounds
      check_fades
      if $fades
        bgm_play(*args) if CP::FADE_AUDIO::DO_BGM
      else
        unless $switch
          cp_bgs_play(*args)
          @bgs = args
        else
          cp_bgm_play(*args)
          @bgm = args
        end
      end
    end
(Lines 166-179)

But I'm not knowledgeable enough to decipher something that's not put it simple numbers. Can anyone help me out and see if it's possible to change the fade-in time and how? Also some enlightenment on the method used itself would be nice, since I am learning RGSS3 bit by bit.

Thank you to anybody who can help!
 

AskaRay

Tired Artist
Veteran
Joined
Oct 21, 2015
Messages
36
Reaction score
28
First Language
English
Primarily Uses
RMVXA
I looked quick, did you try changing the cp_bgs_fade on line 143?
It's right above the cp_bgm_fade you changed

Code:
        if $switch
          spot = cross_bgs# + CP::FADE_AUDIO::OFFSET
          @bgm = args
          @bgs = nil
          cp_bgm_play(args[0],args[1],args[2],spot)
          cp_bgs_fade(1000)
        else
          spot = cross_bgm# + CP::FADE_AUDIO::OFFSET
          @bgs = args
          @bgm = nil
          cp_bgs_play(args[0],args[1],args[2],spot)
          cp_bgm_fade(1000)
        end
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
I remember working with fade-ins (I just can't remember *where*!), but I just checked, and neither the Audio module, nor any of the plugins I have, have a fade-in function.
I must have faked it onto the audio file itself.

by default, it can't be faded-in.
can be faded out,... but not in.
which is kind of counter-intuitive :/
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
I looked quick, did you try changing the cp_bgs_fade on line 143?
It's right above the cp_bgm_fade you changed

Code:
        if $switch
          spot = cross_bgs# + CP::FADE_AUDIO::OFFSET
          @bgm = args
          @bgs = nil
          cp_bgm_play(args[0],args[1],args[2],spot)
          cp_bgs_fade(1000)
        else
          spot = cross_bgm# + CP::FADE_AUDIO::OFFSET
          @bgs = args
          @bgm = nil
          cp_bgs_play(args[0],args[1],args[2],spot)
          cp_bgm_fade(1000)
        end
Yeah this was the second thing I went to. All that does is affect the second cross-fade (so i.e. if you cross-fade a BGM then cross-fade again, since the second BGM is being treated as a BGS). And it does the same thing, changing how long the BGS takes to fade out.

@gstv87 Well yeah there definitely isn't a default fade-in method. That's why Neon creates one somewhere in this script. That's what I'm trying to find.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
There IS actually a fade-in method in the Audio module. That is a hidden module in VX Ace, and the documentation about this module won't tell you this at all.

By default, if you want to play a BGM from a designated position (so, not from the start), it will automatically start the BGM volume on 0 and slowly fades it in.
Without completely rewriting this part of the Audio module, you won't be able to do anything about this.

The AudioManager class in the rpg_managers file in MV is essentially the same as the Audio module in VX Ace, that is why I know about all this, I saw it there.
You can see that in that class there is a _replayFadeTime variable created which is set to 0.5, and this variable is used when the starting position of the BGM is not 0.
It is safe to assume that this is the same thing that happens in the Audio module of VX Ace.
Rewriting this part is certainly not easy without knowing the full code of the entire module.

You can either accept this limitation, or you could try one of the Audio rewrites made for VX Ace.
There is one named FMod or something like that. That one has tons of new options and multiple audio channels, but it also has some bugs.
Other than this, I don't see any other solution to your issue.
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
Where does Neon reference this in his script? Also is it really that complex to change how long the fade-in time is? What happens if you adjust the variable?

Ahh nevermind, I see what you're talking about now. So there isn't any way to access the module, at least not in the script editor? For that matter, are there any methods that can be overwritten or is all of it pretty much inaccessible?

Thanks for the help.
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
Okay, sorry for the double post, but I'm heading in a different direction now.

After toying around with simple event commands, I found an alternative that sounds almost as good as reducing the fade time. Basically, I want the fade-out to start x frames after the second track begins to play (or fade-in). This makes it so that the long fade-in is somewhat concealed by the first track still playing.

I tried using a simple wait(duration) command in the middle of the bgm_play method, which works aurally but immediately produces an error (which says that "wait" is undefined in the audio module, which I don't know how to fix). So the new question is how would I go about adding a "wait" command in the method at Line 133? Ironically I can pull it off using events, but this takes away the ability to cross-fade audio into battle (as well as being overly tedious to manage).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top