Implemented the MediaPlayer and MediaQueue classes as preparation for native Song playback.
Also added the FrameworkDispatcher calls in the Game class. Checking for possible fire and forget sound instances to be disposed in the FrameworkDispatcher update chain.
This commit is contained in:
parent
c5145397bf
commit
ef734ddcd3
@ -446,6 +446,7 @@
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\ISong.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\IServiceProvider.cs" />
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ANX.Framework.Audio.XactParser;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
@ -74,9 +75,8 @@ namespace ANX.Framework.Audio
|
||||
#region GetCategory
|
||||
public AudioCategory GetCategory(string name)
|
||||
{
|
||||
for (int index = 0; index < generalSettings.Categories.Length; index++)
|
||||
if (generalSettings.Categories[index].Name == name)
|
||||
return generalSettings.Categories[index];
|
||||
foreach (AudioCategory category in generalSettings.Categories.Where(category => category.Name == name))
|
||||
return category;
|
||||
|
||||
return new AudioCategory(name);
|
||||
}
|
||||
@ -85,8 +85,7 @@ namespace ANX.Framework.Audio
|
||||
#region GetGlobalVariable
|
||||
public float GetGlobalVariable(string name)
|
||||
{
|
||||
foreach (var variable in generalSettings.Variables)
|
||||
if (variable.Name == name)
|
||||
foreach (var variable in generalSettings.Variables.Where(variable => variable.Name == name))
|
||||
return variable.StartingValue;
|
||||
|
||||
return 0f;
|
||||
@ -96,8 +95,7 @@ namespace ANX.Framework.Audio
|
||||
#region SetGlobalVariable
|
||||
public void SetGlobalVariable(string name, float value)
|
||||
{
|
||||
foreach (var variable in generalSettings.Variables)
|
||||
if (variable.Name == name)
|
||||
foreach (var variable in generalSettings.Variables.Where(variable => variable.Name == name))
|
||||
variable.StartingValue = MathHelper.Clamp(value, variable.MinValue, variable.MaxValue);
|
||||
}
|
||||
#endregion
|
||||
@ -112,15 +110,15 @@ namespace ANX.Framework.Audio
|
||||
#region Dispose
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
if (Disposing != null)
|
||||
Disposing(this, EventArgs.Empty);
|
||||
|
||||
IsDisposed = true;
|
||||
generalSettings = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
@ -17,61 +17,29 @@ namespace ANX.Framework.Audio
|
||||
public sealed class SoundEffect : IDisposable
|
||||
{
|
||||
#region Static
|
||||
#region DistanceScale
|
||||
public static float DistanceScale
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCreator().DistanceScale;
|
||||
get { return GetCreator().DistanceScale; }
|
||||
set { GetCreator().DistanceScale = value; }
|
||||
}
|
||||
set
|
||||
{
|
||||
GetCreator().DistanceScale = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DopplerScale
|
||||
public static float DopplerScale
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCreator().DopplerScale;
|
||||
get { return GetCreator().DopplerScale; }
|
||||
set { GetCreator().DopplerScale = value; }
|
||||
}
|
||||
set
|
||||
{
|
||||
GetCreator().DopplerScale = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MasterVolume
|
||||
public static float MasterVolume
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCreator().MasterVolume;
|
||||
get { return GetCreator().MasterVolume; }
|
||||
set { GetCreator().MasterVolume = value; }
|
||||
}
|
||||
set
|
||||
{
|
||||
GetCreator().MasterVolume = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SpeedOfSound
|
||||
public static float SpeedOfSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCreator().SpeedOfSound;
|
||||
get { return GetCreator().SpeedOfSound; }
|
||||
set { GetCreator().SpeedOfSound = value; }
|
||||
}
|
||||
set
|
||||
{
|
||||
GetCreator().SpeedOfSound = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private
|
||||
@ -131,11 +99,13 @@ namespace ANX.Framework.Audio
|
||||
{
|
||||
}
|
||||
|
||||
public SoundEffect(byte[] buffer, int offset, int count, int sampleRate, AudioChannels channels, int loopStart, int loopLength)
|
||||
public SoundEffect(byte[] buffer, int offset, int count, int sampleRate, AudioChannels channels, int loopStart,
|
||||
int loopLength)
|
||||
: this()
|
||||
{
|
||||
var creator = GetCreator();
|
||||
NativeSoundEffect = creator.CreateSoundEffect(this, buffer, offset, count, sampleRate, channels, loopStart, loopLength);
|
||||
NativeSoundEffect = creator.CreateSoundEffect(this, buffer, offset, count, sampleRate, channels, loopStart,
|
||||
loopLength);
|
||||
}
|
||||
|
||||
~SoundEffect()
|
||||
@ -204,9 +174,7 @@ namespace ANX.Framework.Audio
|
||||
children.Add(new WeakReference(newInstance));
|
||||
|
||||
lock (fireAndForgetInstances)
|
||||
{
|
||||
fireAndForgetInstances.Add(newInstance);
|
||||
}
|
||||
|
||||
newInstance.Play();
|
||||
}
|
||||
@ -220,6 +188,25 @@ namespace ANX.Framework.Audio
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RecycleStoppedFireAndForgetInstances
|
||||
internal static void RecycleStoppedFireAndForgetInstances()
|
||||
{
|
||||
lock (fireAndForgetInstances)
|
||||
{
|
||||
var instancesToDispose = new List<SoundEffectInstance>();
|
||||
foreach (SoundEffectInstance current in fireAndForgetInstances)
|
||||
if (current.State == SoundState.Stopped)
|
||||
instancesToDispose.Add(current);
|
||||
|
||||
foreach (SoundEffectInstance current in instancesToDispose)
|
||||
{
|
||||
current.Dispose();
|
||||
fireAndForgetInstances.Remove(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
|
@ -16,12 +16,7 @@ namespace ANX.Framework.Audio
|
||||
{
|
||||
#region Private
|
||||
private ISoundEffectInstance nativeInstance;
|
||||
|
||||
internal bool IsFireAndForget
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
internal bool IsFireAndForget { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
|
@ -10,24 +10,12 @@ namespace ANX.Framework.Audio.XactParser
|
||||
internal class XactGeneralSettingsRpcCurve
|
||||
{
|
||||
// what variable this curve involves
|
||||
public ushort VariableIndex
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public ushort VariableIndex { get; private set; }
|
||||
|
||||
// which parameter the curve affects refer to the above constants
|
||||
public short Parameters
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public short Parameters { get; private set; }
|
||||
|
||||
public XactGeneralSettingsRpcCurvePoint[] Points
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public XactGeneralSettingsRpcCurvePoint[] Points { get; private set; }
|
||||
|
||||
public XactGeneralSettingsRpcCurve(BinaryReader reader)
|
||||
{
|
||||
|
@ -17,29 +17,15 @@ namespace ANX.Framework.Audio.XactParser
|
||||
SinCos = 0x03,
|
||||
}
|
||||
|
||||
public float X
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public float Y
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public CurveType Type
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public float X { get; private set; }
|
||||
public float Y { get; private set; }
|
||||
public CurveType Type { get; private set; }
|
||||
|
||||
public XactGeneralSettingsRpcCurvePoint(BinaryReader reader)
|
||||
{
|
||||
X = reader.ReadSingle();
|
||||
Y = reader.ReadSingle();
|
||||
Type = (XactGeneralSettingsRpcCurvePoint.CurveType)reader.ReadByte();
|
||||
Type = (CurveType)reader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,35 +17,15 @@ namespace ANX.Framework.Audio.XactParser
|
||||
Reserved = 0x08,
|
||||
}
|
||||
|
||||
public VariableFlags Flags
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public float StartingValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public float MinValue
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public float MaxValue
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public VariableFlags Flags { get; private set; }
|
||||
public float StartingValue { get; set; }
|
||||
public float MinValue { get; private set; }
|
||||
public float MaxValue { get; private set; }
|
||||
public string Name;
|
||||
|
||||
public XactGeneralSettingsVariable(BinaryReader reader)
|
||||
{
|
||||
Flags = (XactGeneralSettingsVariable.VariableFlags)reader.ReadByte();
|
||||
Flags = (VariableFlags)reader.ReadByte();
|
||||
StartingValue = reader.ReadSingle();
|
||||
MinValue = reader.ReadSingle();
|
||||
MaxValue = reader.ReadSingle();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
@ -18,6 +19,8 @@ namespace ANX.Framework
|
||||
{
|
||||
if (OnUpdate != null)
|
||||
OnUpdate();
|
||||
|
||||
SoundEffect.RecycleStoppedFireAndForgetInstances();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.PlatformSystem;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
|
||||
#endregion // Using Statements
|
||||
|
||||
@ -78,6 +79,8 @@ namespace ANX.Framework
|
||||
AddSystemCreator<ISoundSystemCreator>();
|
||||
AddSystemCreator<IRenderSystemCreator>();
|
||||
|
||||
FrameworkDispatcher.Update();
|
||||
|
||||
CreateGameHost();
|
||||
|
||||
Logger.Info("creating ContentManager");
|
||||
@ -151,6 +154,8 @@ namespace ANX.Framework
|
||||
updateable.Update(gameTime);
|
||||
}
|
||||
}
|
||||
|
||||
FrameworkDispatcher.Update();
|
||||
}
|
||||
|
||||
protected virtual void Draw(GameTime gameTime)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -6,6 +7,9 @@ using System;
|
||||
|
||||
namespace ANX.Framework.Media
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public static class MediaPlayer
|
||||
{
|
||||
#region Events
|
||||
@ -13,118 +17,71 @@ namespace ANX.Framework.Media
|
||||
public static event EventHandler<EventArgs> MediaStateChanged;
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region IsShuffled (TODO)
|
||||
public static bool IsShuffled
|
||||
private static bool isRepeating;
|
||||
private static float volume;
|
||||
private static MediaState currentState;
|
||||
internal static float VolumeToUse
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
get { return IsMuted ? 0f : volume; }
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsRepeating (TODO)
|
||||
#region Public
|
||||
public static bool IsShuffled { get; set; }
|
||||
|
||||
public static bool IsRepeating
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
get { return isRepeating; }
|
||||
set { isRepeating = value; }
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Volume (TODO)
|
||||
public static float Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsMuted (TODO)
|
||||
public static bool IsMuted
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsVisualizationEnabled (TODO)
|
||||
public static bool IsVisualizationEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static MediaQueue Queue
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
get { return volume; }
|
||||
set { volume = MathHelper.Clamp(value, 0f, 1f); }
|
||||
}
|
||||
|
||||
#region State (TODO)
|
||||
public static bool IsVisualizationEnabled { get; set; }
|
||||
public static bool IsMuted { get; set; }
|
||||
public static MediaQueue Queue { get; private set; }
|
||||
public static MediaState State
|
||||
{
|
||||
get
|
||||
get { return currentState; }
|
||||
private set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
if (currentState == value)
|
||||
return;
|
||||
|
||||
currentState = value;
|
||||
MediaStateChanged(null, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
#region PlayPosition (TODO)
|
||||
public static TimeSpan PlayPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Queue.ActiveSong == null
|
||||
? TimeSpan.Zero : Queue.ActiveSong.NativeSong.PlayPosition;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GameHasControl (TODO)
|
||||
public static bool GameHasControl
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
static MediaPlayer()
|
||||
{
|
||||
currentState = MediaState.Stopped;
|
||||
volume = 1f;
|
||||
isRepeating = false;
|
||||
IsMuted = false;
|
||||
IsVisualizationEnabled = false;
|
||||
IsShuffled = false;
|
||||
Queue = new MediaQueue();
|
||||
FrameworkDispatcher.OnUpdate += Tick;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -133,47 +90,45 @@ namespace ANX.Framework.Media
|
||||
{
|
||||
Queue.Play(song);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Play
|
||||
public static void Play(SongCollection songCollection)
|
||||
{
|
||||
Queue.Play(songCollection);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Play (TODO)
|
||||
public static void Play(SongCollection songCollection, int index)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Queue.Play(songCollection, index);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Pause (TODO)
|
||||
#region Pause
|
||||
public static void Pause()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (Queue.ActiveSong != null)
|
||||
Queue.ActiveSong.Pause();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Resume (TODO)
|
||||
#region Resume
|
||||
public static void Resume()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (Queue.ActiveSong != null)
|
||||
Queue.ActiveSong.Resume();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Stop (TODO)
|
||||
#region Stop
|
||||
public static void Stop()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Queue.Stop();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MoveNext
|
||||
public static void MoveNext()
|
||||
{
|
||||
Queue.MoveNext();
|
||||
Queue.MoveNext(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -184,10 +139,37 @@ namespace ANX.Framework.Media
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetVisualizationData (TODO)
|
||||
public static void GetVisualizationData(VisualizationData data)
|
||||
#region Tick
|
||||
private static void Tick()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (Queue.ActiveSong == null)
|
||||
{
|
||||
State = MediaState.Stopped;
|
||||
return;
|
||||
}
|
||||
|
||||
State = Queue.ActiveSong.State;
|
||||
if (Queue.ActiveSong.State != MediaState.Stopped)
|
||||
return;
|
||||
|
||||
if (Queue.MoveNext(isRepeating))
|
||||
State = MediaState.Playing;
|
||||
|
||||
ActiveSongChanged(null, EventArgs.Empty);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetVisualizationData
|
||||
public static void GetVisualizationData(VisualizationData visualizationData)
|
||||
{
|
||||
if (visualizationData == null)
|
||||
throw new ArgumentNullException("visualizationData");
|
||||
|
||||
if (IsVisualizationEnabled == false)
|
||||
return;
|
||||
|
||||
if(Queue.ActiveSong != null)
|
||||
Queue.ActiveSong.NativeSong.GetVisualizationData(visualizationData);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -7,41 +8,29 @@ using System.Collections.Generic;
|
||||
|
||||
namespace ANX.Framework.Media
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public sealed class MediaQueue
|
||||
{
|
||||
#region Private
|
||||
private List<Song> queue;
|
||||
#endregion
|
||||
private readonly List<Song> queue;
|
||||
|
||||
#region Public
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return queue.Count;
|
||||
}
|
||||
get { return queue.Count; }
|
||||
}
|
||||
|
||||
public int ActiveSongIndex
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int ActiveSongIndex { get; set; }
|
||||
|
||||
public Song ActiveSong
|
||||
{
|
||||
get
|
||||
{
|
||||
return queue[ActiveSongIndex];
|
||||
}
|
||||
get { return queue.Count <= 0 ? null : queue[ActiveSongIndex]; }
|
||||
}
|
||||
|
||||
public Song this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return queue[index];
|
||||
}
|
||||
get { return queue[index]; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -50,14 +39,22 @@ namespace ANX.Framework.Media
|
||||
{
|
||||
queue = new List<Song>();
|
||||
}
|
||||
|
||||
~MediaQueue()
|
||||
{
|
||||
queue.Clear();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Play
|
||||
internal void Play(Song song)
|
||||
{
|
||||
if (song == null)
|
||||
throw new ArgumentNullException("song");
|
||||
|
||||
Clear();
|
||||
queue.Add(song);
|
||||
ActiveSong.Play();
|
||||
}
|
||||
|
||||
internal void Play(SongCollection songCollection)
|
||||
@ -65,29 +62,93 @@ namespace ANX.Framework.Media
|
||||
if (songCollection == null)
|
||||
throw new ArgumentNullException("songCollection");
|
||||
|
||||
Clear();
|
||||
queue.AddRange(songCollection);
|
||||
// TODO: check if the shuffle is calculated after each finished song or like this!
|
||||
if (MediaPlayer.IsShuffled)
|
||||
Shuffle();
|
||||
ActiveSong.Play();
|
||||
}
|
||||
|
||||
internal void MoveNext()
|
||||
internal void Play(SongCollection songCollection, int index)
|
||||
{
|
||||
if (Count > 0)
|
||||
if (songCollection == null)
|
||||
throw new ArgumentNullException("songCollection");
|
||||
|
||||
Clear();
|
||||
ActiveSongIndex = index;
|
||||
queue.AddRange(songCollection);
|
||||
// TODO: check if the shuffle is calculated after each finished song or like this!
|
||||
if (MediaPlayer.IsShuffled)
|
||||
Shuffle();
|
||||
ActiveSong.Play();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void Clear()
|
||||
{
|
||||
Stop();
|
||||
ActiveSongIndex = 0;
|
||||
queue.Clear();
|
||||
}
|
||||
|
||||
internal void Stop()
|
||||
{
|
||||
if(ActiveSong != null)
|
||||
ActiveSong.Stop();
|
||||
}
|
||||
|
||||
private void Shuffle()
|
||||
{
|
||||
var rand = new Random();
|
||||
int n = queue.Count;
|
||||
while (n > 1)
|
||||
{
|
||||
int k = rand.Next(n);
|
||||
n--;
|
||||
Song value = queue[k];
|
||||
queue[k] = queue[n];
|
||||
queue[n] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region MoveNext
|
||||
internal bool MoveNext(bool stopIfEnded)
|
||||
{
|
||||
if (Count <= 0)
|
||||
return false;
|
||||
|
||||
ActiveSong.Stop();
|
||||
|
||||
if (ActiveSongIndex < Count - 1)
|
||||
ActiveSongIndex++;
|
||||
else
|
||||
{
|
||||
ActiveSongIndex = 0;
|
||||
}
|
||||
if (stopIfEnded)
|
||||
return false;
|
||||
}
|
||||
|
||||
ActiveSong.Play();
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MovePrevious
|
||||
internal void MovePrevious()
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
if (Count <= 0)
|
||||
return;
|
||||
|
||||
ActiveSong.Stop();
|
||||
|
||||
if (ActiveSongIndex > 0)
|
||||
ActiveSongIndex--;
|
||||
else
|
||||
ActiveSongIndex = Count - 1;
|
||||
|
||||
ActiveSong.Play();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -6,26 +9,20 @@ using System;
|
||||
|
||||
namespace ANX.Framework.Media
|
||||
{
|
||||
[PercentageComplete(50)]
|
||||
[Developer("AstrorEnales")]
|
||||
public sealed class Song : IEquatable<Song>, IDisposable
|
||||
{
|
||||
public bool IsDisposed
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
internal ISong NativeSong { get; private set; }
|
||||
internal MediaState State { get { return NativeSong.State; } }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#region Public
|
||||
public bool IsDisposed { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
public bool IsRated
|
||||
{
|
||||
get
|
||||
{
|
||||
return Rating > 0;
|
||||
}
|
||||
get { return Rating > 0; }
|
||||
}
|
||||
|
||||
public Artist Artist
|
||||
@ -54,10 +51,7 @@ namespace ANX.Framework.Media
|
||||
|
||||
public TimeSpan Duration
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
get { return NativeSong.Duration; }
|
||||
}
|
||||
|
||||
public int Rating
|
||||
@ -91,10 +85,12 @@ namespace ANX.Framework.Media
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
internal Song(string setName)
|
||||
internal Song(string setName, Uri uri)
|
||||
{
|
||||
NativeSong = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>().CreateSong(this, uri);
|
||||
Name = setName;
|
||||
IsDisposed = false;
|
||||
}
|
||||
@ -105,9 +101,9 @@ namespace ANX.Framework.Media
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Song FromUri(string name, Uri uri)
|
||||
public static Song FromUri(string name, Uri uri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return new Song(name, uri);
|
||||
}
|
||||
|
||||
public bool Equals(Song other)
|
||||
@ -125,11 +121,34 @@ namespace ANX.Framework.Media
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
IsDisposed = true;
|
||||
throw new NotImplementedException();
|
||||
|
||||
if(NativeSong != null)
|
||||
NativeSong.Dispose();
|
||||
NativeSong = null;
|
||||
}
|
||||
|
||||
internal void Play()
|
||||
{
|
||||
NativeSong.Play();
|
||||
}
|
||||
|
||||
internal void Stop()
|
||||
{
|
||||
NativeSong.Stop();
|
||||
}
|
||||
|
||||
internal void Pause()
|
||||
{
|
||||
NativeSong.Pause();
|
||||
}
|
||||
|
||||
internal void Resume()
|
||||
{
|
||||
NativeSong.Resume();
|
||||
}
|
||||
|
||||
#region ToString
|
||||
@ -149,12 +168,12 @@ namespace ANX.Framework.Media
|
||||
#region Operator overloading
|
||||
public static bool operator ==(Song first, Song second)
|
||||
{
|
||||
return first.Equals(second);
|
||||
return first != null && first.Equals(second);
|
||||
}
|
||||
|
||||
public static bool operator !=(Song first, Song second)
|
||||
{
|
||||
return first.Equals(second) == false;
|
||||
return first == null || first.Equals(second) == false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
@ -9,20 +8,23 @@ namespace ANX.Framework.Media
|
||||
{
|
||||
public class VisualizationData
|
||||
{
|
||||
internal readonly float[] FrequencyData;
|
||||
internal readonly float[] SampleData;
|
||||
|
||||
public ReadOnlyCollection<float> Frequencies
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
get { return new ReadOnlyCollection<float>(FrequencyData); }
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<float> Samples
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
get { return new ReadOnlyCollection<float>(SampleData); }
|
||||
}
|
||||
|
||||
public VisualizationData()
|
||||
{
|
||||
FrequencyData = new float[256];
|
||||
SampleData = new float[256];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ANX.Framework.NonXNA.PlatformSystem;
|
||||
using ANX.Framework.NonXNA.Reflection;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
|
19
ANX.Framework/NonXNA/SoundSystem/ISong.cs
Normal file
19
ANX.Framework/NonXNA/SoundSystem/ISong.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using ANX.Framework.Media;
|
||||
|
||||
namespace ANX.Framework.NonXNA.SoundSystem
|
||||
{
|
||||
public interface ISong : IDisposable
|
||||
{
|
||||
TimeSpan Duration { get; }
|
||||
TimeSpan PlayPosition { get; }
|
||||
MediaState State { get; }
|
||||
|
||||
void Play();
|
||||
void Stop();
|
||||
void Pause();
|
||||
void Resume();
|
||||
void Update();
|
||||
void GetVisualizationData(VisualizationData data);
|
||||
}
|
||||
}
|
@ -1,39 +1,21 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
using System.Collections.ObjectModel;
|
||||
using ANX.Framework.Media;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.Framework.NonXNA
|
||||
namespace ANX.Framework.NonXNA.SoundSystem
|
||||
{
|
||||
public interface ISoundSystemCreator : ICreator
|
||||
{
|
||||
float DistanceScale
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
float DopplerScale
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
float MasterVolume
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
float SpeedOfSound
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
float DistanceScale { get; set; }
|
||||
float DopplerScale { get; set; }
|
||||
float MasterVolume { get; set; }
|
||||
float SpeedOfSound { get; set; }
|
||||
|
||||
IAudioListener CreateAudioListener();
|
||||
|
||||
@ -52,5 +34,7 @@ namespace ANX.Framework.NonXNA
|
||||
ReadOnlyCollection<Microphone> GetAllMicrophones();
|
||||
|
||||
int GetDefaultMicrophone(ReadOnlyCollection<Microphone> allMicrophones);
|
||||
|
||||
ISong CreateSong(Song parentSong, Uri uri);
|
||||
}
|
||||
}
|
||||
|
@ -39,17 +39,17 @@ using System.Runtime.InteropServices;
|
||||
[assembly: InternalsVisibleTo("ANX.RenderSystem.Windows.Metro")]
|
||||
[assembly: InternalsVisibleTo("ANX.RenderSystem.GL3")]
|
||||
[assembly: InternalsVisibleTo("ANX.RenderSystem.Windows.PsVita")]
|
||||
[assembly: InternalsVisibleTo("ANX.Framework.Windows.Kinect")]
|
||||
[assembly: InternalsVisibleTo("ANX.Framework.Windows.XInput")]
|
||||
[assembly: InternalsVisibleTo("ANX.Framework.Windows.XAudio")]
|
||||
[assembly: InternalsVisibleTo("ANX.InputSystem.Recording")]
|
||||
[assembly: InternalsVisibleTo("ANX.InputDevices.PsVita")]
|
||||
[assembly: InternalsVisibleTo("ANX.InputDevices.Test")]
|
||||
[assembly: InternalsVisibleTo("ANX.InputDevices.Windows.Kinect")]
|
||||
[assembly: InternalsVisibleTo("ANX.InputDevices.Windows.XInput")]
|
||||
[assembly: InternalsVisibleTo("ANX.InputDevices.Windows.ModernUI")]
|
||||
[assembly: InternalsVisibleTo("ANX.PlatformSystem.Windows")]
|
||||
[assembly: InternalsVisibleTo("ANX.PlatformSystem.Linux")]
|
||||
[assembly: InternalsVisibleTo("ANX.PlatformSystem.Metro")]
|
||||
[assembly: InternalsVisibleTo("ANX.PlatformSystem.PsVita")]
|
||||
[assembly: InternalsVisibleTo("ANX.SoundSystem.Windows.XAudio")]
|
||||
[assembly: InternalsVisibleTo("ANX.SoundSystem.Windows.OpenAL")]
|
||||
[assembly: InternalsVisibleTo("ANX.Tools.XNBInspector")]
|
||||
[assembly: InternalsVisibleTo("ANX.Framework.Content.Pipeline")]
|
@ -42,25 +42,17 @@ namespace ANX.RenderSystem.GL3
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Current == null || Current.nativeContext == null) ? false : Current.nativeContext.IsCurrent;
|
||||
return (Current != null && Current.nativeContext != null) && Current.nativeContext.IsCurrent;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region VSync
|
||||
public bool VSync
|
||||
{
|
||||
get
|
||||
{
|
||||
return nativeContext.VSync;
|
||||
get { return nativeContext.VSync; }
|
||||
set { nativeContext.VSync = value; }
|
||||
}
|
||||
set
|
||||
{
|
||||
nativeContext.VSync = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Graphics;
|
||||
using System.Windows.Interop;
|
||||
using System;
|
||||
using System.Windows.Threading;
|
||||
using System.Threading;
|
||||
using ANX.Framework.NonXNA;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -12,13 +12,18 @@ using System.Threading;
|
||||
|
||||
namespace WpfEditor
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainWindow
|
||||
{
|
||||
private GraphicsDevice device;
|
||||
private readonly ThreadStart emptyThreadStart;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
emptyThreadStart = delegate { };
|
||||
|
||||
//AddInSystemFactory.Instance.SetPreferredSystem(AddInType.RenderSystem, "OpenGL3");
|
||||
AddInSystemFactory.Instance.SetPreferredSystem(AddInType.RenderSystem, "DirectX10");
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
@ -30,10 +35,7 @@ namespace WpfEditor
|
||||
while (IsVisible)
|
||||
{
|
||||
if (Application.Current != null)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(
|
||||
DispatcherPriority.Background, new ThreadStart(delegate { }));
|
||||
}
|
||||
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, emptyThreadStart);
|
||||
|
||||
Tick();
|
||||
}
|
||||
@ -41,13 +43,11 @@ namespace WpfEditor
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
device = new GraphicsDevice(
|
||||
GraphicsAdapter.DefaultAdapter,
|
||||
GraphicsProfile.HiDef,
|
||||
device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef,
|
||||
new PresentationParameters
|
||||
{
|
||||
BackBufferWidth = (int)GamePanel.Width,
|
||||
BackBufferHeight = (int)GamePanel.Height,
|
||||
BackBufferWidth = GamePanel.Width,
|
||||
BackBufferHeight = GamePanel.Height,
|
||||
BackBufferFormat = SurfaceFormat.Color,
|
||||
DeviceWindowHandle = GamePanel.Handle,
|
||||
PresentationInterval = PresentInterval.Default,
|
||||
|
@ -107,6 +107,10 @@
|
||||
<Project>{49066074-3B7B-4A55-B122-6BD33AB73558}</Project>
|
||||
<Name>ANX.InputSystem.Standard</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.Framework.GL3\ANX.RenderSystem.GL3.csproj">
|
||||
<Project>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</Project>
|
||||
<Name>ANX.RenderSystem.GL3</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
|
||||
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
|
||||
<Name>ANX.RenderSystem.Windows.DX10</Name>
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.Media;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
using OpenTK;
|
||||
@ -15,21 +16,18 @@ namespace ANX.SoundSystem.OpenAL
|
||||
{
|
||||
public class Creator : ISoundSystemCreator
|
||||
{
|
||||
private float currentDistanceScale;
|
||||
private float currentMasterVolume;
|
||||
|
||||
#region Public
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "OpenAL";
|
||||
}
|
||||
get { return "OpenAL"; }
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
get { return 100; }
|
||||
}
|
||||
|
||||
public bool IsSupported
|
||||
@ -45,75 +43,55 @@ namespace ANX.SoundSystem.OpenAL
|
||||
|
||||
public float DistanceScale
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1f;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
get { return currentDistanceScale; }
|
||||
set
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
currentDistanceScale = value;
|
||||
// TODO: set actual property
|
||||
}
|
||||
}
|
||||
|
||||
public float DopplerScale
|
||||
{
|
||||
get
|
||||
{
|
||||
return AL.Get(ALGetFloat.DopplerFactor);
|
||||
}
|
||||
set
|
||||
{
|
||||
AL.DopplerFactor(value);
|
||||
}
|
||||
get { return AL.Get(ALGetFloat.DopplerFactor); }
|
||||
set { AL.DopplerFactor(value); }
|
||||
}
|
||||
|
||||
public float MasterVolume
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1f;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
get { return currentMasterVolume; }
|
||||
set
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
currentMasterVolume = value;
|
||||
// TODO: set actual property
|
||||
}
|
||||
}
|
||||
|
||||
public float SpeedOfSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return AL.Get(ALGetFloat.SpeedOfSound);
|
||||
}
|
||||
set
|
||||
{
|
||||
AL.SpeedOfSound(value);
|
||||
}
|
||||
get { return AL.Get(ALGetFloat.SpeedOfSound); }
|
||||
set { AL.SpeedOfSound(value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Creator()
|
||||
{
|
||||
currentDistanceScale = 1f;
|
||||
currentMasterVolume = 1f;
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
private static void Init()
|
||||
{
|
||||
IntPtr deviceHandle;
|
||||
ContextHandle context = Alc.GetCurrentContext();
|
||||
if (context.Handle != IntPtr.Zero)
|
||||
if (context.Handle == IntPtr.Zero)
|
||||
{
|
||||
deviceHandle = Alc.GetContextsDevice(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceHandle = Alc.OpenDevice(Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier));
|
||||
string deviceName = Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier);
|
||||
IntPtr deviceHandle = Alc.OpenDevice(deviceName);
|
||||
context = Alc.CreateContext(deviceHandle, new int[0]);
|
||||
}
|
||||
|
||||
bool isNowCurrent = Alc.MakeContextCurrent(context);
|
||||
Alc.MakeContextCurrent(context);
|
||||
}
|
||||
|
||||
#region CreateSoundEffectInstance
|
||||
@ -181,7 +159,13 @@ namespace ANX.SoundSystem.OpenAL
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void PreventSystemChange()
|
||||
public ISong CreateSong(Song parentSong, Uri uri)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static void PreventSystemChange()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.SoundSystem);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ namespace ANX.SoundSystem.OpenAL
|
||||
public class OpenALSoundEffectInstance : ISoundEffectInstance
|
||||
{
|
||||
#region Private
|
||||
private OpenALSoundEffect parent;
|
||||
|
||||
private readonly OpenALSoundEffect parent;
|
||||
private float currentPan;
|
||||
private int handle;
|
||||
#endregion
|
||||
|
||||
@ -26,22 +26,16 @@ namespace ANX.SoundSystem.OpenAL
|
||||
AL.GetSource(handle, ALSourceb.Looping, out result);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
AL.Source(handle, ALSourceb.Looping, value);
|
||||
}
|
||||
set { AL.Source(handle, ALSourceb.Looping, value); }
|
||||
}
|
||||
|
||||
public float Pan
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0f;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
get { return currentPan; }
|
||||
set
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
currentPan = value;
|
||||
// TODO: set actual parameter
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,17 +47,10 @@ namespace ANX.SoundSystem.OpenAL
|
||||
AL.GetSource(handle, ALSourcef.Pitch, out result);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
AL.Source(handle, ALSourcef.Pitch, value);
|
||||
}
|
||||
set { AL.Source(handle, ALSourcef.Pitch, value); }
|
||||
}
|
||||
|
||||
public SoundState State
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public SoundState State { get; private set; }
|
||||
|
||||
public float Volume
|
||||
{
|
||||
@ -73,10 +60,7 @@ namespace ANX.SoundSystem.OpenAL
|
||||
AL.GetSource(handle, ALSourcef.Gain, out result);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
AL.Source(handle, ALSourcef.Gain, value);
|
||||
}
|
||||
set { AL.Source(handle, ALSourcef.Gain, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -84,15 +68,13 @@ namespace ANX.SoundSystem.OpenAL
|
||||
internal OpenALSoundEffectInstance(OpenALSoundEffect setParent)
|
||||
{
|
||||
parent = setParent;
|
||||
|
||||
State = SoundState.Stopped;
|
||||
|
||||
handle = AL.GenSource();
|
||||
AL.Source(handle, ALSourcei.Buffer, parent.bufferHandle);
|
||||
IsLooped = false;
|
||||
Pitch = 1f;
|
||||
Volume = 1f;
|
||||
// TODO: Pan = 0f;
|
||||
Pan = 0f;
|
||||
|
||||
ALError error = AL.GetError();
|
||||
if (error != ALError.NoError)
|
||||
@ -103,48 +85,45 @@ namespace ANX.SoundSystem.OpenAL
|
||||
#region Play
|
||||
public void Play()
|
||||
{
|
||||
if (State != SoundState.Playing)
|
||||
{
|
||||
if (State == SoundState.Playing)
|
||||
return;
|
||||
|
||||
State = SoundState.Playing;
|
||||
AL.SourcePlay(handle);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Pause
|
||||
public void Pause()
|
||||
{
|
||||
if (State != SoundState.Paused)
|
||||
{
|
||||
if (State == SoundState.Paused)
|
||||
return;
|
||||
|
||||
State = SoundState.Paused;
|
||||
AL.SourcePause(handle);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Stop
|
||||
public void Stop(bool immediate)
|
||||
{
|
||||
if (State == SoundState.Stopped)
|
||||
if (State == SoundState.Stopped || immediate == false)
|
||||
return;
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
State = SoundState.Stopped;
|
||||
AL.SourceStop(handle);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Resume
|
||||
public void Resume()
|
||||
{
|
||||
if (State != SoundState.Playing)
|
||||
{
|
||||
if (State == SoundState.Playing)
|
||||
return;
|
||||
|
||||
State = SoundState.Playing;
|
||||
AL.SourcePlay(handle);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply3D (TODO)
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.Media;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
|
||||
@ -164,5 +165,11 @@ namespace ANX.SoundSystem.PsVita
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public ISong CreateSong(Song parentSong, Uri uri)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.SoundSystem);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using ANX.Framework.Audio;
|
||||
using ANX.Framework.Media;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.SoundSystem;
|
||||
using SharpDX.XAudio2;
|
||||
@ -86,7 +87,10 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
~Creator()
|
||||
{
|
||||
if (MasteringVoice != null)
|
||||
{
|
||||
MasteringVoice.DestroyVoice();
|
||||
MasteringVoice.Dispose();
|
||||
}
|
||||
|
||||
if (device != null)
|
||||
device.Dispose();
|
||||
@ -144,6 +148,12 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
}
|
||||
|
||||
public int GetDefaultMicrophone(ReadOnlyCollection<Microphone> allMicrophones)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ISong CreateSong(Song parentSong, Uri uri)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
|
@ -74,11 +74,17 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
currentPan = 0f;
|
||||
currentPitch = 1f;
|
||||
State = SoundState.Stopped;
|
||||
source = new SourceVoice(device, setParent.WaveFormat);
|
||||
source = new SourceVoice(device, setParent.WaveFormat, true);
|
||||
source.SubmitSourceBuffer(setParent.AudioBuffer, setParent.DecodedPacketsInfo);
|
||||
source.StreamEnd += StreamEnd;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void StreamEnd()
|
||||
{
|
||||
State = SoundState.Stopped;
|
||||
}
|
||||
|
||||
#region Play
|
||||
public void Play()
|
||||
{
|
||||
@ -94,6 +100,7 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
public void Pause()
|
||||
{
|
||||
State = SoundState.Paused;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -115,6 +122,7 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
public void Resume()
|
||||
{
|
||||
State = SoundState.Playing;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -182,7 +190,11 @@ namespace ANX.SoundSystem.Windows.XAudio
|
||||
public void Dispose()
|
||||
{
|
||||
if (source != null)
|
||||
{
|
||||
source.StreamEnd -= StreamEnd;
|
||||
source.DestroyVoice();
|
||||
source.Dispose();
|
||||
}
|
||||
source = null;
|
||||
}
|
||||
#endregion
|
||||
|
Loading…
x
Reference in New Issue
Block a user