/// <summary> /// Resets this device /// </summary> public void Reset() { _frameBegins = HostVm.Cpu.Tacts; LastRegisterIndex = 0; PsgState = new PsgState(HostVm); for (var i = 0; i < 0x0F; i++) { PsgState[i] = 0; } FrameCount = 0; Overflow = 0; SetRegisterValue(0); _soundProvider?.Reset(); InitializeSampling(); }
/// <summary> /// Create the PSG sample for the specified tact /// </summary> /// <param name="tact">CPU tact to create the sample for</param> /// <returns></returns> private float CreateSampleFor(long tact) { var noise = PsgState.GetNoiseSample(tact); var channelA = PsgState.GetChannelASample(tact); if (PsgState.NoiseAEnabled && noise > channelA) { channelA = noise; } var channelB = PsgState.GetChannelBSample(tact); if (PsgState.NoiseBEnabled && noise > channelB) { channelB = noise; } var channelC = PsgState.GetChannelCSample(tact); if (PsgState.NoiseCEnabled && noise > channelC) { channelC = noise; } // --- Mix channels var sample = (channelA * PsgState.GetAmplitudeA(tact) + channelB * PsgState.GetAmplitudeB(tact) + channelC * PsgState.GetAmplitudeC(tact)) / 3; // --- Remove DC _filtSum += -_delay[_filterIndex] + sample; _delay[_filterIndex] = sample; sample = sample - _filtSum / DC_FITER_SIZE; _filterIndex++; if (_filterIndex >= DC_FITER_SIZE) { _filterIndex = 0; } return((float)_lpf.DoSample(sample)); }