aboutsummaryrefslogtreecommitdiffstats
path: root/unicode/src
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 15:11:21 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 15:11:21 +0000
commit2c54c37a8f0a8c9ab72eb6bfd31bc5d11a074edd (patch)
tree720ea81802d2a2ea60d78c74498dd1198d1fc9cb /unicode/src
parent1bf5b29c3e15898ccf2527f0c5069da508ee24aa (diff)
downloadusdx-2c54c37a8f0a8c9ab72eb6bfd31bc5d11a074edd.tar.gz
usdx-2c54c37a8f0a8c9ab72eb6bfd31bc5d11a074edd.tar.xz
usdx-2c54c37a8f0a8c9ab72eb6bfd31bc5d11a074edd.zip
midi fixes
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1870 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--unicode/src/screens/UScreenEditConvert.pas429
-rw-r--r--unicode/src/screens/UScreenEditHeader.pas8
2 files changed, 232 insertions, 205 deletions
diff --git a/unicode/src/screens/UScreenEditConvert.pas b/unicode/src/screens/UScreenEditConvert.pas
index 109a828b..8c7f5fa7 100644
--- a/unicode/src/screens/UScreenEditConvert.pas
+++ b/unicode/src/screens/UScreenEditConvert.pas
@@ -25,6 +25,16 @@
unit UScreenEditConvert;
+{*
+ * See
+ * MIDI Recommended Practice (RP-017): SMF Lyric Meta Event Definition
+ * http://www.midi.org/techspecs/rp17.php
+ * MIDI Recommended Practice (RP-026): SMF Language and Display Extensions
+ * http://www.midi.org/techspecs/rp26.php
+ * MIDI File Format
+ * http://www.sonicspot.com/guide/midifiles.html
+ *}
+
interface
{$IFDEF FPC}
@@ -48,7 +58,7 @@ uses
UThemes;
type
- TNote = record
+ TMidiNote = record
Event: integer;
EventType: integer;
Channel: integer;
@@ -56,43 +66,41 @@ type
Len: real;
Data1: integer;
Data2: integer;
- Str: string;
+ Str: AnsiString;
end;
TTrack = record
- Note: array of TNote;
- Name: string;
- Hear: boolean;
- Status: set of (notes, lyrics);
+ Note: array of TMidiNote;
+ Name: AnsiString;
+ Status: set of (tsNotes, tsLyrics);
+ LyricType: set of (ltKMIDI, ltSMFLyric);
+ NoteType: (ntNone, ntAvail);
end;
- TNuta = record
+ TNote = record
Start: integer;
Len: integer;
Tone: integer;
- Lyric: string;
+ Lyric: AnsiString;
NewSentence: boolean;
end;
TArrayTrack = array of TTrack;
TScreenEditConvert = class(TMenu)
- public
- ATrack: TArrayTrack; // actual track
-// Track: TArrayTrack;
- Channel: TArrayTrack;
+ private
+ Tracks: TArrayTrack; // current track
ColR: array[0..100] of real;
ColG: array[0..100] of real;
ColB: array[0..100] of real;
Len: real;
- Sel: integer;
- Selected: boolean;
-// FileName: string;
+ SelTrack: integer; // index of selected track
+ //FileName: string;
{$IFDEF UseMIDIPort}
MidiFile: TMidiFile;
MidiTrack: TMidiTrack;
- MidiEvent: pMidiEvent;
+ MidiEvent: PMidiEvent;
MidiOut: TMidiOutput;
{$ENDIF}
@@ -100,16 +108,18 @@ type
Lines: TLines;
BPM: real;
Ticks: real;
- Note: array of TNuta;
+ Note: array of TNote;
- procedure AddLyric(Start: integer; Text: string);
+ procedure AddLyric(Start: integer; Text: AnsiString);
procedure Extract;
{$IFDEF UseMIDIPort}
procedure MidiFile1MidiEvent(event: PMidiEvent);
{$ENDIF}
- function SelectedNumber: integer;
+ function CountSelectedTracks: integer;
+
+ public
constructor Create; override;
procedure onShow; override;
function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override;
@@ -133,9 +143,27 @@ uses
UMain,
UPath,
USkins,
+ UTextEncoding,
UUnicodeUtils;
+const
+ // MIDI/KAR lyrics are specified to be ASCII only.
+ // Assume backward compatible CP1252 encoding.
+ DEFAULT_ENCODING = encCP1252;
+
+const
+ MIDI_EVENTTYPE_NOTEOFF = $8;
+ MIDI_EVENTTYPE_NOTEON = $9;
+ MIDI_EVENTTYPE_META_SYSEX = $F;
+
+ MIDI_EVENT_META = $FF;
+ MIDI_META_TEXT = $1;
+ MIDI_META_LYRICS = $5;
+
function TScreenEditConvert.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean;
+var
+ SResult: TSaveSongResult;
+ Playing: boolean;
begin
Result := true;
if (PressedDown) then
@@ -154,9 +182,9 @@ begin
SDLK_ESCAPE,
SDLK_BACKSPACE :
begin
- {$IFDEF UseMIDIPort}
+ {$IFDEF UseMIDIPort}
MidiFile.StopPlaying;
- {$ENDIF}
+ {$ENDIF}
AudioPlayback.PlaySound(SoundLib.Back);
FadeTo(@ScreenEdit);
end;
@@ -172,37 +200,32 @@ begin
if Interaction = 1 then
begin
- Selected := false;
- {$IFDEF UseMIDIPort}
+ {$IFDEF UseMIDIPort}
MidiFile.OnMidiEvent := MidiFile1MidiEvent;
-// MidiFile.GoToTime(MidiFile.GetTrackLength div 2);
+ //MidiFile.GoToTime(MidiFile.GetTrackLength div 2);
MidiFile.StartPlaying;
{$ENDIF}
end;
if Interaction = 2 then
begin
- Selected := true;
{$IFDEF UseMIDIPort}
MidiFile.OnMidiEvent := nil;
+ MidiFile.StartPlaying;
{$ENDIF}
- {for T := 0 to High(ATrack) do
- begin
- if ATrack[T].Hear then
- begin
- MidiTrack := MidiFile.GetTrack(T);
- MidiTrack.OnMidiEvent := MidiFile1MidiEvent;
- end;
- end;
- MidiFile.StartPlaying;//}
end;
if Interaction = 3 then
begin
- if SelectedNumber > 0 then
+ if CountSelectedTracks > 0 then
begin
Extract;
- SaveSong(Song, Lines, ChangeFileExt(ConversionFileName, '.txt'), false);
+ SResult := SaveSong(Song, Lines, ChangeFileExt(ConversionFileName, '.txt'),
+ false);
+ if (SResult <> ssrOK) then
+ begin
+ ScreenPopupError.ShowPopup('Could not save file');
+ end;
end;
end;
@@ -210,26 +233,44 @@ begin
SDLK_SPACE:
begin
-// ATrack[Sel].Hear := not ATrack[Sel].Hear;
- if Notes in ATrack[Sel].Status then
+ if (Tracks[SelTrack].NoteType = ntAvail) and
+ (Tracks[SelTrack].LyricType <> []) then
+ begin
+ if (Tracks[SelTrack].Status = []) then
+ Tracks[SelTrack].Status := [tsNotes]
+ else if (Tracks[SelTrack].Status = [tsNotes]) then
+ Tracks[SelTrack].Status := [tsLyrics]
+ else if (Tracks[SelTrack].Status = [tsLyrics]) then
+ Tracks[SelTrack].Status := [tsNotes, tsLyrics]
+ else if (Tracks[SelTrack].Status = [tsNotes, tsLyrics]) then
+ Tracks[SelTrack].Status := [];
+ end
+ else if (Tracks[SelTrack].NoteType = ntAvail) then
begin
- ATrack[Sel].Status := ATrack[Sel].Status - [Notes];
- if Lyrics in ATrack[Sel].Status then
- ATrack[Sel].Status := ATrack[Sel].Status - [Lyrics]
+ if (Tracks[SelTrack].Status = []) then
+ Tracks[SelTrack].Status := [tsNotes]
else
- ATrack[Sel].Status := ATrack[Sel].Status + [Lyrics];
+ Tracks[SelTrack].Status := [];
end
- else
- ATrack[Sel].Status := ATrack[Sel].Status + [Notes];
-
-{ if Selected then
+ else if (Tracks[SelTrack].LyricType <> []) then
begin
- MidiTrack := MidiFile.GetTrack(Sel);
- if Track[Sel].Hear then
- MidiTrack.OnMidiEvent := MidiFile1MidiEvent
+ if (Tracks[SelTrack].Status = []) then
+ Tracks[SelTrack].Status := [tsLyrics]
else
- MidiTrack.OnMidiEvent := nil;
- end;}
+ Tracks[SelTrack].Status := [];
+ end;
+
+ {$IFDEF UseMIDIPort}
+ Playing := (MidiFile.GetCurrentTime > 0);
+ MidiFile.StopPlaying();
+ MidiTrack := MidiFile.GetTrack(SelTrack);
+ if tsNotes in Tracks[SelTrack].Status then
+ MidiTrack.OnMidiEvent := MidiFile1MidiEvent
+ else
+ MidiTrack.OnMidiEvent := nil;
+ if (Playing) then
+ MidiFile.ContinuePlaying();
+ {$ENDIF}
end;
SDLK_RIGHT:
@@ -244,21 +285,21 @@ begin
SDLK_DOWN:
begin
- Inc(Sel);
- if Sel > High(ATrack) then
- Sel := 0;
+ Inc(SelTrack);
+ if SelTrack > High(Tracks) then
+ SelTrack := 0;
end;
SDLK_UP:
begin
- Dec(Sel);
- if Sel < 0 then
- Sel := High(ATrack);
+ Dec(SelTrack);
+ if SelTrack < 0 then
+ SelTrack := High(Tracks);
end;
end;
end;
end;
-procedure TScreenEditConvert.AddLyric(Start: integer; Text: string);
+procedure TScreenEditConvert.AddLyric(Start: integer; Text: AnsiString);
var
N: integer;
begin
@@ -266,22 +307,27 @@ begin
begin
if Note[N].Start = Start then
begin
- // check for new sentece
- if Copy(Text, 1, 1) = '\' then
+ // Line Feed -> end of paragraph
+ if Copy(Text, 1, 1) = #$0A then
Delete(Text, 1, 1);
- if Copy(Text, 1, 1) = '/' then
+ // Carriage Return -> end of line
+ if Copy(Text, 1, 1) = #$0D then
begin
Delete(Text, 1, 1);
Note[N].NewSentence := true;
end;
- // overwrite lyric od append
+ // overwrite lyric or append
if Note[N].Lyric = '-' then
Note[N].Lyric := Text
else
Note[N].Lyric := Note[N].Lyric + Text;
+
+ Exit;
end;
end;
+
+ DebugWriteln('Missing: ' + Text);
end;
procedure TScreenEditConvert.Extract;
@@ -290,14 +336,13 @@ var
C: integer;
N: integer;
Nu: integer;
- NoteTemp: TNuta;
+ NoteTemp: TNote;
Move: integer;
Max, Min: integer;
begin
// song info
- Song.Title := '';
- Song.Artist := '';
- Song.Mp3 := '';
+ Song := TSong.Create();
+ Song.Clear();
Song.Resolution := 4;
SetLength(Song.BPM, 1);
Song.BPM[0].BPM := BPM*4;
@@ -305,21 +350,20 @@ begin
SetLength(Note, 0);
// extract notes
- for T := 0 to High(ATrack) do
+ for T := 0 to High(Tracks) do
begin
-// if ATrack[T].Hear then
-// begin
- if Notes in ATrack[T].Status then
+ if tsNotes in Tracks[T].Status then
begin
- for N := 0 to High(ATrack[T].Note) do
+ for N := 0 to High(Tracks[T].Note) do
begin
- if (ATrack[T].Note[N].EventType = 9) and (ATrack[T].Note[N].Data2 > 0) then
+ if (Tracks[T].Note[N].EventType = MIDI_EVENTTYPE_NOTEON) and
+ (Tracks[T].Note[N].Data2 > 0) then
begin
Nu := Length(Note);
SetLength(Note, Nu + 1);
- Note[Nu].Start := Round(ATrack[T].Note[N].Start / Ticks);
- Note[Nu].Len := Round(ATrack[T].Note[N].Len / Ticks);
- Note[Nu].Tone := ATrack[T].Note[N].Data1 - 12*5;
+ Note[Nu].Start := Round(Tracks[T].Note[N].Start / Ticks);
+ Note[Nu].Len := Round(Tracks[T].Note[N].Len / Ticks);
+ Note[Nu].Tone := Tracks[T].Note[N].Data1 - 12*5;
Note[Nu].Lyric := '-';
end;
end;
@@ -327,18 +371,16 @@ begin
end;
// extract lyrics
- for T := 0 to High(ATrack) do
+ for T := 0 to High(Tracks) do
begin
-// if ATrack[T].Hear then
-// begin
- if Lyrics in ATrack[T].Status then
+ if tsLyrics in Tracks[T].Status then
begin
- for N := 0 to High(ATrack[T].Note) do
+ for N := 0 to High(Tracks[T].Note) do
begin
- if (ATrack[T].Note[N].EventType = 15) then
+ if (Tracks[T].Note[N].Event = MIDI_EVENT_META) and
+ (Tracks[T].Note[N].Data1 = MIDI_META_LYRICS) then
begin
-// Log.LogStatus('<' + Track[T].Note[N].Str + '>', 'MIDI');
- AddLyric(Round(ATrack[T].Note[N].Start / Ticks), ATrack[T].Note[N].Str);
+ AddLyric(Round(Tracks[T].Note[N].Start / Ticks), Tracks[T].Note[N].Str);
end;
end;
end;
@@ -404,35 +446,38 @@ begin
// create space for new note
SetLength(Lines.Line[C].Note, Length(Lines.Line[C].Note)+1);
+ Inc(Lines.Line[C].HighNote);
// initialize note
Lines.Line[C].Note[N].Start := Note[Nu].Start;
Lines.Line[C].Note[N].Length := Note[Nu].Len;
Lines.Line[C].Note[N].Tone := Note[Nu].Tone;
- Lines.Line[C].Note[N].Text := Note[Nu].Lyric;
+ Lines.Line[C].Note[N].Text := DecodeStringUTF8(Note[Nu].Lyric, DEFAULT_ENCODING);
//All Notes are Freestyle when Converted Fix:
Lines.Line[C].Note[N].NoteType := ntNormal;
Inc(N);
end;
end;
-function TScreenEditConvert.SelectedNumber: integer;
+function TScreenEditConvert.CountSelectedTracks: integer;
var
T: integer; // track
begin
Result := 0;
- for T := 0 to High(ATrack) do
-// if ATrack[T].Hear then
-// Inc(Result);
- if Notes in ATrack[T].Status then
+ for T := 0 to High(Tracks) do
+ if tsNotes in Tracks[T].Status then
Inc(Result);
end;
{$IFDEF UseMIDIPort}
procedure TScreenEditConvert.MidiFile1MidiEvent(event: PMidiEvent);
begin
-// Log.LogStatus(IntToStr(event.event), 'MIDI');
- MidiOut.PutShort(event.event, event.data1, event.data2);
+ //Log.LogStatus(IntToStr(event.event), 'MIDI');
+ try
+ MidiOut.PutShort(event.event, event.data1, event.data2);
+ except
+ MidiFile.StopPlaying();
+ end;
end;
{$ENDIF}
@@ -443,7 +488,7 @@ begin
inherited Create;
AddButton(40, 20, 100, 40, Skin.GetTextureFileName('ButtonF'));
AddButtonText(15, 5, 0, 0, 0, 'Open');
-// Button[High(Button)].Text[0].Size := 11;
+ //Button[High(Button)].Text[0].Size := 11;
AddButton(160, 20, 100, 40, Skin.GetTextureFileName('ButtonF'));
AddButtonText(25, 5, 0, 0, 0, 'Play');
@@ -454,19 +499,7 @@ begin
AddButton(500, 20, 100, 40, Skin.GetTextureFileName('ButtonF'));
AddButtonText(20, 5, 0, 0, 0, 'Save');
-{ MidiOut := TMidiOutput.Create(nil);
-// MidiOut.Close;
-// MidiOut.DeviceID := 0;
- if Ini.Debug = 1 then
- MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table
- Log.LogStatus(MidiOut.ProductName, 'MIDI');
- MidiOut.Open;
-// MidiOut.SetVolume(100, 100); // temporary}
-
- ConversionFileName := GamePath + 'file.mid';
- {$IFDEF UseMIDIPort}
- MidiFile := TMidiFile.Create(nil);
- {$ENDIF}
+ ConversionFileName := 'D:/daten/africa.mid';//GamePath + 'file.mid';
for P := 0 to 100 do
begin
@@ -477,92 +510,84 @@ begin
end;
-procedure TScreenEditConvert.onShow;
+procedure TScreenEditConvert.OnShow;
var
T: integer; // track
N: integer; // note
- C: integer; // channel
- CN: integer; // channel note
begin
inherited;
{$IFDEF UseMIDIPort}
MidiOut := TMidiOutput.Create(nil);
- if Ini.Debug = 1 then
- MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table
- Log.LogStatus(MidiOut.ProductName, 'MIDI');
+ //if Ini.Debug = 1 then
+ // MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table
+ Log.LogInfo(MidiOut.ProductName, 'MIDI');
MidiOut.Open;
+ MidiFile := nil;
if FileExists(ConversionFileName) then
begin
+ MidiFile := TMidiFile.Create(nil);
MidiFile.Filename := ConversionFileName;
MidiFile.ReadFile;
Len := 0;
- Sel := 0;
+ SelTrack := 0;
BPM := MidiFile.Bpm;
Ticks := MidiFile.TicksPerQuarter / 4;
-{ for T := 0 to MidiFile.NumberOfTracks-1 do
+ SetLength(Tracks, MidiFile.NumberOfTracks);
+ for T := 0 to MidiFile.NumberOfTracks-1 do
begin
- SetLength(Track, Length(Track)+1);
MidiTrack := MidiFile.GetTrack(T);
- MidiTrack.OnMidiEvent := MidiFile1MidiEvent;
- Track[T].Name := MidiTrack.getName;
+ MidiTrack.OnMidiEvent := nil;
+ Tracks[T].Name := MidiTrack.getName;
+ Tracks[T].NoteType := ntNone;
+ Tracks[T].LyricType := [];
+ Tracks[T].Status := [];
+ SetLength(Tracks[T].Note, MidiTrack.getEventCount());
for N := 0 to MidiTrack.getEventCount-1 do
begin
- SetLength(Track[T].Note, Length(Track[T].Note)+1);
MidiEvent := MidiTrack.GetEvent(N);
- Track[T].Note[N].Start := MidiEvent.time;
- Track[T].Note[N].Len := MidiEvent.len;
- Track[T].Note[N].Event := MidiEvent.event;
- Track[T].Note[N].EventType := MidiEvent.event div 16;
- Track[T].Note[N].Channel := MidiEvent.event and 15;
- Track[T].Note[N].Data1 := MidiEvent.data1;
- Track[T].Note[N].Data2 := MidiEvent.data2;
- Track[T].Note[N].Str := MidiEvent.str;
-
- if Track[T].Note[N].Start + Track[T].Note[N].Len > Len then
- Len := Track[T].Note[N].Start + Track[T].Note[N].Len;
- end;
- end;}
- SetLength(Channel, 16);
- for T := 0 to 15 do
- begin
- Channel[T].Name := IntToStr(T+1);
- SetLength(Channel[T].Note, 0);
- Channel[T].Status := [];
- end;
+ Tracks[T].Note[N].Start := MidiEvent.time;
+ Tracks[T].Note[N].Len := MidiEvent.len;
+ Tracks[T].Note[N].Event := MidiEvent.event;
+ Tracks[T].Note[N].EventType := MidiEvent.event shr 4;
+ Tracks[T].Note[N].Channel := MidiEvent.event and $0F;
+ Tracks[T].Note[N].Data1 := MidiEvent.data1;
+ Tracks[T].Note[N].Data2 := MidiEvent.data2;
+ Tracks[T].Note[N].Str := MidiEvent.str;
- for T := 0 to MidiFile.NumberOfTracks-1 do
- begin
- MidiTrack := MidiFile.GetTrack(T);
- MidiTrack.OnMidiEvent := MidiFile1MidiEvent;
+ if (Tracks[T].Note[N].Event = MIDI_EVENT_META) then
+ begin
+ case (Tracks[T].Note[N].Data1) of
+ MIDI_META_TEXT: begin
+ if (Copy(Tracks[T].Note[N].Str, 1, 6) = '@KMIDI') then
+ begin
+ Tracks[T].LyricType := Tracks[T].LyricType + [ltKMIDI];
+ //Tracks[T].Status := [tsLyrics];
+ //DebugWriteln('Text: ' + Tracks[T].Note[N].Str);
+ end;
+ end;
+ MIDI_META_LYRICS: begin
+ // lyrics in Standard Midi File format found
+ Tracks[T].LyricType := Tracks[T].LyricType + [ltSMFLyric];
+ //Tracks[T].Status := [tsLyrics];
+ end;
+ end;
+ end
+ else if (Tracks[T].Note[N].EventType = MIDI_EVENTTYPE_NOTEON) then
+ begin
+ // notes available
+ Tracks[T].NoteType := ntAvail;
+ end;
- for N := 0 to MidiTrack.getEventCount-1 do
- begin
- MidiEvent := MidiTrack.GetEvent(N);
- C := MidiEvent.event and 15;
-
- CN := Length(Channel[C].Note);
- SetLength(Channel[C].Note, CN+1);
-
- Channel[C].Note[CN].Start := MidiEvent.time;
- Channel[C].Note[CN].Len := MidiEvent.len;
- Channel[C].Note[CN].Event := MidiEvent.event;
- Channel[C].Note[CN].EventType := MidiEvent.event div 16;
- Channel[C].Note[CN].Channel := MidiEvent.event and 15;
- Channel[C].Note[CN].Data1 := MidiEvent.data1;
- Channel[C].Note[CN].Data2 := MidiEvent.data2;
- Channel[C].Note[CN].Str := MidiEvent.str;
-
- if Channel[C].Note[CN].Start + Channel[C].Note[CN].Len > Len then
- Len := Channel[C].Note[CN].Start + Channel[C].Note[CN].Len;
+ if Tracks[T].Note[N].Start + Tracks[T].Note[N].Len > Len then
+ Len := Tracks[T].Note[N].Start + Tracks[T].Note[N].Len;
end;
end;
- ATrack := Channel;
end;
@@ -579,41 +604,44 @@ var
Y: real;
Height: real;
YSkip: real;
+ TrackName: UTF8String;
begin
// draw static menu
inherited Draw;
Y := 100;
- Height := min(480, 40 * Length(ATrack));
+ Height := min(480, 40 * Length(Tracks));
Bottom := Y + Height;
- if Length(ATrack) = 0 then // prevent crash with uncomplete code.
- begin
- Log.LogDebug ('UScreenEditConvert -> TScreenEditConvert.Draw:', 'Length(ATrack) = 0');
- YSkip := 40;
- end
- else
- YSkip := Height / Length(ATrack);
-
- // select
- DrawQuad(10, Y + Sel*YSkip, 780, YSkip, 0.8, 0.8, 0.8);
-
- // selected - now me use Status System
- for Count := 0 to High(ATrack) do
- if ATrack[Count].Hear then
+ YSkip := Height / Length(Tracks);
+
+ // highlight selected track
+ DrawQuad(10, Y+SelTrack*YSkip, 780, YSkip, 0.8, 0.8, 0.8);
+
+ // track-selection info
+ for Count := 0 to High(Tracks) do
+ if Tracks[Count].Status <> [] then
DrawQuad(10, Y + Count*YSkip, 50, YSkip, 0.8, 0.3, 0.3);
glColor3f(0, 0, 0);
- for Count := 0 to High(ATrack) do
+ for Count := 0 to High(Tracks) do
begin
- if Notes in ATrack[Count].Status then
+ if Tracks[Count].NoteType = ntAvail then
begin
+ if tsNotes in Tracks[Count].Status then
+ glColor3f(0, 0, 0)
+ else
+ glColor3f(0.7, 0.7, 0.7);
SetFontPos(25, Y + Count*YSkip + 10);
SetFontSize(15);
glPrint('N');
end;
- if Lyrics in ATrack[Count].Status then
+ if Tracks[Count].LyricType <> [] then
begin
+ if tsLyrics in Tracks[Count].Status then
+ glColor3f(0, 0, 0)
+ else
+ glColor3f(0.7, 0.7, 0.7);
SetFontPos(40, Y + Count*YSkip + 10);
SetFontSize(15);
glPrint('L');
@@ -624,36 +652,34 @@ begin
DrawLine( 60, Y, 60, Bottom, 0, 0, 0);
DrawLine(790, Y, 790, Bottom, 0, 0, 0);
- for Count := 0 to Length(ATrack) do
+ for Count := 0 to Length(Tracks) do
DrawLine(10, Y + Count*YSkip, 790, Y + Count*YSkip, 0, 0, 0);
- for Count := 0 to High(ATrack) do
+ for Count := 0 to High(Tracks) do
begin
- SetFontPos(11, Y + 10 + Count*YSkip);
+ // track names should be ASCII only, but who knows
+ TrackName := DecodeStringUTF8(Tracks[Count].Name, DEFAULT_ENCODING);
+
+ SetFontPos(65, Y + Count*YSkip);
SetFontSize(15);
- glPrint(ATrack[Count].Name);
+ glPrint(TrackName);
end;
- for Count := 0 to High(ATrack) do
- for Count2 := 0 to High(ATrack[Count].Note) do
+ for Count := 0 to High(Tracks) do
+ begin
+ for Count2 := 0 to High(Tracks[Count].Note) do
begin
- if ATrack[Count].Note[Count2].EventType = 9 then
- DrawQuad(60 + ATrack[Count].Note[Count2].Start/Len*725,
- Y + (Count+1)*YSkip - ATrack[Count].Note[Count2].Data1*35/127,
- 3,
- 3,
- ColR[Count],
- ColG[Count],
- ColB[Count]);
- if ATrack[Count].Note[Count2].EventType = 15 then
- DrawLine(60 + ATrack[Count].Note[Count2].Start/Len*725,
- Y + 0.75*YSkip + Count*YSkip,
- 60 + ATrack[Count].Note[Count2].Start/Len*725,
- Y + YSkip + Count*YSkip,
- ColR[Count],
- ColG[Count],
- ColB[Count]);
+ if Tracks[Count].Note[Count2].EventType = MIDI_EVENTTYPE_NOTEON then
+ DrawQuad(60 + Tracks[Count].Note[Count2].Start/Len * 725,
+ Y + (Count+1)*YSkip - Tracks[Count].Note[Count2].Data1*35/127,
+ 3, 3,
+ ColR[Count], ColG[Count], ColB[Count]);
+ if Tracks[Count].Note[Count2].EventType = 15 then
+ DrawLine(60 + Tracks[Count].Note[Count2].Start/Len * 725, Y + 0.75 * YSkip + Count*YSkip,
+ 60 + Tracks[Count].Note[Count2].Start/Len * 725, Y + YSkip + Count*YSkip,
+ ColR[Count], ColG[Count], ColB[Count]);
end;
+ end;
// playing line
{$IFDEF UseMIDIPort}
@@ -667,6 +693,7 @@ end;
procedure TScreenEditConvert.onHide;
begin
{$IFDEF UseMIDIPort}
+ MidiFile.Free;
MidiOut.Close;
MidiOut.Free;
{$ENDIF}
diff --git a/unicode/src/screens/UScreenEditHeader.pas b/unicode/src/screens/UScreenEditHeader.pas
index fed226ba..d57f69f7 100644
--- a/unicode/src/screens/UScreenEditHeader.pas
+++ b/unicode/src/screens/UScreenEditHeader.pas
@@ -106,10 +106,10 @@ begin
// check special keys
case PressedKey of
- SDLK_ESCAPE :
+ SDLK_ESCAPE:
begin
-// Music.PlayBack;
-// FadeTo(@MainScreen);
+ //Music.PlayBack;
+ //FadeTo(@MainScreen);
Result := false;
end;
@@ -117,7 +117,7 @@ begin
begin
if Interaction = 1 then
begin
-// Save;
+ //Save;
end;
end;