forked from MoonsideGames/MoonWorks
register new SourceVoices as active
parent
088e7c4b6f
commit
e77c87c772
|
@ -253,6 +253,11 @@ namespace MoonWorks.Audio
|
||||||
lock (StateLock)
|
lock (StateLock)
|
||||||
{
|
{
|
||||||
resources.Add(resource.weakReference);
|
resources.Add(resource.weakReference);
|
||||||
|
|
||||||
|
if (resource is SourceVoice voice)
|
||||||
|
{
|
||||||
|
activeSourceVoices.Add(voice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ namespace MoonWorks.Audio
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plays back a series of AudioBuffers in sequence. Set the OnSoundNeeded callback to add AudioBuffers dynamically.
|
/// Plays back a series of AudioBuffers in sequence. Set the OnSoundNeeded callback to add AudioBuffers dynamically.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SoundSequence : SourceVoice
|
public class SoundSequence : SourceVoice, IPoolable<SoundSequence>
|
||||||
{
|
{
|
||||||
public int NeedSoundThreshold = 0;
|
public int NeedSoundThreshold = 0;
|
||||||
public delegate void OnSoundNeededFunc();
|
public delegate void OnSoundNeededFunc();
|
||||||
|
@ -19,6 +19,11 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SoundSequence Create(AudioDevice device, Format format)
|
||||||
|
{
|
||||||
|
return new SoundSequence(device, format);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
lock (StateLock)
|
lock (StateLock)
|
||||||
|
@ -27,7 +32,9 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
if (NeedSoundThreshold > 0)
|
if (NeedSoundThreshold > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NeedSoundThreshold - BuffersQueued; i += 1)
|
var buffersNeeded = NeedSoundThreshold - (int) BuffersQueued;
|
||||||
|
|
||||||
|
for (int i = 0; i < buffersNeeded; i += 1)
|
||||||
{
|
{
|
||||||
if (OnSoundNeeded != null)
|
if (OnSoundNeeded != null)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +51,7 @@ namespace MoonWorks.Audio
|
||||||
if (!(buffer.Format == Format))
|
if (!(buffer.Format == Format))
|
||||||
{
|
{
|
||||||
Logger.LogWarn("Sound sequence audio format mismatch!");
|
Logger.LogWarn("Sound sequence audio format mismatch!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue