2011-01-11 02:55:51 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Sound
|
|
|
|
|
{
|
|
|
|
|
// This is a straightforward class to mix/chain multiple ISoundProvider sources.
|
|
|
|
|
// TODO: Fine-tuned volume control would be a good thing.
|
|
|
|
|
|
|
|
|
|
public sealed class SoundMixer : ISoundProvider
|
|
|
|
|
{
|
|
|
|
|
private List<ISoundProvider> SoundProviders;
|
|
|
|
|
|
|
|
|
|
public SoundMixer(params ISoundProvider[] soundProviders)
|
|
|
|
|
{
|
|
|
|
|
SoundProviders = new List<ISoundProvider>(soundProviders);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddSource(ISoundProvider source)
|
|
|
|
|
{
|
|
|
|
|
SoundProviders.Add(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DisableSource(ISoundProvider source)
|
|
|
|
|
{
|
|
|
|
|
SoundProviders.Remove(source);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-19 09:12:56 +00:00
|
|
|
|
public void DiscardSamples()
|
|
|
|
|
{
|
|
|
|
|
foreach (var soundSource in SoundProviders)
|
|
|
|
|
soundSource.DiscardSamples();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-11 02:55:51 +00:00
|
|
|
|
public void GetSamples(short[] samples)
|
|
|
|
|
{
|
|
|
|
|
foreach (var soundSource in SoundProviders)
|
|
|
|
|
soundSource.GetSamples(samples);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|