#---------------------------------------------------
# Noyemi K's Dynamic Music System
#---------------------------------------------------
# Description:
# A dynamic music system that switches tracks on-the-fly
# without restarts. Useful for creating ambience that
# builds throughout various situations in an area.
#---------------------------------------------------
module DynamicMusicSystem

#---------------------------------------------------
# Editable Region
#---------------------------------------------------

# Specify the variable ID used to store the song variation variable.

SONG_VARIATION_ID = 1

# Specify the variation extensions
# "0", "1", "2", "3"], , etc. Can accomodate any
# number of variations up to the variable limit.
# ALSO: MAKE SURE YOUR FILENAMES CORRESPOND TO THIS ARRAY
# For example, for variations on "Forest.ogg", you might want to use
# "ForestNormal.ogg", "ForestCombat.ogg", or "ForestPuzzle.ogg"

VARIATION_EXTENSIONS =

end
#---------------------------------------------------
# Engine Region. DO NOT mess with anything beyond this point.
#---------------------------------------------------

class MusicVariations
def initialize
super
@extensions = DynamicMusicSystem::VARIATION_EXTENSIONS
#msgbox(@extensions) #DEBUG
end

def cache_BGM
@variationID = $game_variables
@songpos = Audio.bgm_pos
if @variationID == 0
$bgm_name = ('Audio/BGM/' + RPG::BGM.last.name)
end
end

def check_variations
if @extensions == nil
@play = @last
else
@play = $bgm_name + @extensions
@last = @play
end
Audio.bgm_play(@play, 100, 100, @songpos)
end
end


#---------------------------------------------------
# Starts the engine at the title
#---------------------------------------------------

class Scene_Title
#-------------------------------------------------------------------------
# * Alias Main to initialize the data class upon startup
#-------------------------------------------------------------------------
alias start_dms start
def start
start_dms
# Initialize
$dms = MusicVariations.new
end
end

class Game_Player

alias update_dms update
def update
update_dms
$dms.cache_BGM
$dms.check_variations
end
end