Hello Emil,
Thanks again to you and Silhwan Hyun for your great effort for TMIDIPlayer2 project
I've tried to play the standard midifile many times than found a solution.
I've added two variations after implemetation and other provided codes in MidiFile2
unit as below.
Delphi-Quellcode:
....
implementation
var
isMetaLyric : Boolean;
nMetaTextCount : Integer;
.....
function TMidiFile2.ReadFromFile(const FileName: WideString): Boolean;
var
FileInfo: TMidiFileInfo;
I,N: Integer;
begin
FLyricsTrack := -1;
FLyrics := '';
if isMetaLyric then isMetaLyric := False; // Added by midijor
nMetaTextCount := 0; // Added by midijor
.............
end;
// In SaveMetaEvent procedure
procedure SaveMetaEvent(Status_: byte; Elapsed_: LongWord);
var
......
DataType2 : byte; // Added by midijor
str3 : AnsiString; // Added by midijor
......
begin
...........
TempoMap[TempoCounter-1].Tempo := Tempo;
end else
// Added by midijor
if DataType = $05 then // for metaLyric
begin
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType;
pEvent^.Msg := str2;
if isMetaLyric = false then isMetaLyric := True; // isMetaLyric founded
MidiTrack.AddEvent(pEvent);
end else
if DataType = $01 then // for converting metaText to metaLyric
begin
if isMetaLyric = false then
begin
DataType2 := $05;
if (str2[1] = '@') then //Chr($40)
begin
// some information
end
else
if str2[1] = Chr($5C) then // '\' clear line.
begin
if nMetaTextCount > 0 then
begin
str3 := Chr(10);
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType2;
pEvent^.Msg := str3;
MidiTrack.AddEvent(pEvent);
str3 := ' '+ Chr($A); //for new line
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType2;
pEvent^.Msg := str3;
MidiTrack.AddEvent(pEvent);
end;
nMetaTextCount := nMetaTextCount + 1;
str3 := Copy(str2, 2, Length(str2) -1);
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType2;
pEvent^.Msg := str3;
MidiTrack.AddEvent(pEvent);
end
else
if str2[1] = Chr($2F) then // New Line '/'
begin
str3 := ' '+ Chr($A); //for new line
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType2;
pEvent^.Msg := str3;
MidiTrack.AddEvent(pEvent);
str3 := Copy(str2, 2, Length(str2) -1);
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType2;
pEvent^.Msg := str3;
MidiTrack.AddEvent(pEvent);
end
else
begin
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType2;
pEvent^.Msg := str2;
MidiTrack.AddEvent(pEvent);
end;
end; // if MidiTrack.isMetaLyric = false then
end else
if DataType = $02 then
begin
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType;
pEvent^.Msg := str2;
MidiTrack.AddEvent(pEvent);
end else
if DataType = $03 then
begin
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType;
pEvent^.Msg := str2;
MidiTrack.AddEvent(pEvent);
end else
if DataType = $04 then
begin
New(pEvent);
pEvent^.Event := Status_;
pEvent^.Positon := Elapsed_;
pEvent^.Data1 := DataType;
pEvent^.Msg := str2;
MidiTrack.AddEvent(pEvent);
end;
end;
...........
I hope, you'll do better than me and your "KaraGL" project supports the standard midifile...
Best regards,
midijor