aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2013-02-24 18:55:15 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2013-02-24 18:55:15 +0000
commit297d5ab8e59ca017addec5f0893c89c4704074ed (patch)
tree781fc8aafb980c351903087397fbcf921c1293f2 /src/base
parent2cc11db3642564bb8a71c22739175a6dd65eb4cb (diff)
downloadusdx-297d5ab8e59ca017addec5f0893c89c4704074ed.tar.gz
usdx-297d5ab8e59ca017addec5f0893c89c4704074ed.tar.xz
usdx-297d5ab8e59ca017addec5f0893c89c4704074ed.zip
fix problems with empty songlist. thanks to Zup3rvock.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2949 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base')
-rw-r--r--src/base/UNote.pas38
-rw-r--r--src/base/USong.pas7
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;