From f5ea14a97fe530ff7670645c3c6e5051b961d2a7 Mon Sep 17 00:00:00 2001 From: tobigun Date: Sat, 6 Sep 2008 09:46:24 +0000 Subject: - fixed out-of-range error. In NewNote() CurrentPlayer.Note[CurrentPlayer.HighNote] was accessed although CurrentPlayer.Note is empty (always the case at the beginning of a song). git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1346 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UMain.pas | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 5dacd5f8..08b9cc4a 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -769,7 +769,7 @@ var PlayerIndex: integer; CurrentSound: TCaptureBuffer; CurrentPlayer: PPlayer; - LastPlayerNote: PPLayerNote; + LastPlayerNote: PPlayerNote; Line: PLine; SentenceIndex: integer; SentenceMin: integer; @@ -823,7 +823,12 @@ begin begin CurrentPlayer := @Player[PlayerIndex]; CurrentSound := AudioInputProcessor.Sound[PlayerIndex]; - LastPlayerNote := @CurrentPlayer.Note[CurrentPlayer.HighNote]; + + // At the beginning of the song there is no previous note + if (Length(CurrentPlayer.Note) > 0) then + LastPlayerNote := @CurrentPlayer.Note[CurrentPlayer.HighNote] + else + LastPlayerNote := nil; // analyze buffer CurrentSound.AnalyzeBuffer; @@ -902,8 +907,10 @@ begin begin // we will add a new note NewNote := true; - // if last has the same tone + + // if previous note (if any) was the same, extend prrevious note if ((CurrentPlayer.LengthNote > 0) and + (LastPlayerNote <> nil) and (LastPlayerNote.Tone = CurrentSound.Tone) and ((LastPlayerNote.Start + LastPlayerNote.Length) = LyricsState.CurrentBeatD)) then begin @@ -939,7 +946,8 @@ begin else begin // extend note length - Inc(LastPlayerNote.Length); + if (LastPlayerNote <> nil) then + Inc(LastPlayerNote.Length); end; // check for perfect note and then lit the star (on Draw) -- cgit v1.2.3