kInsideHutAmbientGroup = "INSIDE_HUT"		-- Group name for ambient noises inside the hut
kOutsideHutAmbientGroup = "OUTSIDE_HUT"		-- Group name for ambient noises outside the hut
kSpookyAmbientGroup = "SPOOKY"				-- Group name for ambient noises in "spooky" places

kOutsideAmbienceTag = "OUTSIDE_AMBIENCE"
kIndoorAmbienceTag = "INDOOR_AMBIENCE"
kSpookyAmbienceTag = "SPOOKY_AMBIENCE"

kOutsideAmbienceName = "OUTSIDE_AMBIENCE"
kIndoorAmbienceName = "INDOOR_AMBIENCE"
kSpookyAmbienceName = "SPOOKY_AMBIENCE"

kOutsideAmbientSweetenerTag = "OUTSIDE_AMBIENT_SWEETENERS"
kIndoorAmbientSweetenerTag = "INDOOR_AMBIENT_SWEETENERS"
kSpookyAmbientSweetenerTag = "SPOOKY_AMBIENT_SWEETENERS"

kOutsideAmbientSweetenerName = "OUTSIDE_SWEETENERS"
kIndoorAmbientSweetenerName = "INDOOR_SWEETENERS"
kSpookyAmbientSweetenerName = "SPOOKY_SWEETENERS"

kThemeSwellTag = "THEME_SWELL_TAG"
kThemeSwellName = "THEME_SWELL_GROUP"

kAmbientType = "ambient"
kSFXType = "sfx"
kMusicType = "music"

-- ----------------------------------------------------------------------------
function playAudioTrack(definitionId)
	getAudioManager():playTrack({definition=definitionId})
end
-- ----------------------------------------------------------------------------
function playAmbientAudio(groupName)

	if (groupName == kInsideHutAmbientGroup) then
		stopAudioGroup(kSpookyAmbientGroup)
		stopAudioGroup(kOutsideHutAmbientGroup)
		
		playInsideAmbience()
		
	elseif (groupName == kOutsideHutAmbientGroup) then
		stopAudioGroup(kSpookyAmbientGroup)
		stopAudioGroup(kInsideHutAmbientGroup)
		
		playOutsideAmbience()
		
	elseif (groupName == kSpookyAmbientGroup) then
		stopAudioGroup(kInsideHutAmbientGroup)
		stopAudioGroup(kOutsideHutAmbientGroup)
		
		playSpookyAmbience()
		
	end
	
	-- Play the theme swells no matter what
	if (not getAudioManager():isTrackPlaying(kThemeSwellTag)) then
		getAudioManager():playTrack({tag=kThemeSwellTag, definition=kThemeSwellName})
	end
	
end
-- ----------------------------------------------------------------------------
function stopAudioGroup(groupName)
	getAudioManager():stopTrack({group=groupName})
end
-- ----------------------------------------------------------------------------
function stopAudioTrack(trackTag)
	getAudioManager():stopTrack({tag=trackTag})
end
-- ----------------------------------------------------------------------------
function playOutsideAmbience()
	-- Check for background track
	if (not getAudioManager():isTrackPlaying(kOutsideAmbienceTag)) then
		getAudioManager():crossFadeTrack({tag=kOutsideAmbienceTag, definition=kOutsideAmbienceName, fadeTime=2000})
	end
	if (not getAudioManager():isTrackPlaying(kOutsideAmbientSweetenerTag)) then
		getAudioManager():playTrack({group=kOutsideHutAmbientGroup, tag=kOutsideAmbientSweetenerTag, definition=kOutsideAmbientSweetenerName})
	end
end
-- ----------------------------------------------------------------------------
function playInsideAmbience()
	-- Check for background track
	if (not getAudioManager():isTrackPlaying(kIndoorAmbienceTag)) then
		getAudioManager():crossFadeTrack({tag=kIndoorAmbienceTag, definition=kIndoorAmbienceName, fadeTime=2000})
	end
	if (not getAudioManager():isTrackPlaying(kIndoorAmbientSweetenerTag)) then
		getAudioManager():playTrack({group=kInsideHutAmbientGroup, tag=kIndoorAmbientSweetenerTag, definition=kIndoorAmbientSweetenerName})
	end
end
-- ----------------------------------------------------------------------------
function playSpookyAmbience()
	-- Check for background track
	if (not getAudioManager():isTrackPlaying(kSpookyAmbienceTag)) then
		getAudioManager():crossFadeTrack({tag=kSpookyAmbienceTag, definition=kSpookyAmbienceName, fadeTime=2000})
	end
	if (not getAudioManager():isTrackPlaying(kSpookyAmbientSweetenerTag)) then
		getAudioManager():playTrack({group=kSpookyAmbientGroup, tag=kSpookyAmbientSweetenerTag, definition=kSpookyAmbientSweetenerName})
	end
end
