using System;
namespace RealmForge.Audio{
/// <summary>
/// Summary description for VoiceSystem.
/// </summary>
public class VoiceSystem : AudioSystemBase
{
#region Fields, Properties
/// <summary>
/// Singleton instance of the VoiceSystem object.
/// </summary>
public static readonly VoiceSystem Instance = new VoiceSystem();
private ListenerBase listener;
private AudioSubSystem subSystem = AudioSubSystem.OpenAL; // Default to OpenAL.
/// <summary>
/// Represents the listener of the voice.
/// </summary>
public override ListenerBase Listener
{
get
{
return listener;
}
}
/// <summary>
/// Controls which audio subsystem is in use. See <see cref="AudioSubSystem"/>
/// the AudioSubSystem enumeration for possible values.
/// </summary>
public override AudioSubSystem SubSystem
{
get
{
return subSystem;
}
set
{
subSystem = value;
//
// Determine the subsystem that will be used and perform
// initialization for it.
switch(subSystem)
{
case AudioSubSystem.OpenAL:
//
// Initialize OpenAL.
AudioSystemShared.InitializeOpenAL();
//
// Setup the OpenAL listener.
listener = new OpenALListener();
break;
case AudioSubSystem.DirectX:
//
// Exit OpenAL, if necessary. Initialize DirectX.
AudioSystemShared.ExitOpenAL();
break;
}
}
}
#endregion
#region Methods
/// <summary>
/// Performs clean up for unmanaged resources.
/// </summary>
protected override void Cleanup()
{
//
// Clean up unmanaged resources here.
// Exit OpenAL, if necessary.
AudioSystemShared.ExitOpenAL();
base.Cleanup();
}
#endregion
}
}
|