diff --git a/src/AY8910.cpp b/src/AY8910.cpp index 9413446..04d039e 100644 --- a/src/AY8910.cpp +++ b/src/AY8910.cpp @@ -38,6 +38,7 @@ void AY8910::Init(int clockRate) void AY8910::Reset(int clockRate) { m_iClockRate = clockRate; + m_iCyclesPerSample = m_iClockRate / GC_AUDIO_SAMPLE_RATE; for (int i = 0; i < 16; i++) { @@ -300,10 +301,9 @@ void AY8910::Sync() } m_iSampleCounter++; - int cyclesPerSample = m_iClockRate / GC_AUDIO_SAMPLE_RATE; - if (m_iSampleCounter >= cyclesPerSample) + if (m_iSampleCounter >= m_iCyclesPerSample) { - m_iSampleCounter -= cyclesPerSample; + m_iSampleCounter -= m_iCyclesPerSample; m_CurrentSample = 0; for (int i = 0; i < 3; i++) diff --git a/src/AY8910.h b/src/AY8910.h index e3d6924..d817508 100644 --- a/src/AY8910.h +++ b/src/AY8910.h @@ -61,6 +61,7 @@ class AY8910 bool m_Sign[3]; int m_iCycleCounter; int m_iSampleCounter; + int m_iCyclesPerSample; s16* m_pBuffer; int m_iBufferIndex; int m_ElapsedCycles;