added medley calculation
This commit is contained in:
1 parent
1269af7897
commit
830875d24e
5 files changed
+124
-30
No files matched your search
@@ -113,6 +113,8 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public const float DefaultMedleyFadeInTime = 8f;
|
public const float DefaultMedleyFadeInTime = 8f;
|
||||||
public const float DefaultMedleyFadeOutTIme = 2f;
|
public const float DefaultMedleyFadeOutTIme = 2f;
|
||||||
|
public const int MedleyMinSeriesLength = 3;
|
||||||
|
public const float MedleyMinDuration = 40f;
|
||||||
|
|
||||||
public static bool TabNavigation = false;
|
public static bool TabNavigation = false;
|
||||||
|
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
set { _PerfectLine = value; }
|
set { _PerfectLine = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int FirstBeat
|
public int FirstNoteBeat
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -312,7 +312,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int LastBeat
|
public int LastNoteBeat
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -509,15 +509,15 @@ namespace Vocaluxe.Lib.Song
|
|||||||
int startbeat = int.MaxValue;
|
int startbeat = int.MaxValue;
|
||||||
for (int i = 0; i < _Lines.Count; i++)
|
for (int i = 0; i < _Lines.Count; i++)
|
||||||
{
|
{
|
||||||
if (_Lines[i].FirstBeat < startbeat)
|
if (_Lines[i].FirstNoteBeat < startbeat)
|
||||||
startbeat = _Lines[i].FirstBeat;
|
startbeat = _Lines[i].FirstNoteBeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
int endbeat = int.MinValue;
|
int endbeat = int.MinValue;
|
||||||
for (int i = 0; i < _Lines.Count; i++)
|
for (int i = 0; i < _Lines.Count; i++)
|
||||||
{
|
{
|
||||||
if (_Lines[i].LastBeat < endbeat)
|
if (_Lines[i].LastNoteBeat < endbeat)
|
||||||
endbeat = _Lines[i].LastBeat;
|
endbeat = _Lines[i].LastNoteBeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = endbeat - startbeat;
|
int result = endbeat - startbeat;
|
||||||
|
|||||||
@@ -635,6 +635,13 @@ namespace Vocaluxe.Lib.Song
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct Series
|
||||||
|
{
|
||||||
|
public int start;
|
||||||
|
public int end;
|
||||||
|
public int length;
|
||||||
|
}
|
||||||
|
|
||||||
private void FindRefrain()
|
private void FindRefrain()
|
||||||
{
|
{
|
||||||
if (this.Medley.Source == EMedleySource.Tag)
|
if (this.Medley.Source == EMedleySource.Tag)
|
||||||
@@ -643,9 +650,94 @@ namespace Vocaluxe.Lib.Song
|
|||||||
if (!this.CalculateMedley)
|
if (!this.CalculateMedley)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CLines lines = this.Notes.GetLines(0);
|
||||||
|
|
||||||
|
if (lines.LineCount == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// build sentences list
|
||||||
|
List<string> sentences = new List<string>();
|
||||||
|
foreach (CLine line in lines.Line)
|
||||||
|
{
|
||||||
|
if (line.Points != 0)
|
||||||
|
sentences.Add(line.Lyrics);
|
||||||
|
else
|
||||||
|
sentences.Add(String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
// find equal sentences series
|
||||||
|
List<Series> series = new List<Series>();
|
||||||
|
for (int i = 0; i < lines.LineCount - 1; i++)
|
||||||
|
{
|
||||||
|
for (int j = i + 1; j < lines.LineCount; j++)
|
||||||
|
{
|
||||||
|
if (sentences[i] == sentences[j] && sentences[i] != String.Empty)
|
||||||
|
{
|
||||||
|
Series tempSeries = new Series();
|
||||||
|
tempSeries.start = i;
|
||||||
|
tempSeries.end = i;
|
||||||
|
|
||||||
|
int max = 0;
|
||||||
|
if (j + j - i - 1 > lines.LineCount - 1)
|
||||||
|
max = lines.LineCount - 1 - j;
|
||||||
|
else
|
||||||
|
max = j - i - 1;
|
||||||
|
|
||||||
|
for (int k = 1; k <= max; k++)
|
||||||
|
{
|
||||||
|
if (sentences[i + k] == sentences[j + k] && sentences[i + k] != String.Empty)
|
||||||
|
tempSeries.end = i + k;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempSeries.length = tempSeries.end - tempSeries.start + 1;
|
||||||
|
series.Add(tempSeries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// search for longest series
|
||||||
|
int longest = 0;
|
||||||
|
for (int i = 0; i < series.Count; i++)
|
||||||
|
{
|
||||||
|
if (series[i].length > series[longest].length)
|
||||||
|
longest = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set medley vars
|
||||||
|
if (series.Count > 0 && series[longest].length > CSettings.MedleyMinSeriesLength)
|
||||||
|
{
|
||||||
|
this.Medley.StartBeat = lines.Line[series[longest].start].FirstNoteBeat;
|
||||||
|
this.Medley.EndBeat = lines.Line[series[longest].end].LastNoteBeat;
|
||||||
|
|
||||||
|
bool foundEnd = false;
|
||||||
|
|
||||||
|
// set end if duration > MedleyMinDuration
|
||||||
|
if (CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + CSettings.MedleyMinDuration >
|
||||||
|
CGame.GetTimeFromBeats(this.Medley.EndBeat, this.BPM))
|
||||||
|
foundEnd = true;
|
||||||
|
|
||||||
|
if (!foundEnd)
|
||||||
|
{
|
||||||
|
for (int i = series[longest].start + 1; i < lines.LineCount - 1; i++)
|
||||||
|
{
|
||||||
|
if (CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + CSettings.MedleyMinDuration >
|
||||||
|
CGame.GetTimeFromBeats(lines.Line[i].LastNoteBeat, this.BPM))
|
||||||
|
{
|
||||||
|
foundEnd = true;
|
||||||
|
this.Medley.EndBeat = lines.Line[i].LastNoteBeat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundEnd)
|
||||||
|
{
|
||||||
|
this.Medley.Source = EMedleySource.Calculated;
|
||||||
|
this.Medley.FadeInTime = CSettings.DefaultMedleyFadeInTime;
|
||||||
|
this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTIme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.PreviewStart == 0f)
|
if (this.PreviewStart == 0f)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ namespace Vocaluxe.Menu.SingNotes
|
|||||||
float h = _PlayerNotes[n].Rect.H;
|
float h = _PlayerNotes[n].Rect.H;
|
||||||
float dh = h / CSettings.NumNoteLines * (2f - (int)CGame.Player[_PlayerNotes[n].PlayerNr].Difficulty) / 4f;
|
float dh = h / CSettings.NumNoteLines * (2f - (int)CGame.Player[_PlayerNotes[n].PlayerNr].Difficulty) / 4f;
|
||||||
|
|
||||||
float beats = Line.LastBeat - Line.FirstBeat + 1;
|
float beats = Line.LastNoteBeat - Line.FirstNoteBeat + 1;
|
||||||
|
|
||||||
if (beats == 0)
|
if (beats == 0)
|
||||||
return;
|
return;
|
||||||
@@ -324,7 +324,7 @@ namespace Vocaluxe.Menu.SingNotes
|
|||||||
float width = note.Duration / beats * w;
|
float width = note.Duration / beats * w;
|
||||||
|
|
||||||
SRectF rect = new SRectF(
|
SRectF rect = new SRectF(
|
||||||
_PlayerNotes[n].Rect.X + (note.StartBeat - Line.FirstBeat) / beats * w,
|
_PlayerNotes[n].Rect.X + (note.StartBeat - Line.FirstNoteBeat) / beats * w,
|
||||||
_PlayerNotes[n].Rect.Y + (CSettings.NumNoteLines - 1 - (note.Tone - BaseLine)/2) / CSettings.NumNoteLines * h - dh,
|
_PlayerNotes[n].Rect.Y + (CSettings.NumNoteLines - 1 - (note.Tone - BaseLine)/2) / CSettings.NumNoteLines * h - dh,
|
||||||
width,
|
width,
|
||||||
h / CSettings.NumNoteLines + 2 * dh,
|
h / CSettings.NumNoteLines + 2 * dh,
|
||||||
@@ -344,7 +344,7 @@ namespace Vocaluxe.Menu.SingNotes
|
|||||||
|
|
||||||
if (CConfig.DrawToneHelper == EOffOn.TR_CONFIG_ON)
|
if (CConfig.DrawToneHelper == EOffOn.TR_CONFIG_ON)
|
||||||
{
|
{
|
||||||
DrawToneHelper(n, (int)BaseLine, (CGame.MidBeatD - Line.FirstBeat) / beats * w);
|
DrawToneHelper(n, (int)BaseLine, (CGame.MidBeatD - Line.FirstNoteBeat) / beats * w);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -377,7 +377,7 @@ namespace Vocaluxe.Menu.SingNotes
|
|||||||
|
|
||||||
foreach (CNote note in SingLine[CGame.Player[Player].CurrentLine].Notes)
|
foreach (CNote note in SingLine[CGame.Player[Player].CurrentLine].Notes)
|
||||||
{
|
{
|
||||||
if (note.StartBeat >= Line.FirstBeat && note.EndBeat <= Line.LastBeat)
|
if (note.StartBeat >= Line.FirstNoteBeat && note.EndBeat <= Line.LastNoteBeat)
|
||||||
{
|
{
|
||||||
float width = note.Duration / beats * w;
|
float width = note.Duration / beats * w;
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ namespace Vocaluxe.Menu.SingNotes
|
|||||||
width -= (1 - (CGame.MidBeatD - CGame.ActBeatD)) / beats * w;
|
width -= (1 - (CGame.MidBeatD - CGame.ActBeatD)) / beats * w;
|
||||||
|
|
||||||
SRectF rect = new SRectF(
|
SRectF rect = new SRectF(
|
||||||
_PlayerNotes[n].Rect.X + (note.StartBeat - Line.FirstBeat) / beats * w,
|
_PlayerNotes[n].Rect.X + (note.StartBeat - Line.FirstNoteBeat) / beats * w,
|
||||||
_PlayerNotes[n].Rect.Y + (CSettings.NumNoteLines - 1 - (note.Tone - BaseLine)/2) / CSettings.NumNoteLines * h - dh,
|
_PlayerNotes[n].Rect.Y + (CSettings.NumNoteLines - 1 - (note.Tone - BaseLine)/2) / CSettings.NumNoteLines * h - dh,
|
||||||
width,
|
width,
|
||||||
h / CSettings.NumNoteLines + 2 * dh,
|
h / CSettings.NumNoteLines + 2 * dh,
|
||||||
|
|||||||
@@ -588,7 +588,7 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
if (line[j].StartBeat <= _CurrentBeat)
|
if (line[j].StartBeat <= _CurrentBeat)
|
||||||
{
|
{
|
||||||
if (CGame.GetTimeFromBeats(line[j].FirstBeat, song.BPM) <= _CurrentTime - song.Gap + 10f)
|
if (CGame.GetTimeFromBeats(line[j].FirstNoteBeat, song.BPM) <= _CurrentTime - song.Gap + 10f)
|
||||||
{
|
{
|
||||||
nr = j;
|
nr = j;
|
||||||
}
|
}
|
||||||
@@ -607,8 +607,8 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
Lyrics[htLyrics(LyricMain)].SetLine(line[nr]);
|
Lyrics[htLyrics(LyricMain)].SetLine(line[nr]);
|
||||||
Lyrics[htLyrics(LyricMainTop)].SetLine(line[nr]);
|
Lyrics[htLyrics(LyricMainTop)].SetLine(line[nr]);
|
||||||
_TimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstBeat - line[nr].StartBeat, song.BPM);
|
_TimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - line[nr].StartBeat, song.BPM);
|
||||||
_RemainingTimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);
|
_RemainingTimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);
|
||||||
|
|
||||||
if (line.Length >= nr + 2)
|
if (line.Length >= nr + 2)
|
||||||
{
|
{
|
||||||
@@ -624,8 +624,8 @@ namespace Vocaluxe.Screens
|
|||||||
if (i == 0 && song.IsDuet)
|
if (i == 0 && song.IsDuet)
|
||||||
{
|
{
|
||||||
Lyrics[htLyrics(LyricMainDuet)].SetLine(line[nr]);
|
Lyrics[htLyrics(LyricMainDuet)].SetLine(line[nr]);
|
||||||
_TimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstBeat - line[nr].StartBeat, song.BPM);
|
_TimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - line[nr].StartBeat, song.BPM);
|
||||||
_RemainingTimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);
|
_RemainingTimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);
|
||||||
|
|
||||||
if (line.Length >= nr + 2)
|
if (line.Length >= nr + 2)
|
||||||
Lyrics[htLyrics(LyricSubDuet)].SetLine(line[nr + 1]);
|
Lyrics[htLyrics(LyricSubDuet)].SetLine(line[nr + 1]);
|
||||||
@@ -857,7 +857,7 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
if (line[j].StartBeat <= _CurrentBeat)
|
if (line[j].StartBeat <= _CurrentBeat)
|
||||||
{
|
{
|
||||||
if (CGame.GetTimeFromBeats(line[j].FirstBeat, Song.BPM) <= _CurrentTime - Song.Gap + 10f)
|
if (CGame.GetTimeFromBeats(line[j].FirstNoteBeat, Song.BPM) <= _CurrentTime - Song.Gap + 10f)
|
||||||
{
|
{
|
||||||
CurrentLineSub = j;
|
CurrentLineSub = j;
|
||||||
}
|
}
|
||||||
@@ -868,7 +868,7 @@ namespace Vocaluxe.Screens
|
|||||||
int CurrentLine = 0;
|
int CurrentLine = 0;
|
||||||
for (int j = 0; j < line.Length; j++)
|
for (int j = 0; j < line.Length; j++)
|
||||||
{
|
{
|
||||||
if (line[j].FirstBeat <= _CurrentBeat)
|
if (line[j].FirstNoteBeat <= _CurrentBeat)
|
||||||
{
|
{
|
||||||
CurrentLine = j;
|
CurrentLine = j;
|
||||||
}
|
}
|
||||||
@@ -879,33 +879,33 @@ namespace Vocaluxe.Screens
|
|||||||
Alpha[i * 2 + 1] = 1f;
|
Alpha[i * 2 + 1] = 1f;
|
||||||
|
|
||||||
// main line alpha
|
// main line alpha
|
||||||
if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM))
|
if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstNoteBeat, Song.BPM))
|
||||||
{
|
{
|
||||||
// first main line and fist note is not reached
|
// first main line and fist note is not reached
|
||||||
// => fade in
|
// => fade in
|
||||||
float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM) - CurrentTime;
|
float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstNoteBeat, Song.BPM) - CurrentTime;
|
||||||
if (diff > dt)
|
if (diff > dt)
|
||||||
{
|
{
|
||||||
Alpha[i * 2] = 1f - (diff - dt) / rt;
|
Alpha[i * 2] = 1f - (diff - dt) / rt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime &&
|
else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM) < CurrentTime &&
|
||||||
CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) > CurrentTime)
|
CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstNoteBeat, Song.BPM) > CurrentTime)
|
||||||
{
|
{
|
||||||
// current position is between two lines
|
// current position is between two lines
|
||||||
|
|
||||||
// time between the to lines
|
// time between the to lines
|
||||||
float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) -
|
float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstNoteBeat, Song.BPM) -
|
||||||
CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
|
CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM);
|
||||||
|
|
||||||
// fade only if there is enough time for fading
|
// fade only if there is enough time for fading
|
||||||
if (diff > 3.3f * dt)
|
if (diff > 3.3f * dt)
|
||||||
{
|
{
|
||||||
// time elapsed since last line
|
// time elapsed since last line
|
||||||
float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
|
float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM);
|
||||||
|
|
||||||
// time to next line
|
// time to next line
|
||||||
float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime;
|
float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstNoteBeat, Song.BPM) - CurrentTime;
|
||||||
|
|
||||||
if (last < next)
|
if (last < next)
|
||||||
{
|
{
|
||||||
@@ -920,11 +920,11 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime)
|
else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM) < CurrentTime)
|
||||||
{
|
{
|
||||||
// last main line and last note was reached
|
// last main line and last note was reached
|
||||||
// => fade out
|
// => fade out
|
||||||
float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
|
float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM);
|
||||||
Alpha[i * 2] = 1f - diff / rt;
|
Alpha[i * 2] = 1f - diff / rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,7 +932,7 @@ namespace Vocaluxe.Screens
|
|||||||
if (CurrentLineSub < line.Length - 2)
|
if (CurrentLineSub < line.Length - 2)
|
||||||
{
|
{
|
||||||
float diff = 0f;
|
float diff = 0f;
|
||||||
diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstBeat, Song.BPM) - CurrentTime;
|
diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstNoteBeat, Song.BPM) - CurrentTime;
|
||||||
|
|
||||||
if (diff > dt)
|
if (diff > dt)
|
||||||
{
|
{
|
||||||
@@ -1088,7 +1088,7 @@ namespace Vocaluxe.Screens
|
|||||||
CLine[] Line = Lines[i].Line;
|
CLine[] Line = Lines[i].Line;
|
||||||
for(int j = 0; j<Line.Length; j++){
|
for(int j = 0; j<Line.Length; j++){
|
||||||
TimeRect trect = new TimeRect();
|
TimeRect trect = new TimeRect();
|
||||||
trect.startBeat = Line[j].FirstBeat;
|
trect.startBeat = Line[j].FirstNoteBeat;
|
||||||
trect.endBeat = Line[j].EndBeat;
|
trect.endBeat = Line[j].EndBeat;
|
||||||
|
|
||||||
trect.rect = new CStatic(new STexture(-1),
|
trect.rect = new CStatic(new STexture(-1),
|
||||||
|
|||||||
Reference in new issue
Block a user