//---------------------------------------------------------------------------------------------
// Audio channel descriptions.
//---------------------------------------------------------------------------------------------

function getAudio (%name, %type)
{//echo("getAudio()");
return;	// AudioProfile doesn't exist in T2D v3.0!
	if (isObject(%name))
	{
		return false;
	}
	return true;
}

// Gets an audio ogg file for music.
function getAudioOgg (%name, %type)
{//echo("getAudioOgg()");
return;	// AudioProfile doesn't exist in T2D v3.0!
	if (isObject(%name))
	{
		return;
	}
}

// Stops playing any .ogg background music.
function stopBGMOgg ()
{//echo("stopBGMOgg()");
	if ($bgmo)
	{
		alxStopAll();
		$bgmo = false;
	}
}

// Set the channel volume to the specified value.
function setChannelVolume (%volume)
{//echo("setChannelVolume()");
	alxSetChannelVolume($GuiAudioType, %volume);
}

// Set music channel to specified volume.
function setMusicVolume (%volume)
{//echo("setMusicVolume()");
	alxSetChannelVolume(0, %volume);
}

// Plays an .ogg file as background music.
function playBGMOggAtVolume (%sound, %volume)
{//echo("playBGMOggAtVolume()");
	//alxSetChannelVolume($GuiAudioType, %volume);
	alxSetChannelVolume(2, %volume);
	if ($bgmo)
	{
		alxStopAll();
		$bgmo = false;
	}
	alxPlay(%sound);
	$bgmo = true;
}

function testStartMusic ()
{
	alxSetChannelVolume($GuiAudioType, 0);
	alxSetChannelVolume($GuiAudioType, $Game::MusicVolume);
}

// Plays an .ogg file as background music.
function playBGMOgg (%sound, %volume)
{//echo("playBGMOgg()");
	alxStopAll();
	alxSetChannelVolume(2, %volume);
	if ($bgmo)
	{
		alxStopAll();
		$bgmo = false;
	}
	alxPlay(%sound);
	$bgmo = true;
}

// Fades out an audio channel.
function fadeOut (%channel)
{//echo("fadeOut()");
	alxSetChannelVolume(%channel, alxGetChannelVolume(%channel) - 0.05);
	if (alxGetChannelVolume(%channel) > 0)
	{
		$fadeOutSchedule = schedule(150, 0, "fadeOut", %channel);
	}
	else
	{
		alxSetChannelVolume(%channel, 0.0);
	}
}

// Fades in an audio channel.
function fadeIn (%channel)
{//echo("fadeIn()");
	alxSetChannelVolume(%channel, alxGetChannelVolume(%channel) + 0.05);
	if (alxGetChannelVolume(%channel) < $Game::MusicVolume)
	{
		$fadeInSchedule = schedule(150, 0, "fadeIn", %channel);
	}
	else
	{
		alxSetChannelVolume(%channel, $Game::MusicVolume);
	}
}
function playBGM (%sound, %volume)
{
	getAudio(%sound, "BGM"); 
	alxSetChannelVolume($GuiAudioType, %volume);
	if ($bgm)
	{
		$bgm = alxStopAll(); 
    }
   $bgm = alxPlay(%sound);
}
function playBGS(%sound, %volume)
{
	getAudio(%sound, "BGS"); 
	alxSetChannelVolume($GuiAudioType, %volume);  
	if ($bgs)
	{
		$bgs = alxStopAll();
	}
	$bgs = alxPlay(%sound);
}
function playAudio (%sound, %volume)
{//echo("playAudio()");echo("%sound =" SPC %sound);
	//getAudio(%sound, 1);   
	$se = alxPlay(%sound);
}
function playMainMenuMusic ()
{//echo("playMainMenuMusic()");
	alxStopAll();
	playAudio("Audio:theme", MusicAudioVolume.value);
}
function playCreditsMusic ()
{//echo("playCreditsMusic()");
	playBGMOgg("Audio:credits", MusicAudioVolume.value);
}
function playCommandDeckMusic ()
{//echo("playCommandDeckMusic()");
	playBGMOgg("Audio:ambientLoop", MusicAudioVolume.value);
}
function playEngineeringDeckMusic ()
{//echo("playEngineeringDeckMusic()");
	playBGMOgg("Audio:ambientLoop", MusicAudioVolume.value);
}
function playMedicalDeckMusic ()
{//echo("playMedicalDeckMusic()");
	playBGMOgg("Audio:ambientLoop", MusicAudioVolume.value);
}
function playArmoryDeckMusic ()
{//echo("playArmoryDeckMusic()");
	playBGMOgg("Audio:ambientLoop", MusicAudioVolume.value);
}
function playBridgeDeckMusic ()
{//echo("playBridgeDeckMusic()");
	playBGMOgg("Audio:ambientLoop", MusicAudioVolume.value);
}
function playAlienDeckMusic ()
{//echo("playAlienDeckMusic()");
	playBGMOgg("Audio:alienDeck", MusicAudioVolume.value);
}

//---------------------------------------------------------------------------------------------
// shutdownOpenAL
//---------------------------------------------------------------------------------------------
function shutdownOpenAL ()
{
	OpenALShutdownDriver();
}