aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authorbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-12-23 13:22:39 +0000
committerbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-12-23 13:22:39 +0000
commit5ac30f3564337b76cc12b3e5750ee12a859a9767 (patch)
treed55205e26a68c7535941be348ada26b44d157889 /Game
parent3e561cd4fd1eb46590cb70aaf940f7775a855966 (diff)
downloadusdx-5ac30f3564337b76cc12b3e5750ee12a859a9767.tar.gz
usdx-5ac30f3564337b76cc12b3e5750ee12a859a9767.tar.xz
usdx-5ac30f3564337b76cc12b3e5750ee12a859a9767.zip
- bugfix: handling medley and preview flags in editor
- added voice pitch recording in editor (SHIFT+N and ALT+N) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2772 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/UDraw.pas99
-rw-r--r--Game/Code/Screens/UScreenEditSub.pas133
2 files changed, 184 insertions, 48 deletions
diff --git a/Game/Code/Classes/UDraw.pas b/Game/Code/Classes/UDraw.pas
index 11808614..78d92717 100644
--- a/Game/Code/Classes/UDraw.pas
+++ b/Game/Code/Classes/UDraw.pas
@@ -1918,6 +1918,8 @@ var
CP: integer;
end_: integer;
st: integer;
+ I: integer;
+ x, y: real;
begin
CP := NrCzesci;
if (Length(Czesci[CP].Czesc[Czesci[CP].Akt].Nuta)=0) then
@@ -1926,57 +1928,72 @@ begin
begin
st := Czesci[CP].Czesc[Czesci[CP].Akt].StartNote;
end_ := Czesci[CP].Czesc[Czesci[CP].Akt].Koniec;
- {if AktSong.isDuet and (Length(Czesci[(CP+1) mod 2].Czesc[Czesci[CP].Akt].Nuta)>0)then
- begin
- if (Czesci[(CP+1) mod 2].Czesc[Czesci[CP].Akt].Koniec > end_) then
- end_ := Czesci[(CP+1) mod 2].Czesc[Czesci[CP].Akt].Koniec;
+ end;
- if (Czesci[(CP+1) mod 2].Czesc[Czesci[CP].Akt].StartNote < st) then
- st := Czesci[(CP+1) mod 2].Czesc[Czesci[CP].Akt].StartNote;
- end;}
+ //glColor3f(1, 1, 1);
+ //glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ TempR := (Right-Left) / (end_ - st);
+
+ // Draw Pitches
+ if (Length(ScreenEditSub.Pitches)>0) then
+ begin
+ glColor4f(1, 0, 0, 0.6);
+
+ glLineWidth(NotesH*2);
+ glBegin(GL_LINE_STRIP);
+ for I := 0 to High(ScreenEditSub.Pitches) do
+ begin
+ if (ScreenEditSub.Pitches[I].beat>=st) and (ScreenEditSub.Pitches[I].beat<=end_) then
+ begin
+ x := (ScreenEditSub.Pitches[I].beat-st) * TempR + Left + 0.5 + 10*ScreenX;
+ y := Top - (ScreenEditSub.Pitches[I].pitch-Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt].BaseNote)*Space/2;
+ glVertex2f(x, y);
+ end;
+ end;
+ glEnd;
end;
glColor3f(1, 1, 1);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- TempR := (Right-Left) / (end_ - st);
with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt] do
begin
- for Pet := 0 to HighNut do begin
- with Nuta[Pet] do begin
-
- // Golden Note Patch
- if isMedley or isStartPreview then
- begin
- case Wartosc of
- 0: glColor4f(0, 1, 1, 0.45);
- 1: glColor4f(0, 1, 1, 0.85);
- 2: glColor4f(0, 1, 0.3, 0.85);
- end; // case
- end else
- begin
- case Wartosc of
- 0: glColor4f(0.8, 0.8, 0.8, 0.5); //freestyle
- 1: glColor4f(0.8, 0.8, 0.8, 0.9); //normal
- 2: glColor4f(1, 1, 0.3, 0.85); //golden (green)
- end; // case
- end;
-
-
+ for Pet := 0 to HighNut do
+ begin
+ with Nuta[Pet] do
+ begin
+ // Golden Note Patch
+ if isMedley or isStartPreview then
+ begin
+ case Wartosc of
+ 0: glColor4f(0, 1, 1, 0.45);
+ 1: glColor4f(0, 1, 1, 0.85);
+ 2: glColor4f(0, 1, 0.3, 0.85);
+ end; // case
+ end else
+ begin
+ case Wartosc of
+ 0: glColor4f(0.8, 0.8, 0.8, 0.5); //freestyle
+ 1: glColor4f(0.8, 0.8, 0.8, 0.9); //normal
+ 2: glColor4f(1, 1, 0.3, 0.85); //golden (green)
+ end; // case
+ end;
- // lewa czesc - left part
- Rec.Left := (Start-st) * TempR + Left + 0.5 + 10*ScreenX;
- Rec.Right := Rec.Left + NotesW;
- Rec.Top := Top - (Ton-BaseNote)*Space/2 - NotesH;
- Rec.Bottom := Rec.Top + 2 * NotesH;
- glBindTexture(GL_TEXTURE_2D, Tex_Left[Color].TexNum);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
- glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
- glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
- glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
- glEnd;
+ // lewa czesc - left part
+ Rec.Left := (Start-st) * TempR + Left + 0.5 + 10*ScreenX;
+ Rec.Right := Rec.Left + NotesW;
+ Rec.Top := Top - (Ton-BaseNote)*Space/2 - NotesH;
+ Rec.Bottom := Rec.Top + 2 * NotesH;
+ glBindTexture(GL_TEXTURE_2D, Tex_Left[Color].TexNum);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
+ glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
+ glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
+ glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
+ glEnd;
// srodkowa czesc - middle part
Rec.Left := Rec.Right;
diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas
index be058408..941a6a1b 100644
--- a/Game/Code/Screens/UScreenEditSub.pas
+++ b/Game/Code/Screens/UScreenEditSub.pas
@@ -23,8 +23,15 @@ type
isEnd: boolean; //end beat is declared
end;
+ TVoicePitch = record
+ beat: integer;
+ pitch: integer;
+ end;
+
TScreenEditSub = class(TMenu)
private
+ PitchRecOn: boolean;
+
cRB, cGB, cBB: GLfloat;
cRR, cGR, cBR: GLfloat;
@@ -91,7 +98,7 @@ type
ActTonePitch: integer;
- procedure DrawPitch(x, y, Width, Height: single);
+ procedure DrawPitch(x, y, Width, Height: single; beat: integer);
procedure StartVideo;
procedure StartVideoPreview;
procedure NewBeat;
@@ -129,6 +136,7 @@ type
procedure CopyLine(Pf, Cf, Pt, Ct: integer);
procedure Refresh;
public
+ Pitches: array of TVoicePitch;
Tex_Background: TTexture;
FadeOut: boolean;
Path: string;
@@ -175,6 +183,7 @@ begin
+ KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS});
If (PressedDown) then begin // Key Down
+ PitchRecOn := false;
case PressedKey of
SDLK_TAB:
begin
@@ -587,9 +596,11 @@ begin
begin
if (CP = MedleyNotes.Preview.CP) and
(Czesci[CP].Akt = MedleyNotes.Preview.line) and
- (AktNuta[CP] = MedleyNotes.Preview.note) then //reset ?
+ (AktNuta[CP] = MedleyNotes.Preview.note) and
+ Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[CP]].IsStartPreview then //reset
begin
-
+ Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[CP]].IsStartPreview := false;
+ AktSong.PreviewStart := 0;
end else //set
begin
if (Length(Czesci[MedleyNotes.Preview.CP].Czesc[MedleyNotes.Preview.line].Nuta)>MedleyNotes.Preview.note) then
@@ -639,8 +650,70 @@ begin
SDLK_N:
begin
- // Set actual note over pitch detection
- Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[0]].Ton := ActTonePitch;
+ if (SDL_ModState = KMOD_LSHIFT) then
+ begin
+ // one line, mp3
+ MidiOut.PutShort($81, Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[MidiLastNote].Ton + 60, 127);
+ PlaySentenceMidi := false;
+ PlayOneNoteMidi := false;
+ PlayOneSentence := true;
+ Click := false;
+ Music.Stop;
+ R := GetTimeFromBeat(Czesci[CP].Czesc[Czesci[CP].Akt].StartNote);
+ if R <= Music.Length then
+ begin
+ Music.MoveTo(R);
+ PlayStopTime := GetTimeFromBeat(Czesci[CP].Czesc[Czesci[CP].Akt].Koniec)+
+ Ini.LipSync*0.01 + (120 + Ini.Delay*10) / 1000;
+ PlaySentence := true;
+ PlayOneNote := false;
+ Music.Play;
+ LastClick := -100;
+ end;
+ end;
+
+ if (SDL_ModState = KMOD_LALT) then
+ begin
+ // Play whole file
+ MidiOut.PutShort($81, Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[MidiLastNote].Ton + 60, 127);
+ PlaySentenceMidi := false;
+ PlayOneNoteMidi := false;
+ Click := false;
+ Music.Stop;
+ R := GetTimeFromBeat(Czesci[CP].Czesc[Czesci[CP].Akt].StartNote);
+ if R <= Music.Length then
+ begin
+ Music.MoveTo(R);
+ PlayStopTime := Music.Length;
+ PlaySentence := true;
+ PlayOneSentence := false;
+ PlayOneNote := false;
+ Music.Play;
+ LastClick := -100;
+ end;
+ end;
+
+ if PlaySentence then
+ begin
+ SetLength(Pitches, 0);
+ PitchRecOn := true;
+ noteStart := AktNuta[CP];
+ lineStart := Czesci[CP].Akt;
+ cpStart := CP;
+ Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[CP]].Color := 0;
+ AktNuta[CP] := 0;
+ Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[CP]].Color := 2;
+ EditorLyric[CP].Selected := AktNuta[CP];
+ LineChanged[0]:=false;
+ LineChanged[1]:=false;
+ PlayVideo := false;
+ end;
+
+ if (SDL_ModState = 0) then
+ begin
+ // Set actual note over pitch detection
+ Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[0]].Ton := ActTonePitch;
+ end;
end;
SDLK_C:
@@ -1457,7 +1530,7 @@ begin
end;
end;
-procedure TScreenEditSub.DrawPitch(x, y, Width, Height: single);
+procedure TScreenEditSub.DrawPitch(x, y, Width, Height: single; beat: integer);
var
x1, y1, x2, y2: single;
i: integer;
@@ -1547,6 +1620,21 @@ begin
SetFontPos(x-ToneStringWidth-ToneStringCenterXOffset, y-ToneStringHeight/2);
glColor3f(0, 0, 0);
glPrint(PChar(ToneString));
+
+ // rec pitches
+ if not PitchRecOn then
+ Exit;
+
+ i := High(Pitches);
+ beat := Floor(GetMidBeat(GetTimeFromBeat(beat) - Ini.LipSync*0.01 - (AktSong.Gap + 120 + Ini.Delay*10) / 1000));
+
+ if (i = -1) or (Pitches[i].beat<beat) then
+ begin
+ SetLength(Pitches, i+2);
+ Pitches[i+1].beat := beat;
+ Pitches[i+1].pitch := ActTonePitch;
+ end;
+
end;
@@ -2589,6 +2677,17 @@ var
begin
FixTimings;
LyricsCorrectSpaces;
+
+ if MedleyNotes.isStart and
+ ((High(Czesci[0].Czesc)<MedleyNotes.start.line) or
+ (High(Czesci[0].Czesc[MedleyNotes.start.line].Nuta)<MedleyNotes.start.note)) then
+ MedleyNotes.isStart := false;
+
+ if MedleyNotes.isEnd and
+ ((High(Czesci[0].Czesc)<MedleyNotes.end_.line) or
+ (High(Czesci[0].Czesc[MedleyNotes.end_.line].Nuta)<MedleyNotes.end_.note)) then
+ MedleyNotes.isEnd := false;
+
for P := 0 to Length(Czesci) - 1 do
begin
Czesci[P].Ilosc := Length(Czesci[P].Czesc);
@@ -2610,6 +2709,16 @@ begin
for N := 0 to Length(Czesci[P].Czesc[L].Nuta) - 1 do
begin
Nuta[N].Color := 0;
+ if (MedleyNotes.isStart and (MedleyNotes.start.CP = P) and (MedleyNotes.start.line = L) and
+ (MedleyNotes.start.note = N)) or
+ (MedleyNotes.isEnd and (MedleyNotes.end_.CP = P) and (MedleyNotes.end_.line = L) and
+ (MedleyNotes.end_.note = N)) then
+ Nuta[N].IsMedley := true
+ else
+ Nuta[N].IsMedley := false;
+
+ Nuta[N].IsStartPreview := false;
+
Czesci[P].Wartosc := Czesci[P].Wartosc + Nuta[N].Dlugosc * Nuta[N].Wartosc;
TotalNotes := TotalNotes + Nuta[N].Dlugosc * Nuta[N].Wartosc;
@@ -2621,6 +2730,12 @@ begin
end;
end;
end;
+
+ //set Preview Start
+ MedleyNotes.Preview := FindNote(round(GetMidBeat(AktSong.PreviewStart-AktSong.Gap/1000)));
+ Czesci[MedleyNotes.Preview.CP].Czesc[MedleyNotes.Preview.line].Nuta[MedleyNotes.Preview.note].IsStartPreview := true;
+ AktSong.PreviewStart :=
+ GetTimeFromBeat(Czesci[MedleyNotes.Preview.CP].Czesc[MedleyNotes.Preview.line].Nuta[MedleyNotes.Preview.note].start);
end;
procedure TScreenEditSub.onShow;
@@ -2654,6 +2769,9 @@ begin
MidiOut := TMidiOutput.Create(nil);
MidiOut.Open;
+ SetLength(Pitches, 0);
+ PitchRecOn := false;
+
//Set Volume
MP3Volume := 50;
Music.SetMusicVolume(MP3Volume);
@@ -2886,6 +3004,7 @@ begin
begin
Music.Stop;
PlaySentence := false;
+ PitchRecOn := false;
Czesci[CP].Czesc[Czesci[CP].Akt].Nuta[AktNuta[CP]].Color := 0;
if (Czesci[CP].Akt = lineStart) then
AktNuta[CP] := noteStart;
@@ -3204,7 +3323,7 @@ begin
end;
end else
begin
- DrawPitch(400, 75, 390, 15);
+ DrawPitch(400, 75, 390, 15, AktBeat);
StartVideoPreview;
end;
end;