Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
I'm gonna have the player walk around the same town doing a bunch of stuff most of the time, and I want to actually change the music up, like have one track after the other. How can I do this?
 

xabileug

Veteran
Veteran
Joined
Jul 1, 2014
Messages
178
Reaction score
38
just use event autro run -> random variable -> play BGM -> erase event
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
just use event autro run -> random variable -> play BGM -> erase event

i would do that, but that would just play ALL bgms, right? I want to change up the list of the songs later on, though, so I need to play random BGMs from a set/playlist of BGMs.
 

cradth

FreeLancerPaidSwordsman
Veteran
Joined
Feb 13, 2016
Messages
269
Reaction score
147
First Language
Indonesia
Primarily Uses
N/A
i would do that, but that would just play ALL bgms, right? I want to change up the list of the songs later on, though, so I need to play random BGMs from a set/playlist of BGMs.
That random variable won't play all bgms, you should combine it with conditional branches.

For example, name your BGM in audio folder -> song1, song2, song3, and so on.
Set an event -> random variables 1 - 12 -> name that variable "random song"
-> and make conditional branches : random song = 1 to play song1, random song = 2 to play song2.

Now you can freely add your song later, just name it song1, song2, and overwrite
the old ones. Hope that helps. :)
 

xabileug

Veteran
Veteran
Joined
Jul 1, 2014
Messages
178
Reaction score
38
i dont think there's a conditional branch for when the song ends. since bgm are designed for loops. so you will need a plugin. the auto run event is just to play a random song when entering a map.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
596
Reaction score
266
First Language
PT-BR
Primarily Uses
RM2k3
As I understand it, you want that when the song ends, the next one starts right after.

I don't know if it is easy to find out the final position of BGM.
Here is a post that I was showing you how to use the RMMV function that controls the WebAudio API:

One idea I have is to check when the "POS" of the range returns to zero, so just use an IF.
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
As I understand it, you want that when the song ends, the next one starts right after.

I don't know if it is easy to find out the final position of BGM.
Here is a post that I was showing you how to use the RMMV function that controls the WebAudio API:

One idea I have is to check when the "POS" of the range returns to zero, so just use an IF.

Yeah, I want to play the next song after the one that's on ends. I'm very new with all of this so I'm very confused with everything. I read that thread, too and I'm still very much confused.

i dont think there's a conditional branch for when the song ends. since bgm are designed for loops. so you will need a plugin. the auto run event is just to play a random song when entering a map.

yeah I want to make the same song playing between mapchange and also, when that song ends, randomly play another one from a list of songs.

That random variable won't play all bgms, you should combine it with conditional branches.

For example, name your BGM in audio folder -> song1, song2, song3, and so on.
Set an event -> random variables 1 - 12 -> name that variable "random song"
-> and make conditional branches : random song = 1 to play song1, random song = 2 to play song2.

Now you can freely add your song later, just name it song1, song2, and overwrite
the old ones. Hope that helps. :)

I'll give that a shot!


Tbh I don't care if they're playing AS bgm, but the songs will act as BGMs, so maybe there's more flexibility in adding them as sounds?

I just want it to act like a music playlist set to "random".
 

xabileug

Veteran
Veteran
Joined
Jul 1, 2014
Messages
178
Reaction score
38
actually if you know the length of song, you can store them in a variable, since there are many timer plugins. if song 1 is 2 min long, set timer to 2 minutes, when timer variable is zero, random number, play that song.
the best way will be using hash array not sure how to set them up, then just use script calls.
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
actually if you know the length of song, you can store them in a variable, since there are many timer plugins. if song 1 is 2 min long, set timer to 2 minutes, when timer variable is zero, random number, play that song.
the best way will be using hash array not sure how to set them up, then just use script calls.
oh, that sounds like a viable way to do it! thanks! I will have to make a bunch of variables, though, since there'll be a lot of songs that last different times each one.

i'll search around for a timer plugin and check if I can do it.

thanks
 

xabileug

Veteran
Veteran
Joined
Jul 1, 2014
Messages
178
Reaction score
38
i think you only need 1 variable for the song length, you just need to change its value every time you pick a song to play.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
596
Reaction score
266
First Language
PT-BR
Primarily Uses
RM2k3
If you use Loop you will need only one variable:
Code:
◆Comment:Track 1 - Restart time-count
◆Control Variables:#0002 Track-Length = 0
◆Play BGM:Field1 (90, 100, 0)
◆Loop
  ◆If:Track-Length > 4140
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆Control Variables:#0002 Track-Length += 1
  ◆
:Repeat Above
◆Comment:Track 2 - Restart time-count
◆Control Variables:#0002 Track-Length = 0
◆Play BGM:Field2 (90, 100, 0)
◆Loop
  ◆If:Track-Length > 4320
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆Control Variables:#0002 Track-Length += 1
  ◆
:Repeat Above

Every 1 second equals 60 frames, so every minute has 3600 frames.
If a song is 1:09 you will need to use the calculator:
9 x 60 = 540

Then add the minutes of the song:
540 + 3600 = 4140

Another example, a 2:15 tempo song:
15 x 60 = 900
3600 x 2 = 7200
900 + 7200 = 8100


This calculation does not work with songs with altered speed in the game.

The big problem with this method is that it does not work with the menu open, as the parallel process is in standby mode.

You can use "Fade Out" to trick the player's ears, you will need to calculate the number of frames over time and subtract from the total time value of each song.
If the "Fade Out" has 3 seconds:
60 x 3 = 180
Track 1: 4140 - 180 = 3960


Hence create a "Conditional Branch" that verifies the exact moment:
Code:
◆If:Track-Length = 3960
  ◆Fadeout BGM:3 seconds
  ◆
:End
◆If:Track-Length > 4140
  ◆Break Loop
  ◆
:End

About the WebAudio API, in this case it would really be necessary to develop a plugin that would control the current BGM system. And currently I don't know anyone who is studying this that could create such a system.
 
Last edited:

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
@Dev_With_Coffee
Thanks! Tbh, this sounds way too complex for my level of rpgmaker knowledge. I could follow you until the fade out part.
The video you posted seems to be about mapping, is that the correct video?
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
596
Reaction score
266
First Language
PT-BR
Primarily Uses
RM2k3
For me, the video that appears shows the song being changed.

About the system:
I updated the system today, now it is possible to move on to the next song with a Switch.
The system works in a common event, for music there is another Switch.
Edit: The "Stop BGM" switch was not working at the right time, it is now fixed.

Extra:
I'm still studying the Web Audio API to be able to create a plugin that allows me to list several songs or randomize a list.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Playing my game to improve my game. (Totally not procrastinating)
Hope he recovers fast :|
Looks like it's functional:
It's a common thing to forget eating &drinking while you are working concentrated, right?
If I had discovered RPG-Maker before moving together with my girlfriend, I'd have died of dehydration a long time ago.
Ami
trying to change my picture & got screwed up...

Forum statistics

Threads
112,497
Messages
1,068,690
Members
146,167
Latest member
ryweuu
Top