Clean up math functions
- Remove checking for standard functions from the build system - Prefix all invocations with std:: - Replace suffixed functions with unprefixed versions - Include <cmath> in all files that use it and remove the global include e.g. floorf(x) -> std::floor(x)
This commit is contained in:
+21
-19
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* AdjustSync defines two methods for fixing the sync.
|
||||
* AdjustSync defines two methods for fixing the sync.
|
||||
*
|
||||
* The first method adjusts either the song or the machine by the
|
||||
* The first method adjusts either the song or the machine by the
|
||||
* average offset of the user's steps. In other words, if the user
|
||||
* averages to step early by 10 ms, either the song or the global
|
||||
* offset is adjusted by 10 ms to compensate for that. These
|
||||
* offset is adjusted by 10 ms to compensate for that. These
|
||||
* adjustments only require a small set of data, so this method
|
||||
* updates the offset while the song is playing.
|
||||
*
|
||||
* The second method adjusts both the offset and the tempo of an
|
||||
* individual song. It records all of the steps during a play of
|
||||
* the song and uses linear least squares regression to minimize the
|
||||
* error of those steps. It makes one adjustment for the tempo of
|
||||
* error of those steps. It makes one adjustment for the tempo of
|
||||
* the entire song, rather than adding many different tempo segments
|
||||
* to match the steps. If there are already several tempo segments
|
||||
* in the stepfile, this method makes a proportional change to each
|
||||
@@ -19,8 +19,8 @@
|
||||
* also change 200 bpm to 202 bpm. This method also adjusts the stops.
|
||||
* It assumes that a given stop is measured in terms of beats and makes
|
||||
* the appropriate change.
|
||||
*
|
||||
* If we use this method on a small set of data late in the song, it
|
||||
*
|
||||
* If we use this method on a small set of data late in the song, it
|
||||
* can have very chaotic effects on the early settings. For example,
|
||||
* it may change the offset by several hundred milliseconds and make a
|
||||
* large change to the BPM to compensate if that would minimize the
|
||||
@@ -29,7 +29,7 @@
|
||||
* perform the least squares regression once on all of the data
|
||||
* collected, rather than adjusting the sync every time we get another
|
||||
* 50 or so data points. In fact, if we are playing in edit mode and
|
||||
* the user loops through the song more than once, we use all of the
|
||||
* the user loops through the song more than once, we use all of the
|
||||
* steps made.
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
||||
std::vector<TimingData> AdjustSync::s_vpTimingDataOriginal;
|
||||
float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f;
|
||||
@@ -161,7 +163,7 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime )
|
||||
s_fAutosyncOffset[s_iAutosyncOffsetSample] = fNoteOffBySeconds;
|
||||
++s_iAutosyncOffsetSample;
|
||||
|
||||
if( s_iAutosyncOffsetSample < OFFSET_SAMPLE_COUNT )
|
||||
if( s_iAutosyncOffsetSample < OFFSET_SAMPLE_COUNT )
|
||||
break; // need more
|
||||
|
||||
AutosyncOffset();
|
||||
@@ -298,7 +300,7 @@ static LocalizedString GLOBAL_OFFSET_FROM ( "AdjustSync", "Global Offset from %+
|
||||
// We need to limit the length of lines so each one fits on one line of the SM console.
|
||||
// The tempo and stop change message can get very long in a complicated song, and at
|
||||
// a low resolution, the keep/revert menu would be pushed off the bottom of the screen
|
||||
// if we didn't limit the length of the message. Keeping the lines short lets us fit
|
||||
// if we didn't limit the length of the message. Keeping the lines short lets us fit
|
||||
// more information on the screen.
|
||||
static LocalizedString SONG_OFFSET_FROM ( "AdjustSync", "Song offset from %+.3f to %+.3f (notes %s)" );
|
||||
static LocalizedString TEMPO_SEGMENT_FROM ( "AdjustSync", "%s BPM from %.3f BPM to %.3f BPM." );
|
||||
@@ -314,9 +316,9 @@ void AdjustSync::GetSyncChangeTextGlobal( std::vector<RString> &vsAddTo )
|
||||
float fNew = Quantize( PREFSMAN->m_fGlobalOffsetSeconds, 0.001f ) ;
|
||||
float fDelta = fNew - fOld;
|
||||
|
||||
if( fabsf(fDelta) > 0.0001f )
|
||||
if( std::abs(fDelta) > 0.0001f )
|
||||
{
|
||||
vsAddTo.push_back( ssprintf(
|
||||
vsAddTo.push_back( ssprintf(
|
||||
GLOBAL_OFFSET_FROM.GetValue(),
|
||||
fOld, fNew,
|
||||
(fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ));
|
||||
@@ -344,11 +346,11 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
|
||||
float fNew = Quantize( testing.m_fBeat0OffsetInSeconds, 0.001f );
|
||||
float fDelta = fNew - fOld;
|
||||
|
||||
if( fabsf(fDelta) > 0.0001f )
|
||||
if( std::abs(fDelta) > 0.0001f )
|
||||
{
|
||||
vsAddTo.push_back( ssprintf(
|
||||
vsAddTo.push_back( ssprintf(
|
||||
SONG_OFFSET_FROM.GetValue(),
|
||||
fOld,
|
||||
fOld,
|
||||
fNew,
|
||||
(fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ) );
|
||||
}
|
||||
@@ -362,7 +364,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
|
||||
float fNew = Quantize( ToBPM(bpmTest[i])->GetBPM(), 0.001f );
|
||||
float fOld = Quantize( ToBPM(bpmOrig[i])->GetBPM(), 0.001f );
|
||||
|
||||
if( fabsf(fNew - fOld) < 1e-4 )
|
||||
if( std::abs(fNew - fOld) < 1e-4 )
|
||||
continue;
|
||||
|
||||
if ( i >= 4 )
|
||||
@@ -387,7 +389,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
|
||||
float fNew = Quantize( ToStop(stopTest[i])->GetPause(), 0.001f );
|
||||
float fDelta = fNew - fOld;
|
||||
|
||||
if( fabsf(fDelta) < 1e-4 )
|
||||
if( std::abs(fDelta) < 1e-4 )
|
||||
continue;
|
||||
|
||||
if ( i >= 4 )
|
||||
@@ -413,7 +415,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
|
||||
float fNew = Quantize( ToDelay(delyTest[i])->GetPause(), 0.001f );
|
||||
float fDelta = fNew - fOld;
|
||||
|
||||
if( fabsf(fDelta) < 1e-4 )
|
||||
if( std::abs(fDelta) < 1e-4 )
|
||||
continue;
|
||||
|
||||
if ( i >= 4 )
|
||||
@@ -442,7 +444,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
|
||||
/*
|
||||
* (c) 2003-2006 Chris Danford, John Bauer
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -452,7 +454,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
Reference in New Issue
Block a user