DarkPlasmaBall

Veteran
Veteran
Joined
Apr 29, 2020
Messages
215
Reaction score
17
First Language
English
Primarily Uses
RMMV
Hey everyone, quick question about changing background music during an event, specifically when I keep the BGM song the same but just change the volume and pitch:

I know that when I change the volume of a song, the song doesn't reset/restart from the beginning of the tune (the song continues seamlessly, and adjusts the volume instantly). However, when I change the pitch of a song, the song completely restarts from the beginning, which disrupts the flow of the song. Is there a way I can adjust the pitch of a song, midway through a song, without the song resetting? I would like to be able to speed up or slow down the pace of a song during an event trigger, without the song being interrupted and starting over, since that can lead to weird choppiness.

I have attached two pictures for further clarity. Thanks!
 

Attachments

  • Volume Change Seamless Transition.png
    Volume Change Seamless Transition.png
    52.4 KB · Views: 8
  • Pitch Change Song Resets.png
    Pitch Change Song Resets.png
    53.8 KB · Views: 8

hosercanadian

Veteran
Veteran
Joined
Jul 18, 2016
Messages
53
Reaction score
15
First Language
English
Primarily Uses
Not the best solution, but you could fade the music in and out. Do a fade of 120 frames (in and out) and it should better with a less jarring transition. Experiment with fade duration and maybe insert a wait between them.
 

DarkPlasmaBall

Veteran
Veteran
Joined
Apr 29, 2020
Messages
215
Reaction score
17
First Language
English
Primarily Uses
RMMV
Not the best solution, but you could fade the music in and out. Do a fade of 120 frames (in and out) and it should better with a less jarring transition. Experiment with fade duration and maybe insert a wait between them.

Interesting idea. So with this strategy, the song would still unfortunately reset, but the transition might not sound as bad. I think I might need to settle for this if there is no way to stop the song from resetting when the pitch changes.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
As I understand it, you want the music to start at 1.5x (150%) and gradually decrease to 0.5x (50%), am I right?

This is not a problem in Rpg Maker, it is standard in the WebAudio API.
Each time you change one of these parameters it resets the music.
The best solution I found was to save the time point of the song in a temporary variable.
Then apply the effects and force it to reproduce starting from the point memorized in the variable.

Try this:
pos_temp=AudioManager._bgmBuffer.seek(); AudioManager._bgmBuffer.pitch=n; //Fractional number, like 0.1, 1.0 or 1.1 AudioManager._bgmBuffer.play(true, pos_temp);

1 or 1.0 = 100%
0.5 = 50%
0.1 = 10%

Using Javascript, you are not limited between 50% and 150%.
You can use between 0% and ???%

Example:
Code:
◆Play BGM:Castle2 (100, 130, 0)
◆Wait:120 frames
◆Script:pos_temp=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=1.0;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=1.1;
:      :AudioManager._bgmBuffer.play(false, posNow);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=1.0;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=0.9;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=0.8;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=0.7;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,830
Reaction score
1,651
First Language
English
Primarily Uses
RMMV
The best solution I found was to save the time point of the song in a temporary variable.
Then apply the effects and force it to reproduce starting from the point memorized in the variable.
The problem with this - and why I suspect it's implemented the way it is by default - is that when you change pitch, you also alter the tempo.

This can be very clearly heard even without a trained musical ear - just choose any of your BGM tracks and push the pitch all the way down. Then stop, crank it all the way up, and play again. You can hear that the music is being played at a drastically different tempo, along with the change in pitch. If you wanted to sit there to listen to the entire track, you would hear it takes a very different amount of time to finish.

So doing what you wrote in your code is not going to sound good at all, because where you are at, say, 1:27 at one pitch setting is not going to be the same music that's being played at 1:27 at a different pitch.

You would have to perform math on your variable to try to account for that difference and see how precisely it matches up.
 

DarkPlasmaBall

Veteran
Veteran
Joined
Apr 29, 2020
Messages
215
Reaction score
17
First Language
English
Primarily Uses
RMMV
As I understand it, you want the music to start at 1.5x (150%) and gradually decrease to 0.5x (50%), am I right?

This is not a problem in Rpg Maker, it is standard in the WebAudio API.
Each time you change one of these parameters it resets the music.
The best solution I found was to save the time point of the song in a temporary variable.
Then apply the effects and force it to reproduce starting from the point memorized in the variable.

Try this:
pos_temp=AudioManager._bgmBuffer.seek(); AudioManager._bgmBuffer.pitch=n; //Fractional number, like 0.1, 1.0 or 1.1 AudioManager._bgmBuffer.play(true, pos_temp);

1 or 1.0 = 100%
0.5 = 50%
0.1 = 10%

Using Javascript, you are not limited between 50% and 150%.
You can use between 0% and ???%

Example:
Code:
◆Play BGM:Castle2 (100, 130, 0)
◆Wait:120 frames
◆Script:pos_temp=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=1.0;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=1.1;
:      :AudioManager._bgmBuffer.play(false, posNow);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=1.0;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=0.9;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=0.8;
:      :AudioManager._bgmBuffer.play(true, pos_temp);
◆Wait:120 frames
◆Script:posNow=AudioManager._bgmBuffer.seek();
:      :AudioManager._bgmBuffer.pitch=0.7;
:      :AudioManager._bgmBuffer.play(true, pos_temp);

Hm, that's interesting! That does start to create overlap if timed perfectly (which I'm not sure if it's possible), but I'll tinker with this as well as the fade out/in idea presented earlier. I think ATT_Turan brought up a good point about how the lining up might still sound off because the notes will be different. Thanks to everyone!
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
It is not something that can be changed in the WebAudio API as far as I know, perhaps in a future update.
@ATT_Turan
I realized this, so it is necessary to do a very long graduation. Perhaps using longer intervals:
1.30, 1.25, 1.20, 1.15 ... 1.0, 0.95, 0.90 ... 0.5, 0.45

Edit:
@DarkPlasmaBall It doesn't get any better than that, the rest is up to you, changing the interval within the repetition.

Method:
Code:
◆Control Variables:#0017 = 130
◆Play BGM:Dungeon2 (100, 130, 0)
◆Wait:60 frames
◆Loop
  ◆Script:chg_pitch = $gameVariables.value(17) / 100;
  :      :console.log(chg_pitch);
  :      :pos_temp=AudioManager._bgmBuffer.seek();
  :      :AudioManager._bgmBuffer.pitch=chg_pitch;
  :      :AudioManager._bgmBuffer.play(true, pos_temp);
  ◆Control Variables:#0017 -= 1
  ◆If:#0017 < 70
    ◆Break Loop
    ◆
  :End
  ◆Wait:5 frames
  ◆
:Repeat Above
◆Text:None, Window, Bottom
:    :Exit Script
 
Last edited:

Latest Threads

Latest Profile Posts


It's a Spanish devlog don't get scared!. (please)
Q:"Why don't you get a job?"
A: Posting statuses IS my job. It just so happens to not pay and happen periodically over the course of three months.
My new 49" monitor has been dispatched from the warehouse. Will it arrive tomorrow? The day after? I love that we can track packages now, even if it does only tell me when it's left that end and when it's arrived at the local centre. As long as it doesn't end up in Melbourne again, which has happened before ...
My friend's doing a surprise stream of my game Origin Hunt on Twitch here ! Feel free to stop by :yhappy:

Forum statistics

Threads
117,236
Messages
1,105,753
Members
153,397
Latest member
Westernnimbus
Top