function init_mainmenu_music()
	local music = g_App.mMusicInterface
	music:FadeIn(0, 0, 0.002, false)
	music:FadeOut(1, true, 0.004)
	music:FadeOut(2, true, 0.004)
	music:FadeOut(3, true, 0.004)
	music:FadeOut(4, true, 0.004)
end

-------------------------------------------------------------------------------------------------

function init_game_music()
	local music = g_App.mMusicInterface
	music:FadeOut(0, true, 0.004)

	g_Globals.game_music = -1
end

-------------------------------------------------------------------------------------------------

function fade_game_music()

	local music = g_App.mMusicInterface
	music:FadeOut(g_Globals.game_music, false, 0.006)
	music:FadeOut(g_Globals.game_music, false, 0.006)
	g_Globals.game_music = -1
end

-------------------------------------------------------------------------------------------------

function after_load_lua_change_game_music()
	if not g_Game then return end

	if not g_Globals.game_music then g_Globals.game_music = -1 end

	if g_GameVars.LevelState ~= g_GameVars.state_before_level then
		g_Globals.game_music = -1
		change_game_music()
	end
end

-------------------------------------------------------------------------------------------------

function change_game_music()	
		local music = g_App.mMusicInterface

		if not g_Globals.game_music then g_Globals.game_music = -1 end
		local last_music = g_Globals.game_music
		g_Globals.game_music = math.random(2)*2 - 1
		if g_Player:GetLevel()==1 then g_Globals.game_music = 1 end
		if last_music~=g_Globals.game_music then

			music:FadeOut(5 - g_Globals.game_music, false, 0.008)
			music:FadeOut(5 - g_Globals.game_music - 1, false, 0.008)

			music:StopMusic(g_Globals.game_music)
			music:StopMusic(g_Globals.game_music + 1)

			music:PlayMusic(g_Globals.game_music, 0, false)
			music:PlayMusic(g_Globals.game_music + 1, 0, false)
			music:SetSongVolume(g_Globals.game_music + 1, 0.0)
			music:SetSongVolume(g_Globals.game_music, 0)

			music:FadeIn(g_Globals.game_music, 0, 0.002, false) 
		else
			music:FadeInPlaying(g_Globals.game_music, 0.002)
		end
--	end
end

-------------------------------------------------------------------------------------------------

function update_game_music(satisfaction)
	local music = g_App.mMusicInterface
	if satisfaction>=45 then
		music:FadeInPlaying(g_Globals.game_music, 0.002)
		music:FadeOut(g_Globals.game_music + 1, false, 0.002)
	else
		music:FadeOut(g_Globals.game_music, false, 0.002)
		music:FadeInPlaying(g_Globals.game_music + 1, 0.002)
	end
end

-------------------------------------------------------------------------------------------------

g_App.mMusicInterface:LoadMusic(0, "music/mainmenu.ogg")
g_App.mMusicInterface:LoadMusic(1, "music/game01.ogg")
g_App.mMusicInterface:LoadMusic(2, "music/game02.ogg")
g_App.mMusicInterface:LoadMusic(3, "music/game03.ogg")
g_App.mMusicInterface:LoadMusic(4, "music/game04.ogg")