Skip to content

Commit

Permalink
RageSoundReader_SpeedChange_Good: Check invariants correctly
Browse files Browse the repository at this point in the history
You can see the logic flaw immediately by looking at the m_bDraining test immediately above the assert
  • Loading branch information
graemephi committed Dec 28, 2024
1 parent 44a8430 commit f4e3268
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/RageUtil/Sound/RageSoundReader_SpeedChange_Good.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ ApplyPhases(SpeedChangeFFT *Junk, uint32_t iSeed, float fMix, float *pBuffer, in
float fShelfEnd = (12000.0 / (iSampleRate / 2)) * iNyquistBin;
ASSERT(fSibilanceEnd < iNyquistBin);

float fSibilanceBinInto01 = 1.0f / (fSibilanceEnd - fSibilanceStart);
float fSibilanceBinInto01 = 1.0f / (fSibilanceEnd - fSibilanceStart);
float fShelfBinInto01 = 1.0f / (fShelfEnd - fSibilanceStart);

float fScale = sqrtf(0.5f) / iNyquistBin;
Expand Down Expand Up @@ -383,7 +383,7 @@ RageSoundReader_SpeedChange_Good::Read(float* pBuf, int iFrames)
}

// Get dDestStep as an integer for this step. eg if dDestStep was 1000.2, then we'd step an extra
// sample once every 5 frames. Easier than fractional delay !!
// sample once every 5 steps. Easier than fractional delay !!
double dCurrentPos = m_dPos;
double dDestStep = m_Window.dDestStep * dAdjustScale;
m_dPos += dDestStep;
Expand Down Expand Up @@ -471,10 +471,10 @@ RageSoundReader_SpeedChange_Good::Read(float* pBuf, int iFrames)
m_bDraining = (m_ReadAhead.Frames() > 0);
}

ASSERT_M(m_ReadAhead.iReadPosition < m_ReadAhead.iWritePosition,
ASSERT_M((m_ReadAhead.Frames() == 0) || m_ReadAhead.iReadPosition < m_ReadAhead.iWritePosition,
"RA readpos < writepos. to ignore this, set preference "
"StepmaniaUnpitchRates=1");
ASSERT_M(m_Mixed.iReadPosition < m_Mixed.iWritePosition,
ASSERT_M((m_Mixed.Frames() == 0) || m_Mixed.iReadPosition < m_Mixed.iWritePosition,
"M readpos < writepos. to ignore this, set preference "
"StepmaniaUnpitchRates=1");

Expand Down

0 comments on commit f4e3268

Please sign in to comment.