remove libspeexdsp use in old bsnes core
This commit is contained in:
parent
c794d90878
commit
5e9e9ac289
|
@ -198,7 +198,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
public delegate void snes_input_poll_t();
|
||||
public delegate short snes_input_state_t(int port, int device, int index, int id);
|
||||
public delegate void snes_input_notify_t(int index);
|
||||
public delegate void snes_audio_sample_t(ushort left, ushort right);
|
||||
public delegate void snes_audio_sample_t(short left, short right);
|
||||
public delegate void snes_scanlineStart_t(int line);
|
||||
public delegate string snes_path_request_t(int slot, string hint);
|
||||
public delegate void snes_trace_t(uint which, string msg);
|
||||
|
|
|
@ -45,11 +45,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
if (audio_sample != null)
|
||||
{
|
||||
ushort* audiobuffer = ((ushort*)_comm->ptr);
|
||||
var audiobuffer = (short*)_comm->ptr;
|
||||
for (uint i = 0; i < nsamples;)
|
||||
{
|
||||
ushort left = audiobuffer[i++];
|
||||
ushort right = audiobuffer[i++];
|
||||
var left = audiobuffer[i++];
|
||||
var right = audiobuffer[i++];
|
||||
audio_sample(left, right);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
LagCount++;
|
||||
}
|
||||
|
||||
if (renderSound)
|
||||
{
|
||||
ProcessSoundEnd();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -106,7 +111,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
}
|
||||
|
||||
Api.Dispose();
|
||||
_resampler.Dispose();
|
||||
_blipL.Dispose();
|
||||
_blipR.Dispose();
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||
{
|
||||
public partial class LibsnesCore : ISoundProvider
|
||||
{
|
||||
private readonly BlipBuffer _blipL = new(4096);
|
||||
private readonly BlipBuffer _blipR = new(4096);
|
||||
private short _latchL, _latchR;
|
||||
private readonly short[] _sampleBuffer = new short[4096];
|
||||
private uint _inSamps;
|
||||
private int _outSamps;
|
||||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
_outSamps = 0;
|
||||
}
|
||||
|
||||
public void GetSamplesSync(out short[] samples, out int nsamp)
|
||||
{
|
||||
samples = _sampleBuffer;
|
||||
nsamp = _outSamps;
|
||||
DiscardSamples();
|
||||
}
|
||||
|
||||
private void InitAudio()
|
||||
{
|
||||
_blipL.SetRates(32040.5, 44100);
|
||||
_blipR.SetRates(32040.5, 44100);
|
||||
}
|
||||
|
||||
private void snes_audio_sample(short left, short right)
|
||||
{
|
||||
if (_latchL != left)
|
||||
{
|
||||
_blipL.AddDelta(_inSamps, _latchL - left);
|
||||
_latchL = left;
|
||||
}
|
||||
|
||||
if (_latchR != right)
|
||||
{
|
||||
_blipR.AddDelta(_inSamps, _latchR - right);
|
||||
_latchR = right;
|
||||
}
|
||||
|
||||
_inSamps++;
|
||||
}
|
||||
|
||||
private void ProcessSoundEnd()
|
||||
{
|
||||
_blipL.EndFrame(_inSamps);
|
||||
_blipR.EndFrame(_inSamps);
|
||||
_inSamps = 0;
|
||||
|
||||
_outSamps = _blipL.SamplesAvailable();
|
||||
if (_outSamps != _blipR.SamplesAvailable())
|
||||
{
|
||||
throw new InvalidOperationException("Audio processing error");
|
||||
}
|
||||
|
||||
_blipL.ReadSamplesLeft(_sampleBuffer, _outSamps);
|
||||
_blipR.ReadSamplesRight(_sampleBuffer, _outSamps);
|
||||
}
|
||||
|
||||
public bool CanProvideAsync => false;
|
||||
|
||||
public void GetSamplesAsync(short[] samples)
|
||||
{
|
||||
throw new InvalidOperationException("Async mode is not supported.");
|
||||
}
|
||||
|
||||
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
|
||||
|
||||
public void SetSyncMode(SyncSoundMode mode)
|
||||
{
|
||||
if (mode == SyncSoundMode.Async)
|
||||
{
|
||||
throw new NotSupportedException("Async mode is not supported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -100,7 +100,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
// start up audio resampler
|
||||
InitAudio();
|
||||
ser.Register<ISoundProvider>(_resampler);
|
||||
|
||||
// strip header
|
||||
if ((romData?.Length & 0x7FFF) == 512)
|
||||
|
@ -218,7 +217,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
private IController _controller;
|
||||
private readonly LoadParams _currLoadParams;
|
||||
private SpeexResampler _resampler;
|
||||
private int _timeFrameCounter;
|
||||
private bool _disposed;
|
||||
|
||||
|
@ -623,16 +621,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
// return ret;
|
||||
//}
|
||||
|
||||
private void InitAudio()
|
||||
{
|
||||
_resampler = new SpeexResampler((SpeexResampler.Quality)6, 64081, 88200, 32041, 44100);
|
||||
}
|
||||
|
||||
private void snes_audio_sample(ushort left, ushort right)
|
||||
{
|
||||
_resampler.EnqueueSample((short)left, (short)right);
|
||||
}
|
||||
|
||||
private void RefreshPalette()
|
||||
{
|
||||
CurrPalette = (SnesColors.ColorType)Enum.Parse(typeof(SnesColors.ColorType), _settings.Palette, false);
|
||||
|
|
Loading…
Reference in New Issue