Remove MaxVolume from ISoundProvider, provide an IMixedSoundProvider interface for classes that want to use SoundMIxer as part of their sound provider implementation

This commit is contained in:
adelikat 2016-12-08 19:51:17 -06:00
parent 538630f957
commit 657de56123
9 changed files with 19 additions and 24 deletions

View File

@ -4,8 +4,5 @@
{
void GetSamples(short[] samples);
void DiscardSamples();
// TODO: we want to remove this property. Clients do not need this information. This is only used by cores themselves, they should use their own interface/implementation to pass this information around
int MaxVolume { get; set; }
}
}

View File

@ -115,12 +115,6 @@ namespace BizHawk.Emulation.Common
input.DiscardSamples();
}
int ISoundProvider.MaxVolume
{
get { return input.MaxVolume; }
set { input.MaxVolume = value; }
}
void ISyncSoundProvider.GetSamples(out short[] samples, out int nsamp)
{
short[] sampin;

View File

@ -2,23 +2,30 @@
namespace BizHawk.Emulation.Common
{
// This is a straightforward class to mix/chain multiple ISoundProvider sources.
/// <summary>
/// An interface that extends a sound provider to provide mixing capabilities through the SoundMixer class
/// </summary>
public interface IMixedSoundProvider : ISoundProvider
{
int MaxVolume { get; set; }
}
// This is a straightforward class to mix/chain multiple ISoundProvider sources.
public sealed class SoundMixer : ISoundProvider
{
private readonly List<ISoundProvider> SoundProviders;
private readonly List<IMixedSoundProvider> SoundProviders;
public SoundMixer(params ISoundProvider[] soundProviders)
public SoundMixer(params IMixedSoundProvider[] soundProviders)
{
SoundProviders = new List<ISoundProvider>(soundProviders);
SoundProviders = new List<IMixedSoundProvider>(soundProviders);
}
public void AddSource(ISoundProvider source)
public void AddSource(IMixedSoundProvider source)
{
SoundProviders.Add(source);
}
public void DisableSource(ISoundProvider source)
public void DisableSource(IMixedSoundProvider source)
{
SoundProviders.Remove(source);
}
@ -44,8 +51,5 @@ namespace BizHawk.Emulation.Common
source.MaxVolume = eachVolume;
}
}
// Not actually supported on mixer.
public int MaxVolume { get; set; }
}
}

View File

@ -7,7 +7,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.PCEngine
{
public sealed class ADPCM : ISoundProvider
public sealed class ADPCM : IMixedSoundProvider
{
ScsiCDBus SCSI;
PCEngine pce;

View File

@ -10,7 +10,7 @@ using BizHawk.Emulation.DiscSystem;
namespace BizHawk.Emulation.Cores.Components
{
public sealed class CDAudio : ISoundProvider
public sealed class CDAudio : IMixedSoundProvider
{
public const byte CDAudioMode_Stopped = 0;
public const byte CDAudioMode_Playing = 1;

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Components
// Emulates PSG audio unit of a PC Engine / Turbografx-16 / SuperGrafx.
// It is embedded on the CPU and doesn't have its own part number. None the less, it is emulated separately from the 6280 CPU.
public sealed class HuC6280PSG : ISoundProvider
public sealed class HuC6280PSG : IMixedSoundProvider
{
public class PSGChannel
{

View File

@ -5,7 +5,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Components
{
public sealed class SN76489 : ISoundProvider
public sealed class SN76489 : IMixedSoundProvider
{
public sealed class Channel
{

View File

@ -10,7 +10,7 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Common.Components
{
public sealed class YM2413 : ISoundProvider
public sealed class YM2413 : IMixedSoundProvider
{
public byte DetectionValue;
public byte RegisterLatch;

View File

@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Common.Components
// TODO: Seriously, I think we need better resampling code.
// TODO: Experiment with low-pass filters, etc.
public sealed class YM2612 : ISoundProvider
public sealed class YM2612 : IMixedSoundProvider
{
public readonly Channel[] Channels = { new Channel(), new Channel(), new Channel(), new Channel(), new Channel(), new Channel() };