aboutsummaryrefslogtreecommitdiffstats
path: root/src/base/UBeatTimer.pas
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/UBeatTimer.pas')
-rw-r--r--src/base/UBeatTimer.pas54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/base/UBeatTimer.pas b/src/base/UBeatTimer.pas
index bc03de76..7f68deb6 100644
--- a/src/base/UBeatTimer.pas
+++ b/src/base/UBeatTimer.pas
@@ -170,38 +170,38 @@ var
MasterClock: real;
TimeDiff: real;
const
- AVG_HISTORY_FACTOR = 0.7;
- PAUSE_THRESHOLD = 0.010; // 10ms
- FORWARD_THRESHOLD = 0.010; // 10ms
+ AVG_HISTORY_FACTOR = 0.7;
+ PAUSE_THRESHOLD = 0.010; // 10ms
+ FORWARD_THRESHOLD = 0.010; // 10ms
begin
- MasterClock := fSyncSource.GetClock();
- Result := LyricTime;
-
- // do not sync if lyrics are paused externally or if the timestamp is old
- if (fPaused or (MasterClock = fLastClock)) then
+ MasterClock := fSyncSource.GetClock();
+ Result := LyricTime;
+
+ // do not sync if lyrics are paused externally or if the timestamp is old
+ if (fPaused or (MasterClock = fLastClock)) then
Exit;
// calculate average time difference (some sort of weighted mean).
- // The bigger AVG_HISTORY_FACTOR is, the smoother is the average diff.
- // This is done as some timestamps might be wrong or even lower
- // than their predecessor.
- TimeDiff := MasterClock - LyricTime;
- if (fAvgSyncDiff = -1) then
- fAvgSyncDiff := TimeDiff
- else
- fAvgSyncDiff := TimeDiff * (1-AVG_HISTORY_FACTOR) +
- fAvgSyncDiff * AVG_HISTORY_FACTOR;
-
- {$IFDEF LOG_SYNC}
- //Log.LogError(Format('TimeDiff: %.3f', [TimeDiff]));
- {$ENDIF}
-
+ // The bigger AVG_HISTORY_FACTOR is, the smoother is the average diff.
+ // This is done as some timestamps might be wrong or even lower
+ // than their predecessor.
+ TimeDiff := MasterClock - LyricTime;
+ if (fAvgSyncDiff = -1) then
+ fAvgSyncDiff := TimeDiff
+ else
+ fAvgSyncDiff := TimeDiff * (1-AVG_HISTORY_FACTOR) +
+ fAvgSyncDiff * AVG_HISTORY_FACTOR;
+
+ {$IFDEF LOG_SYNC}
+ //Log.LogError(Format('TimeDiff: %.3f', [TimeDiff]));
+ {$ENDIF}
+
// do not go backwards in time as this could mess up the score
if (fAvgSyncDiff > FORWARD_THRESHOLD) then
begin
{$IFDEF LOG_SYNC}
- Log.LogError('Sync: ' + floatToStr(MasterClock) + ' > ' + floatToStr(LyricTime));
- {$ENDIF}
+ Log.LogError('Sync: ' + floatToStr(MasterClock) + ' > ' + floatToStr(LyricTime));
+ {$ENDIF}
Result := LyricTime + fAvgSyncDiff;
fTimer.SetTime(Result);
@@ -219,14 +219,14 @@ begin
end
else if (fTimer.GetState = rtsPaused) and (fAvgSyncDiff >= 0) then
begin
- fTimer.Start();
+ fTimer.Start();
{$IFDEF LOG_SYNC}
Log.LogError('Unpause: ' + floatToStr(LyricTime));
{$ENDIF}
end;
fLastClock := MasterClock;
-end;
+end;
function TLyricsState.GetCurrentTime(): real;
var
@@ -241,7 +241,7 @@ end;
procedure TLyricsState.SetSyncSource(SyncSource: TSyncSource);
begin
- fSyncSource := SyncSource;
+ fSyncSource := SyncSource;
end;
(**