Clean up namespaces for BizHawk.Emulation sound files
This commit is contained in:
parent
906c0316a6
commit
25b242ade4
|
@ -998,7 +998,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
//avi/wav state
|
||||
private IVideoWriter CurrAviWriter;
|
||||
private ISoundProvider AviSoundInput;
|
||||
private Emulation.Sound.MetaspuSoundProvider DumpProxy; //an audio proxy used for dumping
|
||||
private MetaspuSoundProvider DumpProxy; //an audio proxy used for dumping
|
||||
private long SoundRemainder; //audio timekeeping for video dumping
|
||||
private int avwriter_resizew;
|
||||
private int avwriter_resizeh;
|
||||
|
@ -1412,7 +1412,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (!Global.Emulator.StartAsyncSound())
|
||||
{
|
||||
// if the core doesn't support async mode, use a standard vecna wrapper
|
||||
GlobalWin.Sound.SetAsyncInputPin(new Emulation.Sound.MetaspuAsync(Global.Emulator.SyncSoundProvider, Emulation.Sound.ESynchMethod.ESynchMethod_V));
|
||||
GlobalWin.Sound.SetAsyncInputPin(new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2854,10 +2854,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// do sound rewire. the plan is to eventually have AVI writing support syncsound input, but it doesn't for the moment
|
||||
if (!Global.Emulator.StartAsyncSound())
|
||||
AviSoundInput = new Emulation.Sound.MetaspuAsync(Global.Emulator.SyncSoundProvider, Emulation.Sound.ESynchMethod.ESynchMethod_V);
|
||||
AviSoundInput = new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V);
|
||||
else
|
||||
AviSoundInput = Global.Emulator.SoundProvider;
|
||||
DumpProxy = new Emulation.Sound.MetaspuSoundProvider(Emulation.Sound.ESynchMethod.ESynchMethod_V);
|
||||
DumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
|
||||
SoundRemainder = 0;
|
||||
RewireSound();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Sound;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if WINDOWS
|
||||
using SlimDX.DirectSound;
|
||||
using SlimDX.Multimedia;
|
||||
#endif
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete
|
||||
#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete
|
||||
|
@ -14,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|||
|
||||
// ------------------------------------
|
||||
|
||||
public Sound.Utilities.SpeexResampler resampler;
|
||||
public SpeexResampler resampler;
|
||||
|
||||
static int[] syncNextTable = new int[] { 1, 2, 0 };
|
||||
static int[] syncPrevTable = new int[] { 2, 0, 1 };
|
||||
|
@ -72,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|||
for (int i = 0; i < 3; i++)
|
||||
filterEnable[i] = false;
|
||||
|
||||
resampler = new Sound.Utilities.SpeexResampler(0, cyclesNum, sampleRate * cyclesDen, cyclesNum, sampleRate * cyclesDen, null, null);
|
||||
resampler = new SpeexResampler(0, cyclesNum, sampleRate * cyclesDen, cyclesNum, sampleRate * cyclesDen, null, null);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components.M6502;
|
||||
|
||||
|
||||
|
@ -12,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
public MOS6502X cpu;
|
||||
public M6532 m6532;
|
||||
public TIA tia;
|
||||
public Emulation.Sound.Utilities.DCFilter dcfilter;
|
||||
public DCFilter dcfilter;
|
||||
public byte[] ram = new byte[128];
|
||||
public MapperBase mapper;
|
||||
|
||||
|
@ -183,7 +184,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
//tia = new TIA(this, frameBuffer);
|
||||
tia = new TIA(this);
|
||||
// dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
|
||||
dcfilter = Emulation.Sound.Utilities.DCFilter.AsISoundProvider(tia, 256);
|
||||
dcfilter = DCFilter.AsISoundProvider(tia, 256);
|
||||
// Setup 6532
|
||||
m6532 = new M6532(this);
|
||||
|
||||
|
|
|
@ -344,16 +344,16 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
// really shouldn't happen (after init), but if it does, we're ready
|
||||
if (resampler != null)
|
||||
resampler.Dispose();
|
||||
resampler = new Emulation.Sound.Utilities.SpeexResampler(3, newsamplerate, 44100, newsamplerate, 44100, null, null);
|
||||
resampler = new SpeexResampler(3, newsamplerate, 44100, newsamplerate, 44100, null, null);
|
||||
samplerate = newsamplerate;
|
||||
dcfilter = Emulation.Sound.Utilities.DCFilter.DetatchedMode(256);
|
||||
dcfilter = DCFilter.DetatchedMode(256);
|
||||
}
|
||||
}
|
||||
|
||||
uint samplerate;
|
||||
int[] vidbuffer;
|
||||
Emulation.Sound.Utilities.SpeexResampler resampler;
|
||||
Emulation.Sound.Utilities.DCFilter dcfilter;
|
||||
SpeexResampler resampler;
|
||||
DCFilter dcfilter;
|
||||
|
||||
public void FillFrameBuffer()
|
||||
{
|
||||
|
|
|
@ -4,8 +4,8 @@ using System.IO;
|
|||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
using BizHawk.Emulation.Common.Components.Z80;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.ColecoVision
|
||||
{
|
||||
|
|
|
@ -826,10 +826,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
int latchaudio = 0;
|
||||
|
||||
//Sound.Utilities.SpeexResampler resampler;
|
||||
//Sound.Utilities.DCFilter dcfilter;
|
||||
//SpeexResampler resampler;
|
||||
//DCFilter dcfilter;
|
||||
|
||||
Sound.Utilities.BlipBuffer blip;
|
||||
BlipBuffer blip;
|
||||
|
||||
void ProcessSound()
|
||||
{
|
||||
|
@ -862,7 +862,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
//dcfilter = Sound.Utilities.DCFilter.AsISyncSoundProvider(resampler, 65536);
|
||||
// lowpass filtering on an actual GB was probably pretty aggressive?
|
||||
//dcfilter = Sound.Utilities.DCFilter.AsISyncSoundProvider(resampler, 2048);
|
||||
blip = new Sound.Utilities.BlipBuffer(1024);
|
||||
blip = new BlipBuffer(1024);
|
||||
blip.SetRates(2097152, 44100);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
LagCount = 0;
|
||||
IsLagFrame = false;
|
||||
|
||||
blip_left = new Sound.Utilities.BlipBuffer(1024);
|
||||
blip_right = new Sound.Utilities.BlipBuffer(1024);
|
||||
blip_left = new BlipBuffer(1024);
|
||||
blip_right = new BlipBuffer(1024);
|
||||
blip_left.SetRates(2097152 * 2, 44100);
|
||||
blip_right.SetRates(2097152 * 2, 44100);
|
||||
|
||||
|
@ -357,9 +357,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
// i tried using the left and right buffers and then mixing them together... it was kind of a mess of code, and slow
|
||||
|
||||
Sound.Utilities.BlipBuffer blip_left;
|
||||
Sound.Utilities.BlipBuffer blip_right;
|
||||
|
||||
BlipBuffer blip_left;
|
||||
BlipBuffer blip_right;
|
||||
|
||||
short[] LeftBuffer = new short[(35112 + 2064) * 2];
|
||||
short[] RightBuffer = new short[(35112 + 2064) * 2];
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
public int BackgroundColor { get { return 0; } }
|
||||
|
||||
|
||||
public Sound.Utilities.SpeexResampler resampler;
|
||||
public SpeexResampler resampler;
|
||||
|
||||
public ISoundProvider SoundProvider { get { return null; } }
|
||||
public ISyncSoundProvider SyncSoundProvider { get { return resampler; } }
|
||||
|
|
|
@ -5,6 +5,8 @@ using System.Runtime.InteropServices;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.N64
|
||||
{
|
||||
public class mupen64plusApi : IDisposable
|
||||
|
@ -515,7 +517,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
|
||||
// Set up the resampler
|
||||
m64pSamplingRate = (uint)AudGetAudioRate();
|
||||
bizhawkCore.resampler = new Sound.Utilities.SpeexResampler(6, m64pSamplingRate, 44100, m64pSamplingRate, 44100, null, null);
|
||||
bizhawkCore.resampler = new SpeexResampler(6, m64pSamplingRate, 44100, m64pSamplingRate, 44100, null, null);
|
||||
|
||||
AttachedCore = this;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
//http://wiki.nesdev.com/w/index.php/APU_Mixer_Emulation
|
||||
//http://wiki.nesdev.com/w/index.php/APU
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
|
||||
//simplifications/approximations:
|
||||
//* "Note that no commercial games rely on this mirroring -- therefore you can take the easy way out and simply give all MMC5 games 64k PRG-RAM."
|
||||
|
@ -38,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
int wram_bank;
|
||||
byte[] EXRAM = new byte[1024];
|
||||
byte multiplicand, multiplier;
|
||||
Sound.MMC5Audio audio;
|
||||
MMC5Audio audio;
|
||||
//regeneratable state
|
||||
IntBuffer a_banks_1k = new IntBuffer(8);
|
||||
IntBuffer b_banks_1k = new IntBuffer(8);
|
||||
|
@ -119,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
PoweronState();
|
||||
|
||||
if (NES.apu != null)
|
||||
audio = new Sound.MMC5Audio(NES.apu.ExternalQueue, (e) => { irq_audio = e; SyncIRQ(); });
|
||||
audio = new MMC5Audio(NES.apu.ExternalQueue, (e) => { irq_audio = e; SyncIRQ(); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||
{
|
||||
|
@ -7,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
public sealed class Sunsoft_5 : Sunsoft_FME7
|
||||
{
|
||||
Sound.Sunsoft5BAudio audio;
|
||||
Sunsoft5BAudio audio;
|
||||
|
||||
public override bool Configure(NES.EDetectionOrigin origin)
|
||||
{
|
||||
|
@ -23,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
BaseConfigure();
|
||||
if (NES.apu != null)
|
||||
audio = new Sound.Sunsoft5BAudio(NES.apu.ExternalQueue);
|
||||
audio = new Sunsoft5BAudio(NES.apu.ExternalQueue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||
{
|
||||
|
@ -116,15 +118,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
ser.Sync("ch", ref ch);
|
||||
}
|
||||
|
||||
Sound.Utilities.SpeexResampler resampler;
|
||||
Sound.Utilities.DCFilter dc;
|
||||
Sound.MetaspuAsync metaspu;
|
||||
SpeexResampler resampler;
|
||||
DCFilter dc;
|
||||
MetaspuAsync metaspu;
|
||||
|
||||
public Namco163Audio()
|
||||
{
|
||||
resampler = new Sound.Utilities.SpeexResampler(2, 119318, 44100, 119318, 44100, null, null);
|
||||
dc = Sound.Utilities.DCFilter.DetatchedMode(4096);
|
||||
metaspu = new Sound.MetaspuAsync(resampler, Sound.ESynchMethod.ESynchMethod_V);
|
||||
resampler = new SpeexResampler(2, 119318, 44100, 119318, 44100, null, null);
|
||||
dc = DCFilter.DetatchedMode(4096);
|
||||
metaspu = new MetaspuAsync(resampler, ESynchMethod.ESynchMethod_V);
|
||||
}
|
||||
|
||||
public void ApplyCustomAudio(short[] samples)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||
{
|
||||
|
@ -12,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
bool newer_variant;
|
||||
|
||||
//Sound.VRC6 VRC6Sound = new Sound.VRC6();
|
||||
Sound.VRC6Alt VRC6Sound;
|
||||
VRC6Alt VRC6Sound;
|
||||
|
||||
//state
|
||||
int prg_bank_16k, prg_bank_8k;
|
||||
|
@ -96,7 +98,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
SetMirrorType(EMirrorType.Vertical);
|
||||
|
||||
if (NES.apu != null) // don't start up sound when in configurator
|
||||
VRC6Sound = new Sound.VRC6Alt((uint)NES.cpuclockrate, NES.apu.ExternalQueue);
|
||||
VRC6Sound = new VRC6Alt((uint)NES.cpuclockrate, NES.apu.ExternalQueue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
Func<int, int> remap;
|
||||
|
||||
//state
|
||||
BizHawk.Emulation.Sound.YM2413 fm; //= new Sound.YM2413(Sound.YM2413.ChipType.VRC7);
|
||||
YM2413 fm; //= new Sound.YM2413(Sound.YM2413.ChipType.VRC7);
|
||||
|
||||
ByteBuffer prg_banks_8k = new ByteBuffer(4);
|
||||
ByteBuffer chr_banks_1k = new ByteBuffer(8);
|
||||
|
@ -94,7 +95,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
// presumably the only reason a homebrew would use mapper085 is for the sound?
|
||||
// so initialize like lagrange point
|
||||
remap = (addr) => ((addr & 0xF000) | ((addr & 0x30) >> 4));
|
||||
fm = new Sound.YM2413(Sound.YM2413.ChipType.VRC7);
|
||||
fm = new YM2413(YM2413.ChipType.VRC7);
|
||||
break;
|
||||
case "KONAMI-VRC-7":
|
||||
AssertPrg(128, 512); AssertChr(0, 128); AssertVram(0, 8); AssertWram(0, 8);
|
||||
|
@ -109,7 +110,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
{
|
||||
//lagrange point
|
||||
remap = (addr) => ((addr & 0xF000) | ((addr & 0x30) >> 4));
|
||||
fm = new Sound.YM2413(Sound.YM2413.ChipType.VRC7);
|
||||
fm = new YM2413(YM2413.ChipType.VRC7);
|
||||
}
|
||||
else
|
||||
throw new Exception("Unknown PCB type for VRC7");
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
class MagicSoundProvider : ISoundProvider, ISyncSoundProvider, IDisposable
|
||||
{
|
||||
Sound.Utilities.BlipBuffer blip;
|
||||
BlipBuffer blip;
|
||||
NES nes;
|
||||
|
||||
const int blipbuffsize = 4096;
|
||||
|
@ -75,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
{
|
||||
this.nes = nes;
|
||||
|
||||
blip = new Sound.Utilities.BlipBuffer(blipbuffsize);
|
||||
blip = new BlipBuffer(blipbuffsize);
|
||||
blip.SetRates(infreq, 44100);
|
||||
|
||||
//var actualMetaspu = new Sound.MetaspuSoundProvider(Sound.ESynchMethod.ESynchMethod_V);
|
||||
|
|
|
@ -975,11 +975,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
#region audio stuff
|
||||
|
||||
Sound.Utilities.SpeexResampler resampler;
|
||||
SpeexResampler resampler;
|
||||
|
||||
void InitAudio()
|
||||
{
|
||||
resampler = new Sound.Utilities.SpeexResampler(6, 64081, 88200, 32041, 44100);
|
||||
resampler = new SpeexResampler(6, 64081, 88200, 32041, 44100);
|
||||
}
|
||||
|
||||
void snes_audio_sample(ushort left, ushort right)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Sound;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ using System.IO;
|
|||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
using BizHawk.Emulation.Common.Components.H6280;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@ using System.IO;
|
|||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
|
|
|
@ -7,12 +7,11 @@ using System.Runtime.InteropServices;
|
|||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
using BizHawk.Emulation.Common.Components.M68000;
|
||||
using BizHawk.Emulation.Common.Components.Z80;
|
||||
using BizHawk.Emulation.Sound;
|
||||
using Native68000;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Sega.Genesis
|
||||
{
|
||||
public sealed partial class Genesis : IEmulator
|
||||
|
|
|
@ -5,8 +5,8 @@ using System.IO;
|
|||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.Components;
|
||||
using BizHawk.Emulation.Common.Components.Z80;
|
||||
using BizHawk.Emulation.Sound;
|
||||
|
||||
/*****************************************************
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using BizHawk.Emulation.DiscSystem;
|
|||
// I decided not to let the perfect be the enemy of the good.
|
||||
// It can always be refactored. It's at least deterministic.
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public sealed class CDAudio : ISoundProvider
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.IO;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.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.
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
public class MMC5Audio
|
||||
{
|
||||
|
|
|
@ -5,11 +5,13 @@ using System.IO;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// Emulates a Texas Instruments SN76489
|
||||
// TODO the freq->note translation should be moved to a separate utility class.
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Emulates a Texas Instruments SN76489
|
||||
/// </summary>
|
||||
public sealed class SN76489 : ISoundProvider
|
||||
{
|
||||
public sealed class Channel
|
||||
|
|
|
@ -5,11 +5,13 @@ using System.Text;
|
|||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
// YM2149F variant
|
||||
// this implementation is quite incomplete
|
||||
// http://wiki.nesdev.com/w/index.php/Sunsoft_5B_audio
|
||||
/// <summary>
|
||||
/// YM2149F variant
|
||||
/// this implementation is quite incomplete
|
||||
/// http://wiki.nesdev.com/w/index.php/Sunsoft_5B_audio
|
||||
/// </summary>
|
||||
public class Sunsoft5BAudio
|
||||
{
|
||||
class Pulse
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BizHawk.Emulation.Sound.Utilities
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// wrapper around blargg's unmanaged blip_buf
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
// Generates SEMI-synchronous sound, or "buffered asynchronous" sound.
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Sound
|
|||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
if(BaseSoundProvider != null)
|
||||
if (BaseSoundProvider != null)
|
||||
BaseSoundProvider.DiscardSamples();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound.Utilities
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// implements a DC block filter on top of an ISoundProvider. rather simple.
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public sealed class Equalizer
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace BizHawk.Emulation.Sound
|
|||
}
|
||||
}
|
||||
|
||||
public Equalizer(double lowFreq=880, double highFreq=5000)
|
||||
public Equalizer(double lowFreq = 880, double highFreq = 5000)
|
||||
{
|
||||
lowGain = 1.3;
|
||||
midGain = 0.9;
|
||||
|
@ -86,7 +86,7 @@ namespace BizHawk.Emulation.Sound
|
|||
sampleDataMinus2 = sampleDataMinus1;
|
||||
sampleDataMinus1 = sample;
|
||||
|
||||
return (short) (l + m + h);
|
||||
return (short)(l + m + h);
|
||||
}
|
||||
|
||||
public void Equalize(short[] samples)
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// uses Metaspu to have an ISyncSoundProvider input to a ISoundProvider
|
||||
|
@ -36,8 +36,6 @@ namespace BizHawk.Emulation.Sound
|
|||
public int MaxVolume { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class MetaspuSoundProvider : ISoundProvider
|
||||
{
|
||||
public ISynchronizingAudioBuffer buffer;
|
||||
|
@ -46,7 +44,8 @@ namespace BizHawk.Emulation.Sound
|
|||
buffer = Metaspu.metaspu_construct(method);
|
||||
}
|
||||
|
||||
public MetaspuSoundProvider() : this(ESynchMethod.ESynchMethod_V)
|
||||
public MetaspuSoundProvider()
|
||||
: this(ESynchMethod.ESynchMethod_V)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -151,7 +150,7 @@ namespace BizHawk.Emulation.Sound
|
|||
//returns the number of samples actually supplied, which may not match the number requested
|
||||
public int output_samples(short[] buf, int samples_requested)
|
||||
{
|
||||
int ctr=0;
|
||||
int ctr = 0;
|
||||
int done = 0;
|
||||
if (!mixqueue_go)
|
||||
{
|
||||
|
@ -232,13 +231,15 @@ namespace BizHawk.Emulation.Sound
|
|||
//static int ctr=0; ctr++; if((ctr&127)==0) printf("avg size: %f curr size: %d rate: %f\n",averageSize,size,rate);
|
||||
{
|
||||
float targetRate;
|
||||
if(averageSize < targetLatency)
|
||||
if (averageSize < targetLatency)
|
||||
{
|
||||
targetRate = 1.0f - (targetLatency-averageSize)/kAverageSize;
|
||||
targetRate = 1.0f - (targetLatency - averageSize) / kAverageSize;
|
||||
}
|
||||
else if(averageSize > targetLatency) {
|
||||
targetRate = 1.0f + (averageSize-targetLatency)/kAverageSize;
|
||||
} else targetRate = 1.0f;
|
||||
else if (averageSize > targetLatency)
|
||||
{
|
||||
targetRate = 1.0f + (averageSize - targetLatency) / kAverageSize;
|
||||
}
|
||||
else targetRate = 1.0f;
|
||||
|
||||
//rate = moveValueTowards(rate,targetRate,0.001f);
|
||||
rate = targetRate;
|
||||
|
@ -253,11 +254,13 @@ namespace BizHawk.Emulation.Sound
|
|||
{
|
||||
left = right = 0;
|
||||
addStatistic();
|
||||
if(size==0) { return; }
|
||||
if (size == 0) { return; }
|
||||
cursor += rate;
|
||||
while(cursor>1.0f) {
|
||||
while (cursor > 1.0f)
|
||||
{
|
||||
cursor -= 1.0f;
|
||||
if(size>0) {
|
||||
if (size > 0)
|
||||
{
|
||||
curr[0] = buffer.Dequeue();
|
||||
curr[1] = buffer.Dequeue();
|
||||
size--;
|
||||
|
@ -282,9 +285,9 @@ namespace BizHawk.Emulation.Sound
|
|||
// returns values going between 0 and y-1 in a saw wave pattern, based on x
|
||||
static int pingpong(int x, int y)
|
||||
{
|
||||
x %= 2*y;
|
||||
if(x >= y)
|
||||
x = 2*y - x - 1;
|
||||
x %= 2 * y;
|
||||
if (x >= y)
|
||||
x = 2 * y - x - 1;
|
||||
return x;
|
||||
|
||||
// in case we want to switch to odd buffer sizes for more sharpness
|
||||
|
@ -294,11 +297,11 @@ namespace BizHawk.Emulation.Sound
|
|||
//return x;
|
||||
}
|
||||
|
||||
static ssamp crossfade (ssamp lhs, ssamp rhs, int cur, int start, int end)
|
||||
static ssamp crossfade(ssamp lhs, ssamp rhs, int cur, int start, int end)
|
||||
{
|
||||
if(cur <= start)
|
||||
if (cur <= start)
|
||||
return lhs;
|
||||
if(cur >= end)
|
||||
if (cur >= end)
|
||||
return rhs;
|
||||
|
||||
// in case we want sine wave interpolation instead of linear here
|
||||
|
@ -312,7 +315,7 @@ namespace BizHawk.Emulation.Sound
|
|||
int lrv = ((int)lhs.l * outNum + (int)rhs.l * inNum) / denom;
|
||||
int rrv = ((int)lhs.r * outNum + (int)rhs.r * inNum) / denom;
|
||||
|
||||
return new ssamp((short)lrv,(short)rrv);
|
||||
return new ssamp((short)lrv, (short)rrv);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
|
@ -328,8 +331,8 @@ namespace BizHawk.Emulation.Sound
|
|||
|
||||
static void emit_samples(short[] outbuf, ref int outcursor, ssamp[] samplebuf, int incursor, int samples)
|
||||
{
|
||||
for(int i=0;i<samples;i++)
|
||||
emit_sample(outbuf,ref outcursor, samplebuf[i+incursor]);
|
||||
for (int i = 0; i < samples; i++)
|
||||
emit_sample(outbuf, ref outcursor, samplebuf[i + incursor]);
|
||||
}
|
||||
|
||||
static short abs(short value)
|
||||
|
@ -347,16 +350,16 @@ namespace BizHawk.Emulation.Sound
|
|||
public void enqueue_samples(short[] buf, int samples_provided)
|
||||
{
|
||||
int cursor = 0;
|
||||
for(int i=0;i<samples_provided;i++)
|
||||
for (int i = 0; i < samples_provided; i++)
|
||||
{
|
||||
sampleQueue.Add(new ssamp(buf[cursor+0],buf[cursor+1]));
|
||||
sampleQueue.Add(new ssamp(buf[cursor + 0], buf[cursor + 1]));
|
||||
cursor += 2;
|
||||
}
|
||||
}
|
||||
|
||||
public void enqueue_sample(short left, short right)
|
||||
{
|
||||
sampleQueue.Add(new ssamp(left,right));
|
||||
sampleQueue.Add(new ssamp(left, right));
|
||||
}
|
||||
|
||||
public int output_samples(short[] buf, int samples_requested)
|
||||
|
@ -372,22 +375,22 @@ namespace BizHawk.Emulation.Sound
|
|||
audiosize &= ~1;
|
||||
queued &= ~1;
|
||||
|
||||
if(queued > 0x200 && audiosize > 0) // is there any work to do?
|
||||
if (queued > 0x200 && audiosize > 0) // is there any work to do?
|
||||
{
|
||||
// are we going at normal speed?
|
||||
// or more precisely, are the input and output queues/buffers of similar size?
|
||||
if(queued > 900 || audiosize > queued * 2)
|
||||
if (queued > 900 || audiosize > queued * 2)
|
||||
{
|
||||
// not normal speed. we have to resample it somehow in this case.
|
||||
if(audiosize <= queued)
|
||||
if (audiosize <= queued)
|
||||
{
|
||||
// fast forward speed
|
||||
// this is the easy case, just crossfade it and it sounds ok
|
||||
for(int i = 0; i < audiosize; i++)
|
||||
for (int i = 0; i < audiosize; i++)
|
||||
{
|
||||
int j = i + queued - audiosize;
|
||||
ssamp outsamp = crossfade(sampleQueue[i],sampleQueue[j], i,0,audiosize);
|
||||
emit_sample(buf,ref bufcursor,outsamp);
|
||||
ssamp outsamp = crossfade(sampleQueue[i], sampleQueue[j], i, 0, audiosize);
|
||||
emit_sample(buf, ref bufcursor, outsamp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -426,22 +429,22 @@ namespace BizHawk.Emulation.Sound
|
|||
const int worstdiff = 99999999;
|
||||
int beststartdiff = worstdiff;
|
||||
int bestenddiff = worstdiff;
|
||||
for(int i = 0; i < 128; i+=2)
|
||||
for (int i = 0; i < 128; i += 2)
|
||||
{
|
||||
int diff = abs(sampleQueue[i].l - sampleQueue[i+1].l) + abs(sampleQueue[i].r - sampleQueue[i+1].r);
|
||||
if(diff < beststartdiff)
|
||||
int diff = abs(sampleQueue[i].l - sampleQueue[i + 1].l) + abs(sampleQueue[i].r - sampleQueue[i + 1].r);
|
||||
if (diff < beststartdiff)
|
||||
{
|
||||
beststartdiff = diff;
|
||||
beststart = i;
|
||||
}
|
||||
}
|
||||
for(int i = queued-3; i > queued-3-128; i-=2)
|
||||
for (int i = queued - 3; i > queued - 3 - 128; i -= 2)
|
||||
{
|
||||
int diff = abs(sampleQueue[i].l - sampleQueue[i+1].l) + abs(sampleQueue[i].r - sampleQueue[i+1].r);
|
||||
if(diff < bestenddiff)
|
||||
int diff = abs(sampleQueue[i].l - sampleQueue[i + 1].l) + abs(sampleQueue[i].r - sampleQueue[i + 1].r);
|
||||
if (diff < bestenddiff)
|
||||
{
|
||||
bestenddiff = diff;
|
||||
bestend = i+1;
|
||||
bestend = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,13 +452,13 @@ namespace BizHawk.Emulation.Sound
|
|||
queued = bestend - beststart;
|
||||
|
||||
int oksize = queued;
|
||||
while(oksize + queued*2 + beststart + extraAtEnd <= samples_requested)
|
||||
oksize += queued*2;
|
||||
while (oksize + queued * 2 + beststart + extraAtEnd <= samples_requested)
|
||||
oksize += queued * 2;
|
||||
audiosize = oksize;
|
||||
|
||||
for(int x = 0; x < beststart; x++)
|
||||
for (int x = 0; x < beststart; x++)
|
||||
{
|
||||
emit_sample(buf,ref bufcursor,sampleQueue[x]);
|
||||
emit_sample(buf, ref bufcursor, sampleQueue[x]);
|
||||
}
|
||||
//sampleQueue.erase(sampleQueue.begin(), sampleQueue.begin() + beststart);
|
||||
sampleQueue.RemoveRange(0, beststart);
|
||||
|
@ -473,19 +476,19 @@ namespace BizHawk.Emulation.Sound
|
|||
// so here's a stupid search for the value for now:
|
||||
|
||||
int prevA = 999999;
|
||||
int midpointXOffset = queued/2;
|
||||
while(true)
|
||||
int midpointXOffset = queued / 2;
|
||||
while (true)
|
||||
{
|
||||
int a = abs(pingpong(midpointX - midpointXOffset, queued) - midpointY) - midpointXOffset;
|
||||
if(((a > 0) != (prevA > 0) || (a < 0) != (prevA < 0)) && prevA != 999999)
|
||||
if (((a > 0) != (prevA > 0) || (a < 0) != (prevA < 0)) && prevA != 999999)
|
||||
{
|
||||
if(((a + prevA)&1)!=0) // there's some sort of off-by-one problem with this search since we're moving diagonally...
|
||||
if (((a + prevA) & 1) != 0) // there's some sort of off-by-one problem with this search since we're moving diagonally...
|
||||
midpointXOffset++; // but this fixes it most of the time...
|
||||
break; // found it
|
||||
}
|
||||
prevA = a;
|
||||
midpointXOffset--;
|
||||
if(midpointXOffset < 0)
|
||||
if (midpointXOffset < 0)
|
||||
{
|
||||
midpointXOffset = 0;
|
||||
break; // failed to find it. the two sides probably meet exactly in the center.
|
||||
|
@ -495,35 +498,35 @@ namespace BizHawk.Emulation.Sound
|
|||
int leftMidpointX = midpointX - midpointXOffset;
|
||||
int rightMidpointX = midpointX + midpointXOffset;
|
||||
int leftMidpointY = pingpong(leftMidpointX, queued);
|
||||
int rightMidpointY = (queued-1) - pingpong((int)audiosize-1 - rightMidpointX + queued*2, queued);
|
||||
int rightMidpointY = (queued - 1) - pingpong((int)audiosize - 1 - rightMidpointX + queued * 2, queued);
|
||||
|
||||
// output the left almost-half of the sound (section "A")
|
||||
for(int x = 0; x < leftMidpointX; x++)
|
||||
for (int x = 0; x < leftMidpointX; x++)
|
||||
{
|
||||
int i = pingpong(x, queued);
|
||||
emit_sample(buf,ref bufcursor,sampleQueue[i]);
|
||||
emit_sample(buf, ref bufcursor, sampleQueue[i]);
|
||||
}
|
||||
|
||||
// output the middle stretch (section "B")
|
||||
int y = leftMidpointY;
|
||||
int dyMidLeft = (leftMidpointY < midpointY) ? 1 : -1;
|
||||
int dyMidRight = (rightMidpointY > midpointY) ? 1 : -1;
|
||||
for(int x = leftMidpointX; x < midpointX; x++, y+=dyMidLeft)
|
||||
emit_sample(buf,ref bufcursor,sampleQueue[y]);
|
||||
for(int x = midpointX; x < rightMidpointX; x++, y+=dyMidRight)
|
||||
for (int x = leftMidpointX; x < midpointX; x++, y += dyMidLeft)
|
||||
emit_sample(buf, ref bufcursor, sampleQueue[y]);
|
||||
for (int x = midpointX; x < rightMidpointX; x++, y += dyMidRight)
|
||||
emit_sample(buf, ref bufcursor, sampleQueue[y]);
|
||||
|
||||
// output the end of the queued sound (section "C")
|
||||
for(int x = rightMidpointX; x < audiosize; x++)
|
||||
for (int x = rightMidpointX; x < audiosize; x++)
|
||||
{
|
||||
int i = (queued-1) - pingpong((int)audiosize-1 - x + queued*2, queued);
|
||||
emit_sample(buf,ref bufcursor,sampleQueue[i]);
|
||||
int i = (queued - 1) - pingpong((int)audiosize - 1 - x + queued * 2, queued);
|
||||
emit_sample(buf, ref bufcursor, sampleQueue[i]);
|
||||
}
|
||||
|
||||
for(int x = 0; x < extraAtEnd; x++)
|
||||
for (int x = 0; x < extraAtEnd; x++)
|
||||
{
|
||||
int i = queued + x;
|
||||
emit_sample(buf,ref bufcursor,sampleQueue[i]);
|
||||
emit_sample(buf, ref bufcursor, sampleQueue[i]);
|
||||
}
|
||||
queued += extraAtEnd;
|
||||
audiosize += beststart + extraAtEnd;
|
||||
|
@ -545,9 +548,9 @@ namespace BizHawk.Emulation.Sound
|
|||
// but that's ok! because all of these branches sound similar enough that we can get away with it.
|
||||
// so the two cases actually complement each other.
|
||||
|
||||
if(audiosize >= queued)
|
||||
if (audiosize >= queued)
|
||||
{
|
||||
emit_samples(buf,ref bufcursor, sampleQueue.ToArray(),0,queued);
|
||||
emit_samples(buf, ref bufcursor, sampleQueue.ToArray(), 0, queued);
|
||||
//sampleQueue.erase(sampleQueue.begin(), sampleQueue.begin() + queued);
|
||||
sampleQueue.RemoveRange(0, queued);
|
||||
//zero 08-nov-2010: did i do this right?
|
||||
|
@ -555,7 +558,7 @@ namespace BizHawk.Emulation.Sound
|
|||
}
|
||||
else
|
||||
{
|
||||
emit_samples(buf,ref bufcursor, sampleQueue.ToArray(),0,audiosize);
|
||||
emit_samples(buf, ref bufcursor, sampleQueue.ToArray(), 0, audiosize);
|
||||
//sampleQueue.erase(sampleQueue.begin(), sampleQueue.begin()+audiosize);
|
||||
sampleQueue.RemoveRange(0, audiosize);
|
||||
//zero 08-nov-2010: did i do this right?
|
||||
|
@ -573,7 +576,7 @@ namespace BizHawk.Emulation.Sound
|
|||
} //output_samples
|
||||
|
||||
|
||||
}; //NitsujaSynchronizer
|
||||
}; //NitsujaSynchronizer
|
||||
|
||||
class VecnaSynchronizer : ISynchronizingAudioBuffer
|
||||
{
|
||||
|
@ -617,8 +620,8 @@ namespace BizHawk.Emulation.Sound
|
|||
resampleBuffer = new Sample[2730]; // 2048 * 1.25
|
||||
|
||||
// Give us a little buffer wiggle-room
|
||||
for (int i=0; i<367; i++)
|
||||
buffer.Enqueue(new Sample(0,0));
|
||||
for (int i = 0; i < 367; i++)
|
||||
buffer.Enqueue(new Sample(0, 0));
|
||||
}
|
||||
|
||||
public void enqueue_samples(short[] buf, int samples_provided)
|
||||
|
@ -662,13 +665,15 @@ namespace BizHawk.Emulation.Sound
|
|||
resampleBuffer[i] = buffer.Dequeue();
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i<samples_requested; i++)
|
||||
for (int i = 0; i < samples_requested; i++)
|
||||
{
|
||||
Sample sample = resampleBuffer[i*samples_available/samples_requested];
|
||||
Sample sample = resampleBuffer[i * samples_available / samples_requested];
|
||||
buf[index++] += sample.left;
|
||||
buf[index++] += sample.right;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// we're outside of a "reasonable" underflow. Give up and output silence.
|
||||
// Do nothing. The whole frame will be excess buffer.
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
// This is a straightforward class to mix/chain multiple ISoundProvider sources.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound.Utilities
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// junk wrapper around LibSpeexDSP. quite inefficient. will be replaced
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public static class Waves
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
public class VRC6Alt
|
||||
{
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
using System;
|
||||
|
||||
// Credits:
|
||||
// Credits:
|
||||
// Original emulator written by Mitsutaka Okazaki 2001.
|
||||
// Original conversion to C# by Ben Ryves.
|
||||
|
||||
// TODO The savestate support here is very simplistic and incomplete. However, this does not result in desyncs as the YM2413 is write-only.
|
||||
// TODO This should eventually be replaced, due to 1) uncertain licensing terms 2) This is not a native C# implementation, but a naive port.
|
||||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
public sealed class YM2413 : ISoundProvider
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.IO;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Sound
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
// ======================================================================
|
||||
// Yamaha YM2612 Emulation Core
|
||||
|
|
Loading…
Reference in New Issue