aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UMusic.pas
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-07-19 12:48:23 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-07-19 12:48:23 +0000
commit517e6872ed12e6a9144c4fbd0b02063feeab5528 (patch)
tree5b9feb4722281edc180ecfc42c12cf447f3fb39b /Game/Code/Classes/UMusic.pas
parentdcc64f116267edcf72f5e18105310c68355149f7 (diff)
downloadusdx-517e6872ed12e6a9144c4fbd0b02063feeab5528.tar.gz
usdx-517e6872ed12e6a9144c4fbd0b02063feeab5528.tar.xz
usdx-517e6872ed12e6a9144c4fbd0b02063feeab5528.zip
lyric engine patches, solves
- pixeled/transparent fonts bug - some lines were erroneously marked active or disabled - state was not initialized correctly - negative gap problem (TLyricLine.Start was of type cardinal) - some more lyrics bugs git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1211 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UMusic.pas81
1 files changed, 69 insertions, 12 deletions
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas
index 3ef6aca2..2df5286e 100644
--- a/Game/Code/Classes/UMusic.pas
+++ b/Game/Code/Classes/UMusic.pas
@@ -65,46 +65,47 @@ type
end;
(**
- * TLineState contains all information that concerns the current frames
+ * TLineState contains all information that concerns the
+ * state of the lyrics.
*)
TLineState = class
private
Timer: TRelativeTimer; // keeps track of the current time
-
- function GetCurrentTime(): real;
- procedure SetCurrentTime(Time: real);
public
OldBeat: integer; // previous discovered beat
- CurrentBeat: integer;
- MidBeat: real; // like CurrentBeat
+ CurrentBeat: integer; // current beat (rounded)
+ MidBeat: real; // current beat (float)
// now we use this for super synchronization!
// only used when analyzing voice
// TODO: change ...D to ...Detect(ed)
OldBeatD: integer; // previous discovered beat
- CurrentBeatD: integer;
- MidBeatD: real; // like CurrentBeatD
- FracBeatD: real; // fractional part of MidBeatD
+ CurrentBeatD: integer; // current discovered beat (rounded)
+ MidBeatD: real; // current discovered beat (float)
// we use this for audible clicks
// TODO: Change ...C to ...Click
OldBeatC: integer; // previous discovered beat
CurrentBeatC: integer;
MidBeatC: real; // like CurrentBeatC
- FracBeatC: real; // fractional part of MidBeatC
OldLine: integer; // previous displayed sentence
+ StartTime: real; // time till start of lyrics (= Gap)
TotalTime: real; // total song time
constructor Create();
procedure Pause();
procedure Resume();
+ procedure Reset();
+ procedure UpdateBeats();
+
(**
- * current song time used as base-timer for lyrics etc.
+ * current song time (in seconds) used as base-timer for lyrics etc.
*)
- property CurrentTime: real read GetCurrentTime write SetCurrentTime;
+ function GetCurrentTime(): real;
+ procedure SetCurrentTime(Time: real);
end;
@@ -926,11 +927,17 @@ begin
end;
end;
+
+{ TVoiceRemoval }
+
constructor TLineState.Create();
begin
// create a triggered timer, so we can Pause() it, set the time
// and Resume() it afterwards for better synching.
Timer := TRelativeTimer.Create(true);
+
+ // reset state
+ Reset();
end;
procedure TLineState.Pause();
@@ -955,6 +962,56 @@ begin
Result := Timer.GetTime();
end;
+(**
+ * Resets the timer and state of the lyrics.
+ * The timer will be stopped afterwards so you have to call Resume()
+ * to start the lyrics timer.
+ *)
+procedure TLineState.Reset();
+begin
+ Pause();
+ SetCurrentTime(0);
+
+ StartTime := 0;
+ TotalTime := 0;
+
+ OldBeat := -1;
+ MidBeat := -1;
+ CurrentBeat := -1;
+
+ OldBeatC := -1;
+ MidBeatC := -1;
+ CurrentBeatC := -1;
+
+ OldBeatD := -1;
+ MidBeatD := -1;
+ CurrentBeatD := -1;
+end;
+
+(**
+ * Updates the beat information (CurrentBeat/MidBeat/...) according to the
+ * current lyric time.
+ *)
+procedure TLineState.UpdateBeats();
+var
+ CurLyricsTime: real;
+begin
+ CurLyricsTime := GetCurrentTime();
+
+ OldBeat := CurrentBeat;
+ MidBeat := GetMidBeat(CurLyricsTime - StartTime / 1000);
+ CurrentBeat := Floor(MidBeat);
+
+ OldBeatC := CurrentBeatC;
+ MidBeatC := GetMidBeat(CurLyricsTime - StartTime / 1000);
+ CurrentBeatC := Floor(MidBeatC);
+
+ OldBeatD := CurrentBeatD;
+ // MidBeatD = MidBeat with additional GAP
+ MidBeatD := -0.5 + GetMidBeat(CurLyricsTime - (StartTime + 120 + 20) / 1000);
+ CurrentBeatD := Floor(MidBeatD);
+end;
+
{ TAudioConverter }