C64: connect audio to speexresampler. consider this commit a demonstration on "how it could be done"...
This commit is contained in:
parent
1d3ff8524a
commit
1b83110a37
|
@ -57,9 +57,9 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
|
|
||||||
// audio/video
|
// audio/video
|
||||||
public void EndAsyncSound() { } //TODO
|
public void EndAsyncSound() { } //TODO
|
||||||
public ISoundProvider SoundProvider { get { return board.sid; } }
|
public ISoundProvider SoundProvider { get { return null; } }
|
||||||
public bool StartAsyncSound() { return true; } //TODO
|
public bool StartAsyncSound() { return false; } //TODO
|
||||||
public ISyncSoundProvider SyncSoundProvider { get { return board.sid; } }
|
public ISyncSoundProvider SyncSoundProvider { get { return board.sid.resampler; } }
|
||||||
public IVideoProvider VideoProvider { get { return board.vic; } }
|
public IVideoProvider VideoProvider { get { return board.vic; } }
|
||||||
|
|
||||||
// controller
|
// controller
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Text;
|
||||||
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
// sid
|
// sid
|
||||||
public class MOS6581 : Sid, ISoundProvider, ISyncSoundProvider
|
public class MOS6581 : Sid
|
||||||
{
|
{
|
||||||
static uint[][] waveTable = new uint[][]
|
static uint[][] waveTable = new uint[][]
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,16 +5,21 @@ using System.Text;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
public abstract partial class Sid : ISoundProvider
|
/*
|
||||||
|
* this wasn't sounding as good as a vecna metaspu
|
||||||
|
*/
|
||||||
|
public abstract partial class Sid //: ISoundProvider
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
private short[] buffer;
|
private short[] buffer;
|
||||||
private uint bufferCounter;
|
private uint bufferCounter;
|
||||||
private uint bufferFrequency;
|
private uint bufferFrequency;
|
||||||
private uint bufferIndex;
|
private uint bufferIndex;
|
||||||
private uint bufferLength;
|
private uint bufferLength;
|
||||||
private uint bufferReadOffset;
|
private uint bufferReadOffset;
|
||||||
|
*/
|
||||||
private uint cyclesPerSec;
|
private uint cyclesPerSec;
|
||||||
|
/*
|
||||||
public void GetSamples(short[] samples)
|
public void GetSamples(short[] samples)
|
||||||
{
|
{
|
||||||
bool overrun = false;
|
bool overrun = false;
|
||||||
|
@ -57,5 +62,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
// no change in volume
|
// no change in volume
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@ using System.Text;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
public abstract partial class Sid : ISyncSoundProvider
|
public abstract partial class Sid : IDisposable
|
||||||
{
|
{
|
||||||
|
public Sound.Utilities.SpeexResampler resampler;
|
||||||
|
/*
|
||||||
public void GetSamples(out short[] samples, out int nsamp)
|
public void GetSamples(out short[] samples, out int nsamp)
|
||||||
{
|
{
|
||||||
if (bufferIndex > bufferReadOffset)
|
if (bufferIndex > bufferReadOffset)
|
||||||
|
@ -31,5 +33,14 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
bufferReadOffset = 0;
|
bufferReadOffset = 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (resampler != null)
|
||||||
|
{
|
||||||
|
resampler.Dispose();
|
||||||
|
resampler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,11 +645,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
switch (newRegion)
|
switch (newRegion)
|
||||||
{
|
{
|
||||||
case Region.NTSC: cyclesPerSec = 14318181 / 14; bufferLength = (newSampleRate / 60) * 4; break;
|
case Region.NTSC: cyclesPerSec = 14318181 / 14; /*bufferLength = (newSampleRate / 60) * 4;*/ break;
|
||||||
case Region.PAL: cyclesPerSec = 17734472 / 18; bufferLength = (newSampleRate / 50) * 4; break;
|
case Region.PAL: cyclesPerSec = 17734472 / 18; /*bufferLength = (newSampleRate / 50) * 4;*/ break;
|
||||||
}
|
}
|
||||||
bufferFrequency = cyclesPerSec / newSampleRate;
|
//bufferFrequency = cyclesPerSec / newSampleRate;
|
||||||
buffer = new short[bufferLength];
|
//buffer = new short[bufferLength];
|
||||||
|
|
||||||
waveformTable = newWaveformTable;
|
waveformTable = newWaveformTable;
|
||||||
|
|
||||||
|
@ -666,6 +666,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
filterEnable = new bool[3];
|
filterEnable = new bool[3];
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
filterEnable[i] = false;
|
filterEnable[i] = false;
|
||||||
|
|
||||||
|
resampler = new Sound.Utilities.SpeexResampler(0, cyclesPerSec, 44100, cyclesPerSec, 44100, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
@ -722,11 +724,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
envelopeOutput[2] = envelopes[2].Level;
|
envelopeOutput[2] = envelopes[2].Level;
|
||||||
|
|
||||||
// process output
|
// process output
|
||||||
if (bufferCounter == 0)
|
//if (bufferCounter == 0)
|
||||||
{
|
//{
|
||||||
uint mixer;
|
uint mixer;
|
||||||
short sample;
|
short sample;
|
||||||
bufferCounter = bufferFrequency;
|
//bufferCounter = bufferFrequency;
|
||||||
|
|
||||||
// mix each channel (20 bits)
|
// mix each channel (20 bits)
|
||||||
mixer = ((voiceOutput[0] * envelopeOutput[0]) >> 7);
|
mixer = ((voiceOutput[0] * envelopeOutput[0]) >> 7);
|
||||||
|
@ -735,12 +737,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
mixer = (mixer * volume) >> 4;
|
mixer = (mixer * volume) >> 4;
|
||||||
|
|
||||||
sample = (short)mixer;
|
sample = (short)mixer;
|
||||||
buffer[bufferIndex++] = sample;
|
//buffer[bufferIndex++] = sample;
|
||||||
buffer[bufferIndex++] = sample;
|
//buffer[bufferIndex++] = sample;
|
||||||
if (bufferIndex == bufferLength)
|
resampler.EnqueueSample(sample, sample);
|
||||||
bufferIndex = 0;
|
//if (bufferIndex == bufferLength)
|
||||||
}
|
// bufferIndex = 0;
|
||||||
bufferCounter--;
|
//}
|
||||||
|
//bufferCounter--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue