From 6db1465f89985e8675db3fdac1aa7d662dda3722 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Sat, 19 Apr 2008 15:23:35 +0000 Subject: tried to make songloading working with the old loader and keep all changes that were made since starting to work on a new one *hope that worked* you may delete your existing cover.cache (the cover cache is still NOT working) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1024 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/USong.pas | 666 +++++++++++++++----------------------------- 1 file changed, 222 insertions(+), 444 deletions(-) (limited to 'Game/Code/Classes/USong.pas') diff --git a/Game/Code/Classes/USong.pas b/Game/Code/Classes/USong.pas index d878132a..66169ef0 100644 --- a/Game/Code/Classes/USong.pas +++ b/Game/Code/Classes/USong.pas @@ -42,7 +42,13 @@ type StartBeat: real; end; - {TSong = class + TScore = record + Name: widestring; + Score: integer; + Length: string; + end; + + TSong = class FileLineNo : integer; //Line which is readed at Last, for error reporting procedure ParseNote(LineNumber: integer; TypeP: char; StartP, DurationP, NoteP: integer; LyricS: string); @@ -105,88 +111,6 @@ type function Analyse(): boolean; function AnalyseXML(): boolean; procedure clear(); - end; } - - TScore = record - Name: widestring; - Score: integer; - Length: string; - end; - - AScore = Array[0..4] of TScore; - - {******************* - New TSong Class. - Containing some Methods for DB communication - but none for Song laoding, saving, these should be - implemented by child classes - *******************} - TSong = class - protected - SongID: Integer; //ID of this Song in the Song Database - FolderID: Integer; //ID of the Folder containing this Song - FileName: String; //Filename of this Song w/o Path - FilePath: String; //Path of this Song - - Procedure ResetAttributes; virtual; //Reset all Attributes of this object - Procedure ReadHeader; virtual; abstract; //Reads Fileheader (Implemented by Child only) - Procedure ReadFile; virtual; abstract; //Reads complete File (Header + Notes) (Implemented by Child only) - Procedure WriteFile; virtual; abstract; //Writes complete File (Header + Notes) (Implemented by Child only) - Procedure ReadFromDB; virtual; //Reads all available Information from DB - Function CheckDB: Integer; virtual; //Checks DB for Song. Result > 0 SongExists (ID Returned) - Function UpdateDB: Integer; virtual; //Writes all Header Information set in this Song Object to DB. Returns ID (Required when Updated first Time) - - // procedures to manage the lyrics - Procedure ResetLyrics; - Procedure AddLyricLine(const PlayerID: Integer; const StartBeat: Integer; const RelativeBeat: Integer = -1); - Procedure AddNote(const PlayerID: Integer; const NoteType: Char; const NoteStart, NoteLength, NoteTone: Integer; const NoteText: WideString); - Function SolmizatLyrics(const NoteTone: Integer; const NoteText: WideString): WideString; - Procedure AddBPM(const StartBeat: Integer; const NewBeat: Extended); - public - //Required Information - Title: widestring; - Artist: widestring; - - Mp3: widestring; //Full Path to MP3 - - Creator: widestring; - - Resolution: integer; - BPM: array of TBPM; - GAP: real; // in miliseconds - - Base : array[0..1] of integer; - Mult : integer; - MultBPM : integer; - - //Some Files - Cover: widestring; //Full Path to Cover - CoverID: Integer; //ID of Cover in Covers Cache - Background: widestring; //Full Path to BG - Video: widestring; //Full Path to Video - VideoGAP: real; - - - //Additional Information - NotesGAP: integer; - Start: real; // in seconds - Finish: integer; // in miliseconds - Relative: boolean; - - //Sorting - Genre: widestring; - Edition: widestring; - Language: widestring; - - - constructor Create(const Path: String = ''; const FolderID: Integer = 0); - Procedure LoadbyFile(const Path: String); - Procedure LoadbyID(const ID: Integer); - Procedure SavetoFile(const Filename: String = ''); - - Function Score(const Difficulty: Byte): AScore; - - Procedure Clear; end; implementation @@ -194,288 +118,10 @@ implementation uses TextGL, UIni, - UMusic; //needed for Lines - -var - RelativPosition: array [0..1] of Integer; - -constructor TSong.Create(const Path: String = ''; const FolderID: Integer = 0); -begin - If (Length(Path) > 0) AND (FolderID > 0) then - begin //Read Song Infos from File or DB - FilePath := ExtractFilePath(Path); - FileName := ExtractFileName(Path); - Self.FolderID := FolderID; - SongID := CheckDB; - - If (SongID = 0) then //Check if File has changed - begin - ResetAttributes; - ReadHeader; - SongID := UpdateDB; - //Get CoverID from Covers by Covers.AddCover(Coverscache checks if the Cover requires update - end; - end - else - begin - ResetAttributes; - end; -end; - -Procedure TSong.LoadbyFile(const Path: String); -begin - //Call all Functions to Load From File - //Set Song and Folder ID and Update DB if required - //Get CoverID from Covers by Covers.AddCover(Coverscache checks if the Cover requires update -end; - -Procedure TSong.LoadbyID(const ID: Integer); -begin - //Call all Functions to Load Song by ID - //Read all Information from file - //Get CoverID from Covers by Covers.AddCover(Coverscache checks if the Cover requires update -end; - -Procedure TSong.SavetoFile(const Filename: String = ''); -begin - //Save HeaderInformation and Notes to File. If File = '' use File that was read from -end; - -Function TSong.Score(const Difficulty: Byte): AScore; -begin - //Return Score of Difficulty(0..2) Easy to Difficult -end; - -Procedure TSong.Clear; -begin - ResetAttributes; -end; - -//-------- -// Reset all Attributes of this object -//-------- -Procedure TSong.ResetAttributes; -begin - SongID := 0; - FolderID := 0; - FileName := ''; - FilePath := ''; - - Title := ''; - Artist := ''; - Mp3 := ''; - SetLength(BPM, 0); - - Creator := ''; - Resolution := 0; - GAP := 0; - - Base[0] := 100; - Base[1] := 100; - - Mult := 1; - MultBPM := 4; - - Cover := ''; - CoverID := 0; - Background := ''; - Video := ''; - VideoGAP := 0; - - NotesGAP := 0; - Start := 0; - Finish := 0; - Relative := False; - - Genre := ''; - Edition := ''; - Language := ''; -end; - -//-------- -// Reads all available Information from DB -//-------- -Procedure TSong.ReadFromDB; -begin - // to- do -end; - - -//-------- -// Checks DB for Song. Result > 0 SongExists (ID Returned) -//-------- -Function TSong.CheckDB: Integer; -begin - // to- do -end; - - -//-------- -// Writes all Header Information set in this Song Object to DB. Returns ID (Required when Updated first Time) -//-------- -Function TSong.UpdateDB: Integer; -begin - // to- do -end; - -Procedure TSong.ResetLyrics; -var - i: Integer; -begin - for i := 0 to High(Lines) do - begin - SetLength(Lines[i].Line, 0); - Lines[i].High := -1; - end; - - for i := 0 to High(RelativPosition) do - begin - RelativPosition[i] := 0; - end; -end; - -Procedure TSong.AddLyricLine(const PlayerID: Integer; const StartBeat: Integer; const RelativeBeat: Integer = -1); -var - NewLineIdx: Integer; -begin - NewLineIdx := High(Lines[PlayerID].Line) + 1; - - with Lines[PlayerID] do - begin - // recent added line is not the last of the song - if (NewLineIdx > 0) then - Lines[PlayerID].Line[NewLineIdx - 1].LastLine := False; - - // if last line, has no notes, ignore the new line (except for the RelativeBeat) - if (NewLineIdx < 1) OR (Lines[PlayerID].Line[NewLineIdx - 1].HighNote > -1) then - begin - // create lyric line and update references - SetLength(Line, NewLineIdx); - High := NewLineIdx; - Number := Number + 1; - with Line[High] do - begin - // default values - TotalNotes := 0; - HighNote := -1; - LastLine := True; - BaseNote := 100; - - // set start beat count of this new line - Start := (RelativPosition[PlayerID] + StartBeat) * Mult; - end; - end; - - if Relative then - begin - if RelativeBeat >= 0 then - // if this is a relativ song, we have to update the relativ offset - RelativPosition[PlayerID] := (RelativPosition[PlayerID] + RelativeBeat) * Mult - else - RelativPosition[PlayerID] := (RelativPosition[PlayerID] + StartBeat) * Mult; - end; - end; -end; - -Procedure TSong.AddNote(const PlayerID: Integer; const NoteType: Char; const NoteStart, NoteLength, NoteTone: Integer; const NoteText: WideString); -begin - if (High(Lines[PlayerID].Line) < 0) then - AddLyricLine(PlayerID, NoteStart, 0); - - with Lines[PlayerID].Line[Lines[PlayerID].High] do begin - // array of Notes expand to have space for new Note - HighNote := HighNote + 1; - TotalNotes := TotalNotes + 1; - SetLength(Note, HighNote + 1); - - with Note[HighNote] do - begin - Start := (RelativPosition[PlayerID] + NoteStart) * Mult; - Length := NoteLength * Mult; - Tone := NoteTone; - Text := SolmizatLyrics(NoteTone, NoteText); - Lyric := Lyric + Text; - - // identify lowest note of line - if Tone < BaseNote then - BaseNote := Tone; - end; - - case NoteType of - 'F': Note[HighNote].NoteType := ntFreestyle; - ':': Note[HighNote].NoteType := ntNormal; - '*': Note[HighNote].NoteType := ntGolden; - end; - - // calculate total score value - if (Note[HighNote].NoteType = ntNormal) then - begin - // normal notes - Lines[PlayerID].ScoreValue := Lines[PlayerID].ScoreValue + Note[HighNote].Length; - TotalNotes := TotalNotes + Note[HighNote].Length; - end - else if (Note[HighNote].NoteType = ntGolden) then - begin - // golden notes - Lines[PlayerID].ScoreValue := Lines[PlayerID].ScoreValue + (Note[HighNote].Length * 2); - TotalNotes := TotalNotes + (Note[HighNote].Length * 2); - end; - - // finish of the line - End_ := Note[HighNote].Start + Note[HighNote].Length; - end; // with -end; + UMusic, //needed for Lines + UMain; //needed for Player -Function TSong.SolmizatLyrics(const NoteTone: Integer; const NoteText: WideString): WideString; -begin - Result := NoteText; - - case Ini.Solmization of - 1: // european - case (NoteTone mod 12) of - 0..1: Result := 'do '; - 2..3: Result := 're '; - 4: Result := 'mi '; - 5..6: Result := 'fa '; - 7..8: Result := 'sol '; - 9..10: Result := 'la '; - 11: Result := 'si '; - end; - - 2: // japanese - case (NoteTone mod 12) of - 0..1: Result := 'do '; - 2..3: Result := 're '; - 4: Result := 'mi '; - 5..6: Result := 'fa '; - 7..8: Result := 'so '; - 9..10: Result := 'la '; - 11: Result := 'shi '; - end; - - 3: // american - case (NoteTone mod 12) of - 0..1: Result := 'do '; - 2..3: Result := 're '; - 4: Result := 'mi '; - 5..6: Result := 'fa '; - 7..8: Result := 'sol '; - 9..10: Result := 'la '; - 11: Result := 'ti '; - end; - end; // case Ini.Solmization -end; - -Procedure TSong.AddBPM(const StartBeat: Integer; const NewBeat: Extended); -begin - SetLength(BPM, Length(BPM) + 1); - BPM[High(BPM)].StartBeat := StartBeat; - BPM[High(BPM)].StartBeat := BPM[High(BPM)].StartBeat + RelativPosition[0]; - - BPM[High(BPM)].BPM := NewBeat * Mult * MultBPM; -end; - -{constructor TSong.create( const aFileName : WideString ); +constructor TSong.create( const aFileName : WideString ); begin Mult := 1; @@ -512,8 +158,7 @@ begin end; end; -} -(* + //Load TXT Song function TSong.LoadSong(): boolean; @@ -540,7 +185,7 @@ begin MultBPM := 4; // multiply beat-count of note by 4 Mult := 1; // accuracy of measurement of note Base[0] := 100; // high number - Lines[0].NoteType := 0; + Lines[0].ScoreValue := 0; self.Relative := false; Rel[0] := 0; CP := 0; @@ -589,7 +234,6 @@ begin Lines[Count].Current := 0; Lines[Count].Resolution := self.Resolution; Lines[Count].NotesGAP := self.NotesGAP; - Lines[Count].Line[0].IlNut := 0; Lines[Count].Line[0].HighNote := -1; Lines[Count].Line[0].LastLine := False; end; @@ -660,7 +304,11 @@ begin Lines[CP].Line[Lines[CP].High].TotalNotes := 0; for I := low(Lines[CP].Line[Lines[CP].High].Note) to high(Lines[CP].Line[Lines[CP].High].Note) do begin - Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[I].Length * Lines[CP].Line[Lines[CP].High].Note[I].NoteType; + if (Lines[CP].Line[Lines[CP].High].Note[I].NoteType = ntGolden) then + Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[I].Length; + + if (Lines[CP].Line[Lines[CP].High].Note[I].NoteType <> ntFreestyle) then + Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[I].Length; end; //Total Notes Patch End end else begin @@ -671,14 +319,17 @@ begin Lines[Count].Line[Lines[Count].High].TotalNotes := 0; for I := low(Lines[Count].Line[Lines[Count].High].Note) to high(Lines[Count].Line[Lines[Count].High].Note) do begin - Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[I].Length * Lines[Count].Line[Lines[Count].High].Note[I].NoteType; + if (Lines[Count].Line[Lines[Count].High].Note[I].NoteType = ntGolden) then + Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[I].Length; + if (Lines[Count].Line[Lines[Count].High].Note[I].NoteType <> ntFreestyle) then + Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[I].Length; end; //Total Notes Patch End end; end; Read(SongFile, TempC); Inc(FileLineNo); - end; // while} { + end; // while} for Count := 0 to High(Lines) do begin Lines[Count].Line[High(Lines[Count].Line)].LastLine := True; @@ -728,7 +379,7 @@ begin MultBPM := 4; // multiply beat-count of note by 4 Mult := 1; // accuracy of measurement of note Base[0] := 100; // high number - Lines[0].NoteType := 0; + Lines[0].ScoreValue := 0; self.Relative := false; Rel[0] := 0; CP := 0; @@ -739,7 +390,7 @@ begin Parser := TParser.Create; - Parser.Settings.DashReplacement := '~'; + Parser.Settings.DashReplacement := '~'; for Count := 0 to High(Lines) do begin @@ -749,7 +400,6 @@ begin Lines[Count].Current := 0; Lines[Count].Resolution := self.Resolution; Lines[Count].NotesGAP := self.NotesGAP; - Lines[Count].Line[0].IlNut := 0; Lines[Count].Line[0].HighNote := -1; Lines[Count].Line[0].LastLine := False; end; @@ -757,38 +407,38 @@ begin //Try to Parse the Song If Parser.ParseSong(Path + PathDelim + FileName) then - begin -// Writeln('XML Inputfile Parsed succesful'); - //Start write parsed information to Song - //Notes Part - For I := 0 to High(Parser.SongInfo.Sentences) do - begin - //Add Notes - For J := 0 to High(Parser.SongInfo.Sentences[I].Notes) do - begin - Case Parser.SongInfo.Sentences[I].Notes[J].NoteTyp of - NT_Normal: NoteType := ':'; - NT_Golden: NoteType := '*'; - NT_Freestyle: NoteType := 'F'; - end; - - Param1:=Parser.SongInfo.Sentences[I].Notes[J].Start; //Note Start - Param2:=Parser.SongInfo.Sentences[I].Notes[J].Duration; //Note Duration - Param3:=Parser.SongInfo.Sentences[I].Notes[J].Tone; //Note Tone - ParamS:=' ' + Parser.SongInfo.Sentences[I].Notes[J].Lyric; //Note Lyric - - - if not Both then + begin +// Writeln('XML Inputfile Parsed succesful'); + //Start write parsed information to Song + //Notes Part + For I := 0 to High(Parser.SongInfo.Sentences) do + begin + //Add Notes + For J := 0 to High(Parser.SongInfo.Sentences[I].Notes) do + begin + Case Parser.SongInfo.Sentences[I].Notes[J].NoteTyp of + NT_Normal: NoteType := ':'; + NT_Golden: NoteType := '*'; + NT_Freestyle: NoteType := 'F'; + end; + + Param1:=Parser.SongInfo.Sentences[I].Notes[J].Start; //Note Start + Param2:=Parser.SongInfo.Sentences[I].Notes[J].Duration; //Note Duration + Param3:=Parser.SongInfo.Sentences[I].Notes[J].Tone; //Note Tone + ParamS:=' ' + Parser.SongInfo.Sentences[I].Notes[J].Lyric; //Note Lyric + + + if not Both then // P1 ParseNote(0, NoteType, (Param1+Rel[0]) * Mult, Param2 * Mult, Param3, ParamS) else begin // P1 + P2 ParseNote(0, NoteType, (Param1+Rel[0]) * Mult, Param2 * Mult, Param3, ParamS); ParseNote(1, NoteType, (Param1+Rel[1]) * Mult, Param2 * Mult, Param3, ParamS); - end; - - - if not Both then + end; + + + if not Both then begin Lines[CP].Line[Lines[CP].High].BaseNote := Base[CP]; Lines[CP].Line[Lines[CP].High].LyricWidth := glTextWidth(PChar(Lines[CP].Line[Lines[CP].High].Lyric)); @@ -796,7 +446,11 @@ If Parser.ParseSong(Path + PathDelim + FileName) then Lines[CP].Line[Lines[CP].High].TotalNotes := 0; for X := low(Lines[CP].Line[Lines[CP].High].Note) to high(Lines[CP].Line[Lines[CP].High].Note) do begin - Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[X].Length * Lines[CP].Line[Lines[CP].High].Note[X].NoteType; + if (Lines[CP].Line[Lines[CP].High].Note[I].NoteType = ntGolden) then + Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[X].Length; + + if (Lines[CP].Line[Lines[CP].High].Note[I].NoteType <> ntFreestyle) then + Lines[CP].Line[Lines[CP].High].TotalNotes := Lines[CP].Line[Lines[CP].High].TotalNotes + Lines[CP].Line[Lines[CP].High].Note[X].Length; end; //Total Notes Patch End end else begin @@ -807,35 +461,39 @@ If Parser.ParseSong(Path + PathDelim + FileName) then Lines[Count].Line[Lines[Count].High].TotalNotes := 0; for X := low(Lines[Count].Line[Lines[Count].High].Note) to high(Lines[Count].Line[Lines[Count].High].Note) do begin - Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[X].Length * Lines[Count].Line[Lines[Count].High].Note[X].NoteType; - end; + if (Lines[Count].Line[Lines[Count].High].Note[I].NoteType = ntGolden) then + Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[X].Length; + if (Lines[Count].Line[Lines[Count].High].Note[I].NoteType <> ntFreestyle) then + Lines[Count].Line[Lines[Count].High].TotalNotes := Lines[Count].Line[Lines[Count].High].TotalNotes + Lines[Count].Line[Lines[Count].High].Note[X].Length; + + end; //Total Notes Patch End end; end; - - - - end; //J Forloop - - //Add Sentence break - If (I < High(Parser.SongInfo.Sentences)) then - begin - - SentenceEnd := Parser.SongInfo.Sentences[I].Notes[High(Parser.SongInfo.Sentences[I].Notes)].Start + Parser.SongInfo.Sentences[I].Notes[High(Parser.SongInfo.Sentences[I].Notes)].Duration; - Rest := Parser.SongInfo.Sentences[I+1].Notes[0].Start - SentenceEnd; - - //Calculate Time - Case Rest of - 0, 1: Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start; - 2: Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start - 1; - 3: Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start - 2; - else - If (Rest >= 4) then - Time := SentenceEnd + 2 - Else //Sentence overlapping :/ - Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start; - end; - // new sentence + + + + end; //J Forloop + + //Add Sentence break + If (I < High(Parser.SongInfo.Sentences)) then + begin + + SentenceEnd := Parser.SongInfo.Sentences[I].Notes[High(Parser.SongInfo.Sentences[I].Notes)].Start + Parser.SongInfo.Sentences[I].Notes[High(Parser.SongInfo.Sentences[I].Notes)].Duration; + Rest := Parser.SongInfo.Sentences[I+1].Notes[0].Start - SentenceEnd; + + //Calculate Time + Case Rest of + 0, 1: Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start; + 2: Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start - 1; + 3: Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start - 2; + else + If (Rest >= 4) then + Time := SentenceEnd + 2 + Else //Sentence overlapping :/ + Time := Parser.SongInfo.Sentences[I+1].Notes[0].Start; + end; + // new sentence if not Both then // P1 NewSentence(0, (Time + Rel[0]) * Mult, Param2) @@ -843,19 +501,19 @@ If Parser.ParseSong(Path + PathDelim + FileName) then // P1 + P2 NewSentence(0, (Time + Rel[0]) * Mult, Param2); NewSentence(1, (Time + Rel[1]) * Mult, Param2); - end; - - end; - end; + end; + + end; + end; //End write parsed information to Song Parser.Free; - end - else - begin - Log.LogError('Could not parse Inputfile: ' + Path + PathDelim + FileName); - exit; - end; - + end + else + begin + Log.LogError('Could not parse Inputfile: ' + Path + PathDelim + FileName); + exit; + end; + for Count := 0 to High(Lines) do begin Lines[Count].Line[High(Lines[Count].Line)].LastLine := True; end; @@ -1022,10 +680,10 @@ begin //Required Attributes //----------- - {$IFDEF UTF8_FILENAMES} { + {$IFDEF UTF8_FILENAMES} if ((Identifier = 'MP3') or (Identifier = 'BACKGROUND') or (Identifier = 'COVER') or (Identifier = 'VIDEO')) then Value := Utf8Encode(Value); - {$ENDIF} { + {$ENDIF} //Title if (Identifier = 'TITLE') then @@ -1169,6 +827,126 @@ begin end; +procedure TSong.ParseNote(LineNumber: integer; TypeP: char; StartP, DurationP, NoteP: integer; LyricS: string); +//var +// Space: boolean; // Auto Removed, Unused Variable +begin + case Ini.Solmization of + 1: // european + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' sol '; + 9..10: LyricS := ' la '; + 11: LyricS := ' si '; + end; + end; + 2: // japanese + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' so '; + 9..10: LyricS := ' la '; + 11: LyricS := ' shi '; + end; + end; + 3: // american + begin + case (NoteP mod 12) of + 0..1: LyricS := ' do '; + 2..3: LyricS := ' re '; + 4: LyricS := ' mi '; + 5..6: LyricS := ' fa '; + 7..8: LyricS := ' sol '; + 9..10: LyricS := ' la '; + 11: LyricS := ' ti '; + end; + end; + end; // case + + with Lines[LineNumber].Line[Lines[LineNumber].High] do begin + SetLength(Note, Length(Note) + 1); + HighNote := High(Note); + + Note[HighNote].Start := StartP; + if HighNote = 0 then begin + if Lines[LineNumber].Number = 1 then + Start := -100; +// Start := Note[HighNote].Start; + end; + + Note[HighNote].Length := DurationP; + + // back to the normal system with normal, golden and now freestyle notes + case TypeP of + 'F': Note[HighNote].NoteType := ntFreestyle; + ':': Note[HighNote].NoteType := ntNormal; + '*': Note[HighNote].NoteType := ntGolden; + end; + + if (Note[HighNote].NoteType = ntGolden) then + Lines[LineNumber].ScoreValue := Lines[LineNumber].ScoreValue + Note[HighNote].Length; + + if (Note[HighNote].NoteType <> ntFreestyle) then + Lines[LineNumber].ScoreValue := Lines[LineNumber].ScoreValue + Note[HighNote].Length; + + Note[HighNote].Tone := NoteP; + if Note[HighNote].Tone < Base[LineNumber] then Base[LineNumber] := Note[HighNote].Tone; + + Note[HighNote].Text := Copy(LyricS, 2, 100); + Lyric := Lyric + Note[HighNote].Text; + + End_ := Note[HighNote].Start + Note[HighNote].Length; + end; // with +end; + +procedure TSong.NewSentence(LineNumberP: integer; Param1, Param2: integer); +var +I: Integer; +begin + + // stara czesc //Alter Satz //Update Old Part + Lines[LineNumberP].Line[Lines[LineNumberP].High].BaseNote := Base[LineNumberP]; + Lines[LineNumberP].Line[Lines[LineNumberP].High].LyricWidth := glTextWidth(PChar(Lines[LineNumberP].Line[Lines[LineNumberP].High].Lyric)); + + //Total Notes Patch + Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := 0; + for I := low(Lines[LineNumberP].Line[Lines[LineNumberP].High].Note) to high(Lines[LineNumberP].Line[Lines[LineNumberP].High].Note) do + begin + if (Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].NoteType = ntGolden) then + Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes + Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].Length; + + if (Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].NoteType <> ntFreestyle) then + Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes := Lines[LineNumberP].Line[Lines[LineNumberP].High].TotalNotes + Lines[LineNumberP].Line[Lines[LineNumberP].High].Note[I].Length; + end; + //Total Notes Patch End + + + // nowa czesc //Neuer Satz //Update New Part + SetLength(Lines[LineNumberP].Line, Lines[LineNumberP].Number + 1); + Lines[LineNumberP].High := Lines[LineNumberP].High + 1; + Lines[LineNumberP].Number := Lines[LineNumberP].Number + 1; + Lines[LineNumberP].Line[Lines[LineNumberP].High].HighNote := -1; + + if self.Relative then + begin + Lines[LineNumberP].Line[Lines[LineNumberP].High].Start := Param1; + Rel[LineNumberP] := Rel[LineNumberP] + Param2; + end + else + Lines[LineNumberP].Line[Lines[LineNumberP].High].Start := Param1; + + Lines[LineNumberP].Line[Lines[LineNumberP].High].LastLine := False; + + Base[LineNumberP] := 100; // high number +end; + procedure TSong.clear(); begin //Main Information @@ -1182,11 +960,11 @@ begin //Required Information Mp3 := ''; - {$IFDEF FPC} { + {$IFDEF FPC} setlength( BPM, 0 ); - {$ELSE} { + {$ELSE} BPM := nil; - {$ENDIF} { + {$ENDIF} GAP := 0; Start := 0; @@ -1242,6 +1020,6 @@ begin //Read Header Result := self.ReadXMLHeader( FileName ); -end; *) +end; end. -- cgit v1.2.3