From 1a644ab22c3ef3dcd7db9813350ae08445bdd868 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 21 Feb 2013 13:05:49 +0100 Subject: [PATCH] Added Mic delay in calculation of line breaks Added config entry for minimal time before text is show --- .gitignore | 30 ++++++++++++++++ Vocaluxe/Base/CConfig.cs | 2 ++ Vocaluxe/Screens/CScreenSing.cs | 52 +++++++++++++++------------- VocaluxeLib/Menu/SingNotes/CNotes.cs | 2 +- 4 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..dc52224f --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +obj +Output/Songs +*.mp4 +*.pdb +/Output/Benchmark.log + +/Output/CoverDB.sqlite + +/Output/HighscoreDB.sqlite + +/Output/PartyModes/*/Code/* + +/Output/Vocaluxe.exe* + +/Output/Vocaluxe.vshost.exe* + +/Output/VocaluxeLib.dll + +*.psess + +/*.vsp + +/*.ctl + +/Output/Registration.xml + +/Vocaluxe.suo +/Vocaluxe/Vocaluxe.csproj.user + +/Output/Config.xml diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index c53b827c..3793df6c 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -80,6 +80,8 @@ namespace Vocaluxe.Base public static string Language = "English"; public static EOffOn LyricsOnTop = EOffOn.TR_CONFIG_OFF; public static string[] Players = new string[CSettings.MaxNumPlayer]; + + public static float MinLineBreakTime = 0.1f; //Minimum time to show the text before it is (to be) sung (if possible) // Video public static EVideoDecoder VideoDecoder = EVideoDecoder.FFmpeg; diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index b1775d87..64a6edd4 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -738,6 +738,30 @@ namespace Vocaluxe.Screens CWebcam.Close(); } + private int FindCurrentLine(CLine[] line, CSong song) + { + float CurrentTime = _CurrentTime - song.Gap; + //We are only interested in the last matching line, so either do not check further after line[j].StartBeat > _CurrentBeat or go backwards! + for (int j = line.Length - 1; j >= 0; j--) + { + if (line[j].StartBeat <= _CurrentBeat) + { + float FirstNoteTime = CGame.GetTimeFromBeats(line[j].FirstNoteBeat, song.BPM); + //Earlist possible line break is 10s before first note + if (FirstNoteTime <= CurrentTime + 10f) + { + //First line has no predecessor or line has to be shown + if(j == 0 || FirstNoteTime - CConfig.MinLineBreakTime <= CurrentTime) return j; + float LastNoteTime = CGame.GetTimeFromBeats(line[j-1].LastNoteBeat, song.BPM); + //No line break if last line is not fully evaluated (with 50% tolerance -> tested so notes are drawn) + if(LastNoteTime + CConfig.MicDelay/1000f * 1.5f >= CurrentTime) return j-1; + return j; + } + } + } + return -1; + } + private void UpdateLyrics() { if (_FadeOut) @@ -759,18 +783,8 @@ namespace Vocaluxe.Screens lines[i] = song.Notes.GetLines(i); CLine[] line = lines[i].Line; - // find current line (it must be the same as in CalcFadingAlpha) - int nr = -1; - for (int j = 0; j < line.Length; j++) - { - if (line[j].StartBeat <= _CurrentBeat) - { - if (CGame.GetTimeFromBeats(line[j].FirstNoteBeat, song.BPM) <= _CurrentTime - song.Gap + 10f) - { - nr = j; - } - } - } + // find current line + int nr = FindCurrentLine(line, song); if (nr != -1) { @@ -1048,18 +1062,8 @@ namespace Vocaluxe.Screens lines[i] = Song.Notes.GetLines(i); CLine[] line = lines[i].Line; - // find current line for lyric sub fading (it must be the same as in UpdateLyrics) - int CurrentLineSub = 0; - for (int j = 0; j < line.Length; j++) - { - if (line[j].StartBeat <= _CurrentBeat) - { - if (CGame.GetTimeFromBeats(line[j].FirstNoteBeat, Song.BPM) <= _CurrentTime - Song.Gap + 10f) - { - CurrentLineSub = j; - } - } - } + // find current line for lyric sub fading + int CurrentLineSub = FindCurrentLine(line, Song); // find current line for lyric main fading int CurrentLine = 0; diff --git a/VocaluxeLib/Menu/SingNotes/CNotes.cs b/VocaluxeLib/Menu/SingNotes/CNotes.cs index dfda1ee0..74f008df 100644 --- a/VocaluxeLib/Menu/SingNotes/CNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CNotes.cs @@ -636,7 +636,7 @@ namespace Vocaluxe.Menu.SingNotes #region Methods public void AddLine(CLine Line) { - AddLine(Line, true); + AddLine(Line, false); } public void AddLine(CLine Line, bool updateTimings) {