More IAsyncSoundProvider and related classes to BizHawk.Emulation.Cores and make them internal, since they are implementation details, and they are deprecrated and not intended to be used in future cores.
This commit is contained in:
parent
c971fba7df
commit
691632f188
|
@ -126,7 +126,6 @@
|
|||
<Compile Include="Interfaces\IEmulatorServiceProvider.cs" />
|
||||
<Compile Include="Interfaces\Services\ICreateGameDBEntries.cs" />
|
||||
<Compile Include="Interfaces\Services\ISoundProvider.cs" />
|
||||
<Compile Include="Interfaces\IAsyncSoundProvider.cs" />
|
||||
<Compile Include="Interfaces\Services\ICodeDataLogger.cs" />
|
||||
<Compile Include="Interfaces\Services\IDebuggable.cs" />
|
||||
<Compile Include="Interfaces\Services\IDisassemblable.cs" />
|
||||
|
@ -147,7 +146,6 @@
|
|||
<Compile Include="Sound\Utilities\DCFilter.cs" />
|
||||
<Compile Include="Sound\Utilities\Equalizer.cs" />
|
||||
<Compile Include="Sound\Utilities\Metaspu.cs" />
|
||||
<Compile Include="Sound\Utilities\SoundMixer.cs" />
|
||||
<Compile Include="Sound\Utilities\SpeexResampler.cs" />
|
||||
<Compile Include="Sound\Utilities\Waves.cs" />
|
||||
<Compile Include="SystemLookup.cs" />
|
||||
|
|
|
@ -58,64 +58,6 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
}
|
||||
|
||||
// An async sound provider
|
||||
// Sound refactor TODO: can this be combined with the other Metaspu?
|
||||
public class MetaspuSoundProvider : ISoundProvider
|
||||
{
|
||||
public MetaspuSoundProvider(ESynchMethod method)
|
||||
{
|
||||
Buffer = Metaspu.metaspu_construct(method);
|
||||
}
|
||||
|
||||
public ISynchronizingAudioBuffer Buffer { get; set; }
|
||||
private readonly short[] pullBuffer = new short[1470];
|
||||
|
||||
public MetaspuSoundProvider()
|
||||
: this(ESynchMethod.ESynchMethod_V)
|
||||
{
|
||||
}
|
||||
|
||||
public void PullSamples(IAsyncSoundProvider source)
|
||||
{
|
||||
Array.Clear(pullBuffer, 0, 1470);
|
||||
source.GetSamples(pullBuffer);
|
||||
Buffer.enqueue_samples(pullBuffer, 735);
|
||||
}
|
||||
|
||||
public bool CanProvideAsync
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public SyncSoundMode SyncMode
|
||||
{
|
||||
get { return SyncSoundMode.Async; }
|
||||
}
|
||||
|
||||
public void SetSyncMode(SyncSoundMode mode)
|
||||
{
|
||||
if (mode != SyncSoundMode.Async)
|
||||
{
|
||||
throw new NotSupportedException("Only Async mode is supported.");
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSamplesSync(out short[] samples, out int nsamp)
|
||||
{
|
||||
throw new InvalidOperationException("Sync mode is not supported.");
|
||||
}
|
||||
|
||||
public void GetSamplesAsync(short[] samples)
|
||||
{
|
||||
Buffer.output_samples(samples, samples.Length / 2);
|
||||
}
|
||||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
Buffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public interface ISynchronizingAudioBuffer
|
||||
{
|
||||
void enqueue_samples(short[] buf, int samples_provided);
|
||||
|
|
|
@ -911,32 +911,32 @@
|
|||
<Compile Include="Consoles\PC Engine\MemoryMap.Populous.cs" />
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.ArcadeCard.cs" />
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.ICodeDataLogger.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.IDebuggable.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.IDriveLight.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.IEmulator.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.IInputPollable.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.IMemoryDomains.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.Input.cs" />
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.ISaveRam.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.ISettable.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.IStatable.cs">
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
<DependentUpon>PCEngine.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\PC Engine\PCEngine.TurboCD.cs" />
|
||||
<Compile Include="Consoles\PC Engine\ScsiCDBus.cs" />
|
||||
|
@ -1197,8 +1197,10 @@
|
|||
<Compile Include="Consoles\Sega\Genesis\MemoryMap.Z80.cs" />
|
||||
<Compile Include="Sound\CDAudio.cs" />
|
||||
<Compile Include="Sound\HuC6280PSG.cs" />
|
||||
<Compile Include="Sound\IAsyncSoundProvider.cs" />
|
||||
<Compile Include="Sound\MMC5Audio.cs" />
|
||||
<Compile Include="Sound\SN76489.cs" />
|
||||
<Compile Include="Sound\SoundMixer.cs" />
|
||||
<Compile Include="Sound\Sunsoft5BAudio.cs" />
|
||||
<Compile Include="Sound\VRC6Alt.cs" />
|
||||
<Compile Include="Sound\YM2413.cs" />
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
||||
{
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface is for legacy sound implementations in some older cores
|
||||
/// This needs to go away, but is provided here, for now
|
||||
/// </summary>
|
||||
public interface IAsyncSoundProvider
|
||||
namespace BizHawk.Emulation.Cores.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface is for legacy sound implementations in some older cores
|
||||
/// This needs to go away, but is provided here, for now
|
||||
/// </summary>
|
||||
internal interface IAsyncSoundProvider
|
||||
{
|
||||
void GetSamples(short[] samples);
|
||||
void DiscardSamples();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TODO: this is a shim for now
|
||||
/// TODO: this is a shim for now, and needs to go away
|
||||
/// turns an IAsyncSoundPRovider into a full ISoundProvider
|
||||
/// This is used in cores that have an async only sound implementation
|
||||
/// better is impleemnt a sync sound option in those cores without the need for
|
||||
/// better is implement a sync sound option in those cores without the need for
|
||||
/// this class or an IAsyncSoundPRovider interface
|
||||
/// </summary>
|
||||
public class FakeSyncSound : ISoundProvider
|
||||
internal class FakeSyncSound : ISoundProvider
|
||||
{
|
||||
private readonly IAsyncSoundProvider source;
|
||||
private readonly int spf;
|
||||
|
@ -75,4 +76,63 @@ namespace BizHawk.Emulation.Common
|
|||
SyncMode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
// An async sound provider
|
||||
// This class needs to go away, it takes an IAsyncSoundProvider
|
||||
// and is only used by legacy sound implementations
|
||||
internal class MetaspuSoundProvider : ISoundProvider
|
||||
{
|
||||
public MetaspuSoundProvider(ESynchMethod method)
|
||||
{
|
||||
Buffer = Metaspu.metaspu_construct(method);
|
||||
}
|
||||
|
||||
public ISynchronizingAudioBuffer Buffer { get; set; }
|
||||
private readonly short[] pullBuffer = new short[1470];
|
||||
|
||||
public MetaspuSoundProvider()
|
||||
: this(ESynchMethod.ESynchMethod_V)
|
||||
{
|
||||
}
|
||||
|
||||
public void PullSamples(IAsyncSoundProvider source)
|
||||
{
|
||||
Array.Clear(pullBuffer, 0, 1470);
|
||||
source.GetSamples(pullBuffer);
|
||||
Buffer.enqueue_samples(pullBuffer, 735);
|
||||
}
|
||||
|
||||
public bool CanProvideAsync
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public SyncSoundMode SyncMode
|
||||
{
|
||||
get { return SyncSoundMode.Async; }
|
||||
}
|
||||
|
||||
public void SetSyncMode(SyncSoundMode mode)
|
||||
{
|
||||
if (mode != SyncSoundMode.Async)
|
||||
{
|
||||
throw new NotSupportedException("Only Async mode is supported.");
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSamplesSync(out short[] samples, out int nsamp)
|
||||
{
|
||||
throw new InvalidOperationException("Sync mode is not supported.");
|
||||
}
|
||||
|
||||
public void GetSamplesAsync(short[] samples)
|
||||
{
|
||||
Buffer.output_samples(samples, samples.Length / 2);
|
||||
}
|
||||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
Buffer.clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +1,60 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface that extends a sound provider to provide mixing capabilities through the SoundMixer class
|
||||
/// </summary>
|
||||
public interface IMixedSoundProvider : IAsyncSoundProvider
|
||||
{
|
||||
int MaxVolume { get; set; }
|
||||
}
|
||||
|
||||
// This is a straightforward class to mix/chain multiple ISoundProvider sources.
|
||||
public sealed class SoundMixer : IAsyncSoundProvider
|
||||
{
|
||||
private readonly List<IMixedSoundProvider> SoundProviders;
|
||||
|
||||
public SoundMixer(params IMixedSoundProvider[] soundProviders)
|
||||
{
|
||||
SoundProviders = new List<IMixedSoundProvider>(soundProviders);
|
||||
}
|
||||
|
||||
public void AddSource(IMixedSoundProvider source)
|
||||
{
|
||||
SoundProviders.Add(source);
|
||||
}
|
||||
|
||||
public void DisableSource(IMixedSoundProvider source)
|
||||
{
|
||||
SoundProviders.Remove(source);
|
||||
}
|
||||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
foreach (var soundSource in SoundProviders)
|
||||
{
|
||||
soundSource.DiscardSamples();
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSamples(short[] samples)
|
||||
{
|
||||
foreach (var soundSource in SoundProviders)
|
||||
{
|
||||
soundSource.GetSamples(samples);
|
||||
}
|
||||
}
|
||||
|
||||
// Splits the volume space equally between available sources.
|
||||
public void EqualizeVolumes()
|
||||
{
|
||||
int eachVolume = short.MaxValue / SoundProviders.Count;
|
||||
foreach (var source in SoundProviders)
|
||||
{
|
||||
source.MaxVolume = eachVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Components
|
||||
{
|
||||
// TODO: Sound mixer is a good concept, but it needs to be refactored to use an ISoundProvider, it perhaps can enforce only recieving providers in Async mode
|
||||
/// <summary>
|
||||
/// An interface that extends a sound provider to provide mixing capabilities through the SoundMixer class
|
||||
/// </summary>
|
||||
internal interface IMixedSoundProvider : IAsyncSoundProvider
|
||||
{
|
||||
int MaxVolume { get; set; }
|
||||
}
|
||||
|
||||
// This is a straightforward class to mix/chain multiple ISoundProvider sources.
|
||||
internal sealed class SoundMixer : IAsyncSoundProvider
|
||||
{
|
||||
private readonly List<IMixedSoundProvider> SoundProviders;
|
||||
|
||||
public SoundMixer(params IMixedSoundProvider[] soundProviders)
|
||||
{
|
||||
SoundProviders = new List<IMixedSoundProvider>(soundProviders);
|
||||
}
|
||||
|
||||
public void AddSource(IMixedSoundProvider source)
|
||||
{
|
||||
SoundProviders.Add(source);
|
||||
}
|
||||
|
||||
public void DisableSource(IMixedSoundProvider source)
|
||||
{
|
||||
SoundProviders.Remove(source);
|
||||
}
|
||||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
foreach (var soundSource in SoundProviders)
|
||||
{
|
||||
soundSource.DiscardSamples();
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSamples(short[] samples)
|
||||
{
|
||||
foreach (var soundSource in SoundProviders)
|
||||
{
|
||||
soundSource.GetSamples(samples);
|
||||
}
|
||||
}
|
||||
|
||||
// Splits the volume space equally between available sources.
|
||||
public void EqualizeVolumes()
|
||||
{
|
||||
int eachVolume = short.MaxValue / SoundProviders.Count;
|
||||
foreach (var source in SoundProviders)
|
||||
{
|
||||
source.MaxVolume = eachVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Cores.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Emulation.Cores.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
// ======================================================================
|
||||
|
|
Loading…
Reference in New Issue