Hi there.
So recently I have been trying to get background music to change for each location based on time of day. For example, I am trying to have background music for inside of a specific shop to change based on whether or not it is morning, day, dusk, night, etc. I would also like a different set of music to play for outside of the shop along with other areas, which alternates between morning, day, dusk, and night. So basically, if the player enters the shop during the morning, the music would be lively and upbeat. But if they enter the shop at night, it will be a different music track, which is more calm and relaxing.
So far, I have been using a common event set to run parallel to try to get this to work, which checks for whether or not the player is in this specific shop, and what time of day it is. This almost works, except that the common event will just repeat the first part of the song over and over (as in only the first note or so). I tried to use a loop to fix this, and it seemed to work, except that it seemed to cause the game to run very slowly and the music sounded poor quality as well.
I then tried to use various wait commands... however, the music track I am using is 2 minutes and 41 seconds long. Wait time only goes up to 999 frames, so I used nine different 999 wait times, plus one 789 long wait time. This of course was very inefficient, and also made the game crash when I tried to run it.
I have tried to find information on a way to do this elsewhere, but so far have not found any good solutions which seem to work for my particular circumstances.
In case any of this information is relevant, the common event I am using here ("Soothing Breeze Music") requires a switch to be active called "Soothing Breeze," which just checks if the player has entered the "Soothing Breeze" shop. Additionally, I am using a common event for keeping track of time as well, which also runs parallel. A screenshot of this is included below.
Here are some screenshots of my attempts. I want to note that I am only showing my attempts for the first track of background music, which is for the "dawn" music (from hours 5 to 7).
Here is a screenshot of the common event without the loop or wait times, which only plays the first note of the music on repeat:
Here is a screenshot of the common event with the loop, which caused the game to run very slow and seemed to degrade the quality of the music:
Here is a screenshot of the common event after unwisely attempting to use over 9 wait time commands:
And here is a screenshot of my time common event, in case it is relevant:
If anyone has any suggestions of what I might be able to do to get this to work correctly (without making the game run very slowly), I would very grateful. I am grateful for any and all advice/help offered.
Thank you for your time!
Update: Thank you everyone for your responses! Thanks to your advice, I finally have it working correctly! The player can now enter this specific shop at any time of day, and the music will smoothly play based on what time of day it is, without any noticeable issues with quality. Additionally, if the player stays within the shop long enough for the time of day to change again, the music will change accordingly as well. So if the player enters the shop at night, the night music will play. If the player stays in the shop until dawn, the night music will change to dawn music.
For anyone else who may have had this problem, I did the following to get it to work:
Step 1:
I added a background music check to the common event which is responsible for changing the music within the Soothing Breeze shop. This common event already checked for the time of day, and if the player was inside of a building. I just had to add a variable as well (called it varBGM) which checked for whether or not that specific music track was playing.
In the varBGM variable, I chose for 1 to correspond with Dawn, 2 to correspond with Day, 3 to correspond with Dusk, 4 to correspond with Night, and 5 to correspond with Midnight.
To do the BGM check, I set the conditional to "If : varBGM =/= #" where the # is the BGM track playing (1 for Dawn music, 2 for Day music, etc).
Then, I made sure to set varBGM to the correct music track that is currently playing within this common event.
Additionally, I added a "Wait 20 Frames" command at the very end of this common event, though you cannot see it in the screenshot.
Here is a screenshot of the code of this common event:
Step 2: I added a regular event set to autorun in the top left corner of the Soothing Breeze shop map. This event sets the varBGM variable to 0, then it erases itself using the Erase Event command. This event means that each time you enter the Soothing Breeze shop, the varBGM will be set to 0, so then the Soothing Breeze Music common event will play whatever music track is designated for the time of day, and then will set varBGM to the number assigned to this track, so that it will not repeat the first note over and over.
Additionally, here is a screenshot of the code for the door to go into the Soothing Breeze shop, in case anyone finds this helpful:
The Soothing Breeze switch is responsible for turning on the Soothing Breeze Music common event.
Thank you again to everyone for all of your useful suggestions! I am very appreciative, and I am so happy to have finally gotten this to work thanks to you.
So recently I have been trying to get background music to change for each location based on time of day. For example, I am trying to have background music for inside of a specific shop to change based on whether or not it is morning, day, dusk, night, etc. I would also like a different set of music to play for outside of the shop along with other areas, which alternates between morning, day, dusk, and night. So basically, if the player enters the shop during the morning, the music would be lively and upbeat. But if they enter the shop at night, it will be a different music track, which is more calm and relaxing.
So far, I have been using a common event set to run parallel to try to get this to work, which checks for whether or not the player is in this specific shop, and what time of day it is. This almost works, except that the common event will just repeat the first part of the song over and over (as in only the first note or so). I tried to use a loop to fix this, and it seemed to work, except that it seemed to cause the game to run very slowly and the music sounded poor quality as well.
I then tried to use various wait commands... however, the music track I am using is 2 minutes and 41 seconds long. Wait time only goes up to 999 frames, so I used nine different 999 wait times, plus one 789 long wait time. This of course was very inefficient, and also made the game crash when I tried to run it.
I have tried to find information on a way to do this elsewhere, but so far have not found any good solutions which seem to work for my particular circumstances.
In case any of this information is relevant, the common event I am using here ("Soothing Breeze Music") requires a switch to be active called "Soothing Breeze," which just checks if the player has entered the "Soothing Breeze" shop. Additionally, I am using a common event for keeping track of time as well, which also runs parallel. A screenshot of this is included below.
Here are some screenshots of my attempts. I want to note that I am only showing my attempts for the first track of background music, which is for the "dawn" music (from hours 5 to 7).
Here is a screenshot of the common event without the loop or wait times, which only plays the first note of the music on repeat:
Here is a screenshot of the common event with the loop, which caused the game to run very slow and seemed to degrade the quality of the music:
Here is a screenshot of the common event after unwisely attempting to use over 9 wait time commands:
And here is a screenshot of my time common event, in case it is relevant:
If anyone has any suggestions of what I might be able to do to get this to work correctly (without making the game run very slowly), I would very grateful. I am grateful for any and all advice/help offered.
Thank you for your time!
Update: Thank you everyone for your responses! Thanks to your advice, I finally have it working correctly! The player can now enter this specific shop at any time of day, and the music will smoothly play based on what time of day it is, without any noticeable issues with quality. Additionally, if the player stays within the shop long enough for the time of day to change again, the music will change accordingly as well. So if the player enters the shop at night, the night music will play. If the player stays in the shop until dawn, the night music will change to dawn music.
For anyone else who may have had this problem, I did the following to get it to work:
Step 1:
I added a background music check to the common event which is responsible for changing the music within the Soothing Breeze shop. This common event already checked for the time of day, and if the player was inside of a building. I just had to add a variable as well (called it varBGM) which checked for whether or not that specific music track was playing.
In the varBGM variable, I chose for 1 to correspond with Dawn, 2 to correspond with Day, 3 to correspond with Dusk, 4 to correspond with Night, and 5 to correspond with Midnight.
To do the BGM check, I set the conditional to "If : varBGM =/= #" where the # is the BGM track playing (1 for Dawn music, 2 for Day music, etc).
Then, I made sure to set varBGM to the correct music track that is currently playing within this common event.
Additionally, I added a "Wait 20 Frames" command at the very end of this common event, though you cannot see it in the screenshot.
Here is a screenshot of the code of this common event:
Step 2: I added a regular event set to autorun in the top left corner of the Soothing Breeze shop map. This event sets the varBGM variable to 0, then it erases itself using the Erase Event command. This event means that each time you enter the Soothing Breeze shop, the varBGM will be set to 0, so then the Soothing Breeze Music common event will play whatever music track is designated for the time of day, and then will set varBGM to the number assigned to this track, so that it will not repeat the first note over and over.
Additionally, here is a screenshot of the code for the door to go into the Soothing Breeze shop, in case anyone finds this helpful:
The Soothing Breeze switch is responsible for turning on the Soothing Breeze Music common event.
Thank you again to everyone for all of your useful suggestions! I am very appreciative, and I am so happy to have finally gotten this to work thanks to you.