• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Resource icon

Resource BGM with intro + loops 2024-03-12

SunriseStudios

Novice
Member
Joined
Aug 10, 2022
Posts
21
Dracarys submitted a new resource:

BGM with intro + loops - Loop your music without editing audio files

Are you also annoyed about music that end, then starts from the beginning with no good transition? A good example is when you have a battle BGM and you want the intro of that BGM only played once and afterwards loop a certain part of the BGM (the actual "battle music").

This very small script allows you to define BGMs that will behave like this. All BGM files that are part of the hash need a defined start and end position (in seconds). After reaching the defined end position, the script BGM...

Read more about this resource...
 

Ryuushedo

Developer of Pokemon Lost World
Member
Joined
Jun 13, 2023
Posts
20
this is very helpful script but somehow i dont know if i did it right or not sir

module MusicLoops
# Music looping: if a BGM file is listed here, the respective start and end
# time will be used to loop the BGM after playing until the end once
BGM = {
"FinalClash" => [36.00, 113.00] # start, end (in seconds)
}
end

class Game_System
attr_accessor :bgm_loop_start
attr_accessor :bgm_loops

def bgm_play(bgm, track = nil)
old_pos = @bgm_position
@bgm_position = 0
bgm_play_internal(bgm, 0, track)
@bgm_position = old_pos
if MusicLoops::BGM.has_key?(bgm.name)
@bgm_loops = 0
@bgm_loop_start = System.uptime
end
end

def bgm_loop
bgm = playing_bgm.name
pbBGMFade(0.1)
bgm_play_internal2("Audio/BGM/" + bgm, 100, 100, MusicLoops::BGM[bgm][0])
@bgm_loop_start = System.uptime
@bgm_loops += 1
end

alias bgmloop_update update unless method_defined?(:bgmloop_update)
def update
bgmloop_update
return if !playing_bgm
bgm = playing_bgm.name
return if !MusicLoops::BGM.has_key?(bgm) || !@bgm_loop_start || @bgm_loop_start == 0
# After intro is finished, jump back to loop start
if System.uptime >= @bgm_loop_start + MusicLoops::BGM[bgm][1] && @bgm_loops == 0
bgm_loop
# After first loop, calculate timing based on loop duration (without intro)
elsif System.uptime >= @bgm_loop_start + (MusicLoops::BGM[bgm][1] - MusicLoops::BGM[bgm][0]) && @bgm_loops > 0
bgm_loop
end
end
end

here my script, i set up the loop will be on 36 second to 113 but the bgm still continue till end and start from beginning instead the loop i make
 
Back
Top