DarkPlasmaBall

Veteran
Veteran
Joined
Apr 29, 2020
Messages
216
Reaction score
18
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
216
Reaction score
18
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
966
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,845
Reaction score
1,666
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
216
Reaction score
18
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
966
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 Posts

Latest Profile Posts

since all my maps are hand drawn... I admit, I super envy those who can make the tileset's work. I'm garbage at mapping, but slightly less bad at just drawing my own areas. plus it's easier to draw my own sprites than edit others to look like my characters.
Guys, I made a trailer! And, I also launched the Steam page! If you would like to support the game, please Wishlist it :ahappy: ->
working on some tilesets _ノ乙(、ン、)_

CIBl8xT.png


Oq8WKHX.png
aww man, color hex code #C4C4C4 doesn't work for the tint value in this scene I need something darker, which stinks just because I liked that one it was my favorite plastic explosive three times...#696969 (nice) should work better (WHY IS MY BRAIN LIKE THIS)
Tell it to me straight, doc. If I've been trying to piece together a "shorter" game to learn stuff outside of game jams... am I just running away from my WIP? :v

Forum statistics

Threads
117,284
Messages
1,106,135
Members
153,470
Latest member
CPGPPC
Top