Reduced the AY center channel volume for better balance

This commit is contained in:
Asnivor 2018-03-13 18:52:00 +00:00
parent f612ae043b
commit 9778cc2644
5 changed files with 47 additions and 17 deletions

View File

@ -2,8 +2,6 @@
using BizHawk.Common;
using BizHawk.Emulation.Common;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
@ -69,9 +67,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public void UpdateSound(int currentFrameCycle)
{
//if (currentFrameCycle >= _tStatesPerFrame)
//currentFrameCycle = _tStatesPerFrame;
for (int i = 0; i < (currentFrameCycle / AY_SAMPLE_RATE) - _AYCount; i++)
{
Update();
@ -113,11 +108,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// the stereo _samples buffer should already have been processed as a part of
// ISoundProvider at the end of the last frame
//_samples = new short[_samplesPerFrame * 2];
//_nsamp = _samplesPerFrame;
_sampleCounter = 0;
//Init(44100, _tStatesPerFrame);
}
public void EndFrame()
@ -447,15 +438,25 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
private void EndSampleAY()
{
averagedChannelSamples[0] = (short)((averagedChannelSamples[ChannelLeft] + averagedChannelSamples[ChannelCenter]) / soundSampleCounter);
averagedChannelSamples[1] = (short)((averagedChannelSamples[ChannelRight] + averagedChannelSamples[ChannelCenter]) / soundSampleCounter);
//averagedChannelSamples[0] = (short)((averagedChannelSamples[ChannelLeft] +
// averagedChannelSamples[ChannelCenter] +
// averagedChannelSamples[ChannelRight])
// / soundSampleCounter);
// averagedChannelSamples[1] = (short)((averagedChannelSamples[ChannelLeft] +
// averagedChannelSamples[ChannelCenter] +
// averagedChannelSamples[ChannelRight])
// / soundSampleCounter);
averagedChannelSamples[0] = (short)((averagedChannelSamples[ChannelLeft] + averagedChannelSamples[ChannelCenter] / 1.5) / soundSampleCounter);
averagedChannelSamples[1] = (short)((averagedChannelSamples[ChannelRight] + averagedChannelSamples[ChannelCenter] / 1.5) / soundSampleCounter);
soundSampleCounter = 0;
}
private void SampleAY()
{
int ah;
int ah;
ah = regs[AY_ENABLE];

View File

@ -236,7 +236,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
if (_tapeMode)
samples[sampleIndex++] = pulse.State ? (short)(short.MaxValue / 6) : (short)0;
else
samples[sampleIndex++] = pulse.State ? (short)(short.MaxValue / 2) : (short)0;
samples[sampleIndex++] = pulse.State ? (short)(short.MaxValue / 3) : (short)0;
}
currentEnd += pulse.Length;

View File

@ -146,7 +146,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
PollInput();
while (CurrentFrameCycle < ULADevice.FrameLength) // UlaFrameCycleCount)
while (CurrentFrameCycle < ULADevice.FrameLength)
{
// check for interrupt
ULADevice.CheckForInterrupt(CurrentFrameCycle);
@ -157,8 +157,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// update AY
if (_renderSound)
{
if (AYDevice != null)
AYDevice.UpdateSound(CurrentFrameCycle);
if (AYDevice != null && CPU.RegPC != 1523)
{
AYDevice.UpdateSound(CurrentFrameCycle);
}
}
}

View File

@ -45,6 +45,22 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
EqualizeVolumes();
}
public SoundProviderMixer(short maxVolume, params ISoundProvider[] soundProviders)
{
SoundProviders = new List<Provider>();
foreach (var s in soundProviders)
{
SoundProviders.Add(new Provider
{
SoundProvider = s,
MaxVolume = maxVolume,
});
}
EqualizeVolumes();
}
public void AddSource(ISoundProvider source)
{
SoundProviders.Add(new Provider
@ -56,6 +72,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
EqualizeVolumes();
}
public void AddSource(ISoundProvider source, short maxVolume)
{
SoundProviders.Add(new Provider
{
SoundProvider = source,
MaxVolume = maxVolume
});
EqualizeVolumes();
}
public void DisableSource(ISoundProvider source)
{
var sp = SoundProviders.Where(a => a.SoundProvider == source);

View File

@ -99,7 +99,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ser.Register<IDisassemblable>(_cpu);
ser.Register<IVideoProvider>(_machine.ULADevice);
SoundMixer = new SoundProviderMixer((ISoundProvider)_machine.BuzzerDevice);
SoundMixer = new SoundProviderMixer((int)(32767 / 10), (ISoundProvider)_machine.BuzzerDevice);
if (_machine.AYDevice != null)
SoundMixer.AddSource(_machine.AYDevice);