From 5ac30f3564337b76cc12b3e5750ee12a859a9767 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Thu, 23 Dec 2010 13:22:39 +0000 Subject: - 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 --- Game/Code/Classes/UDraw.pas | 99 +++++++++++++++----------- Game/Code/Screens/UScreenEditSub.pas | 133 +++++++++++++++++++++++++++++++++-- 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