diff options
-rw-r--r-- | src/base/UNote.pas | 38 | ||||
-rw-r--r-- | src/base/USong.pas | 7 |
2 files changed, 27 insertions, 18 deletions
diff --git a/src/base/UNote.pas b/src/base/UNote.pas index b9e71ac2..f3ff19ce 100644 --- a/src/base/UNote.pas +++ b/src/base/UNote.pas @@ -231,37 +231,43 @@ begin end;
end;
-function GetTimeFromBeat(Beat: integer): real;
+function GetTimeFromBeat(Beat: integer; SelfSong: TSong = nil): real;
var
CurBPM: integer;
+ Song: TSong;
begin
+ if (SelfSong <> nil) then
+ Song := SelfSong
+ else
+ Song := CurrentSong;
+
// static BPM
- if Length(CurrentSong.BPM) = 1 then
+ if Length(Song.BPM) = 1 then
begin
- Result := CurrentSong.GAP / 1000 + Beat * 60 / CurrentSong.BPM[0].BPM;
+ Result := Song.GAP / 1000 + Beat * 60 / Song.BPM[0].BPM;
end
// variable BPM
- else if Length(CurrentSong.BPM) > 1 then
+ else if Length(Song.BPM) > 1 then
begin
- Result := CurrentSong.GAP / 1000;
+ Result := Song.GAP / 1000;
CurBPM := 0;
- while (CurBPM <= High(CurrentSong.BPM)) and
- (Beat > CurrentSong.BPM[CurBPM].StartBeat) do
+ while (CurBPM <= High(Song.BPM)) and
+ (Beat > Song.BPM[CurBPM].StartBeat) do
begin
- if (CurBPM < High(CurrentSong.BPM)) and
- (Beat >= CurrentSong.BPM[CurBPM+1].StartBeat) then
+ if (CurBPM < High(Song.BPM)) and
+ (Beat >= Song.BPM[CurBPM+1].StartBeat) then
begin
// full range
- Result := Result + (60 / CurrentSong.BPM[CurBPM].BPM) *
- (CurrentSong.BPM[CurBPM+1].StartBeat - CurrentSong.BPM[CurBPM].StartBeat);
+ Result := Result + (60 / Song.BPM[CurBPM].BPM) *
+ (Song.BPM[CurBPM+1].StartBeat - Song.BPM[CurBPM].StartBeat);
end;
- if (CurBPM = High(CurrentSong.BPM)) or
- (Beat < CurrentSong.BPM[CurBPM+1].StartBeat) then
+ if (CurBPM = High(Song.BPM)) or
+ (Beat < Song.BPM[CurBPM+1].StartBeat) then
begin
// in the middle
- Result := Result + (60 / CurrentSong.BPM[CurBPM].BPM) *
- (Beat - CurrentSong.BPM[CurBPM].StartBeat);
+ Result := Result + (60 / Song.BPM[CurBPM].BPM) *
+ (Beat - Song.BPM[CurBPM].StartBeat);
end;
Inc(CurBPM);
end;
@@ -410,7 +416,7 @@ var CurrentSound: TCaptureBuffer;
CurrentPlayer: PPlayer;
LastPlayerNote: PPlayerNote;
- Line: PLine;
+ Line: PLine;
SentenceIndex: integer;
SentenceMin: integer;
SentenceMax: integer;
diff --git a/src/base/USong.pas b/src/base/USong.pas index 38ba1c12..4f35d774 100644 --- a/src/base/USong.pas +++ b/src/base/USong.pas @@ -1188,7 +1188,7 @@ begin if ((MedleyFlags and 1) = 0) or (self.PreviewStart <= 0) then //PreviewStart is not set or <=0 begin if (MedleyFlags and 2) = 2 then - self.PreviewStart := GetTimeFromBeat(self.Medley.StartBeat) //fallback to MedleyStart + self.PreviewStart := GetTimeFromBeat(self.Medley.StartBeat, self) //fallback to MedleyStart else self.PreviewStart := 0; //else set it to 0, it will be set in FindRefrainStart end; @@ -1552,7 +1552,10 @@ begin Resolution := 4; Creator := ''; PreviewStart := 0; - CalcMedley := true; + if CurrentSong = nil then + CalcMedley := false + else + CalcMedley := true; Medley.Source := msNone; Relative := false; |