Resolve the SM5 sync drift issue
Summary of changes 1) Fix issues in RageTimer and RageSoundPosMap 2) Calculate seconds from microseconds more accurately 3) Replace lrint(x) with static_cast<int>(x+0.5) for better performance 4) Replace C style casting with C++ style casting 5) Make important values 64-bit wide 6) Update RageUtil.cpp (timer conversion RStrings had some math which needed to be fixed after fixing RageTimer's math) 7) Ensure floating point math is done as floating point 8) Improve code commentary all around 9) Improve clarity and efficiency of RageSoundPosMap "return closest position" error logging
This commit is contained in:
+19
-19
@@ -226,53 +226,53 @@ float HHMMSSToSeconds( const RString &sHHMMSS )
|
||||
return fSeconds;
|
||||
}
|
||||
|
||||
RString SecondsToHHMMSS( float fSecs )
|
||||
RString SecondsToHHMMSS(float fSecs)
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
|
||||
RString sReturn = ssprintf( "%02d:%02d:%02d", iMinsDisplay/60, iMinsDisplay%60, iSecsDisplay );
|
||||
const int iMinsDisplay = static_cast<int>(fSecs / 60);
|
||||
const int iSecsDisplay = static_cast<int>(fmod(fSecs, 60));
|
||||
RString sReturn = ssprintf("%02d:%02d:%02d", iMinsDisplay / 60, iMinsDisplay % 60, iSecsDisplay);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
RString SecondsToMMSSMsMs( float fSecs )
|
||||
RString SecondsToMMSSMsMs(float fSecs)
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
|
||||
const int iLeftoverDisplay = (int) ( (fSecs - iMinsDisplay*60 - iSecsDisplay) * 100 );
|
||||
RString sReturn = ssprintf( "%02d:%02d.%02d", iMinsDisplay, iSecsDisplay, std::min(99,iLeftoverDisplay) );
|
||||
const int iMinsDisplay = static_cast<int>(fSecs / 60);
|
||||
const int iSecsDisplay = static_cast<int>(fmod(fSecs, 60));
|
||||
const int iLeftoverDisplay = static_cast<int>((fSecs - iMinsDisplay * 60 - iSecsDisplay) * 100);
|
||||
RString sReturn = ssprintf("%02d:%02d.%02d", iMinsDisplay, iSecsDisplay, std::min(99, iLeftoverDisplay));
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
RString SecondsToMSSMsMs( float fSecs )
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
|
||||
const int iLeftoverDisplay = (int) ( (fSecs - iMinsDisplay*60 - iSecsDisplay) * 100 );
|
||||
const int iMinsDisplay = static_cast<int>(fSecs/60);
|
||||
const int iSecsDisplay = static_cast<int>(fmod(fSecs, 60));
|
||||
const int iLeftoverDisplay = static_cast<int>((fSecs - iMinsDisplay*60 - iSecsDisplay) * 100 );
|
||||
RString sReturn = ssprintf( "%01d:%02d.%02d", iMinsDisplay, iSecsDisplay, std::min(99,iLeftoverDisplay) );
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
RString SecondsToMMSSMsMsMs( float fSecs )
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
|
||||
const int iLeftoverDisplay = (int) ( (fSecs - iMinsDisplay*60 - iSecsDisplay) * 1000 );
|
||||
const int iMinsDisplay = static_cast<int>(fSecs/60);
|
||||
const int iSecsDisplay = static_cast<int>(fmod(fSecs, 60));
|
||||
const int iLeftoverDisplay = static_cast<int>((fSecs - iMinsDisplay*60 - iSecsDisplay) * 1000 );
|
||||
RString sReturn = ssprintf( "%02d:%02d.%03d", iMinsDisplay, iSecsDisplay, std::min(999,iLeftoverDisplay) );
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
RString SecondsToMSS( float fSecs )
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
|
||||
const int iMinsDisplay = static_cast<int>(fSecs/60);
|
||||
const int iSecsDisplay = static_cast<int>(fmod(fSecs, 60));
|
||||
RString sReturn = ssprintf( "%01d:%02d", iMinsDisplay, iSecsDisplay);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
RString SecondsToMMSS( float fSecs )
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
|
||||
const int iMinsDisplay = static_cast<int>(fSecs/60);
|
||||
const int iSecsDisplay = static_cast<int>(fmod(fSecs, 60));
|
||||
RString sReturn = ssprintf( "%02d:%02d", iMinsDisplay, iSecsDisplay);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user