public CLines(CLines lines) { foreach (CLine line in lines._Lines) { _Lines.Add(new CLine(line)); } }
public bool ReplaceLinesAt(int Index, CLines Lines) { if (Index >= _Lines.Count) return false; _Lines[Index] = Lines; return true; }
public bool ReplaceLinesAt(int Index, CLines Lines) { if (Index >= _Lines.Count) { return(false); } _Lines[Index] = Lines; return(true); }
private void NewSentence(int Player, int Start) { CLines lines = Notes.GetLines(Player); CLine line = new CLine(); line.StartBeat = Start; if (lines.LineCount == 0) { lines.AddLine(line); } else { lines.AddLine(line); } }
private void ParseNote(int Player, ENoteType NoteType, int Start, int Length, int Tone, string Text) { CNote note = new CNote(Start, Length, Tone, Text, NoteType); CLines lines = this.Notes.GetLines(Player); if (lines.LineCount == 0) { CLine line = new CLine(); line.AddNote(note); lines.AddLine(line, false); } else { lines.AddNote(note, lines.LineCount - 1, false); } }
public void AddLines(CLines Lines) { _Lines.Add(Lines); }
public bool ReplaceLinesAt(int Index, CLines Lines) { if (Index >= _Lines.Count) return false; CLines lines = new CLines(); lines = Lines; _Lines[Index] = lines; return true; }
private void FindRefrain() { if (this.IsDuet) { this.Medley.Source = EMedleySource.None; return; } if (this.Medley.Source == EMedleySource.Tag) { return; } if (!this.CalculateMedley) { 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.Medley.Source == EMedleySource.Calculated) { this.PreviewStart = CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM); } } }
private void FindShortEnd() { 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); } } } //Calculate length of singing int stop = (lines.Line[lines.Line.Length - 1].LastNoteBeat - lines.Line[0].FirstNoteBeat) / 2; //Check if stop is in series for (int i = 0; i < series.Count; i++) { if (lines.Line[series[i].start].FirstNoteBeat <stop && lines.Line[series[i].end].LastNoteBeat> stop) { if (stop < (lines.Line[series[i].start].FirstNoteBeat + ((lines.Line[series[i].end].LastNoteBeat - lines.Line[series[i].start].FirstNoteBeat) / 2))) { this.ShortEnd = lines.Line[series[i].start - 1].LastNote.EndBeat; return; } else { this.ShortEnd = lines.Line[series[i].end].LastNote.EndBeat; return; } } } //Check if stop is in line for (int i = 0; i < lines.Line.Length; i++) { if (lines.Line[i].FirstNoteBeat <stop && lines.Line[i].LastNoteBeat> stop) { this.ShortEnd = lines.Line[i].LastNoteBeat; return; } } ShortEnd = stop; }
private void UpdateLyrics() { if (_FadeOut) return; CSong song = CGame.GetSong(); if (song == null) return; CLines[] lines = new CLines[song.Notes.Lines.Length]; _CurrentBeat = CGame.CurrentBeat; for (int i = 0; i < lines.Length; i++) { if (i > 1) break; // for later lines[i] = song.Notes.GetLines(i); CLine[] line = lines[i].Line; int nr = -1; for (int j = 0; j < line.Length; j++) { if (line[j].StartBeat <= _CurrentBeat) { if (CGame.GetTimeFromBeats(line[j].FirstBeat, song.BPM) <= _CurrentTime - song.Gap + 10f) { nr = j; } } } if (nr != -1) { for (int j = 0; j < CGame.NumPlayer; j++) { if (CGame.Player[j].LineNr == i) SingNotes[htSingNotes(SingBars)].AddLine(NoteLines[j], line, nr, j); } if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet) { Lyrics[htLyrics(LyricMain)].SetLine(line[nr]); Lyrics[htLyrics(LyricMainTop)].SetLine(line[nr]); _TimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstBeat - line[nr].StartBeat, song.BPM); _RemainingTimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM); if (line.Length >= nr + 2) { Lyrics[htLyrics(LyricSub)].SetLine(line[nr + 1]); Lyrics[htLyrics(LyricSubTop)].SetLine(line[nr + 1]); } else { Lyrics[htLyrics(LyricSub)].Clear(); Lyrics[htLyrics(LyricSubTop)].Clear(); } } if (i == 0 && song.IsDuet) { Lyrics[htLyrics(LyricMainDuet)].SetLine(line[nr]); _TimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstBeat - line[nr].StartBeat, song.BPM); _RemainingTimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM); if (line.Length >= nr + 2) Lyrics[htLyrics(LyricSubDuet)].SetLine(line[nr + 1]); else Lyrics[htLyrics(LyricSubDuet)].Clear(); } } else { if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet) { Lyrics[htLyrics(LyricMain)].Clear(); Lyrics[htLyrics(LyricSub)].Clear(); Lyrics[htLyrics(LyricMainTop)].Clear(); Lyrics[htLyrics(LyricSubTop)].Clear(); _TimeToFirstNote = 0f; } if (i == 0 && song.IsDuet) { Lyrics[htLyrics(LyricMainDuet)].Clear(); Lyrics[htLyrics(LyricSubDuet)].Clear(); _TimeToFirstNoteDuet = 0f; } } } }
private void PrepareTimeLine() { CStatic stat = Statics[htStatics(StaticTimeLine)]; switch (CConfig.TimerLook) { case ETimerLook.TR_CONFIG_TIMERLOOK_NORMAL: _TimeLineRect = new SRectF(stat.Rect.X, stat.Rect.Y, 0f, stat.Rect.H, stat.Rect.Z); Statics[htStatics(StaticTimePointer)].Visible = false; break; case ETimerLook.TR_CONFIG_TIMERLOOK_EXPANDED: _TimeRects.Clear(); Statics[htStatics(StaticTimePointer)].Visible = true; CSong song = CGame.GetSong(); if (song == null) return; float TotalTime = CSound.GetLength(_CurrentStream); if (song.Finish != 0) TotalTime = song.Finish; TotalTime -= song.Start; if (TotalTime <= 0f) return; CLines[] Lines = new CLines[song.Notes.Lines.Length]; Lines = song.Notes.Lines; for (int i = 0; i < Lines.Length; i++) { CLine[] Line = Lines[i].Line; for(int j = 0; j<Line.Length; j++){ TimeRect trect = new TimeRect(); trect.startBeat = Line[j].FirstBeat; trect.endBeat = Line[j].EndBeat; trect.rect = new CStatic(new STexture(-1), new SColorF(1f, 1f, 1f, 1f), new SRectF(stat.Rect.X + stat.Rect.W * ((CGame.GetTimeFromBeats(trect.startBeat, song.BPM) + song.Gap - song.Start) / TotalTime), stat.Rect.Y, stat.Rect.W * (CGame.GetTimeFromBeats((trect.endBeat - trect.startBeat), song.BPM) / TotalTime), stat.Rect.H, stat.Rect.Z)); _TimeRects.Add(trect); } } break; } }
private float[] CalcFadingAlpha() { float dt = 4f; float rt = dt * 0.8f; CSong Song = CGame.GetSong(); if (Song == null) return null; float[] Alpha = new float[Song.Notes.Lines.Length * 2]; CLines[] lines = new CLines[Song.Notes.Lines.Length]; float CurrentTime = _CurrentTime - Song.Gap; for (int i = 0; i < lines.Length; i++) { lines[i] = Song.Notes.GetLines(i); CLine[] line = lines[i].Line; int CurrentLine = 0; for (int j = 0; j < line.Length; j++) { if (line[j].FirstBeat <= _CurrentBeat) { CurrentLine = j; } } // default values Alpha[i * 2] = 1f; Alpha[i * 2 + 1] = 1f; // main if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM)) { float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM) - CurrentTime; if (diff > dt) { Alpha[i * 2] = 1f - (diff - dt) / rt; } } else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime && CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) > CurrentTime) { float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); if (diff > 3.3f * dt) { float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime; if (last < next) { Alpha[i * 2] = 1f - last / rt; } else { if (next > dt) Alpha[i * 2] = 1f - (next - dt) / rt; } } } else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime) { float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); Alpha[i * 2] = 1f - diff / rt; } // sub if (CurrentLine < line.Length - 2) { float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime; if (diff > dt) { Alpha[i * 2 + 1] = 1f - (diff - dt) / rt; } } if (Alpha[i * 2] < 0f) Alpha[i * 2] = 0f; if (Alpha[i * 2 + 1] < 0f) Alpha[i * 2 + 1] = 0f; } return Alpha; }
private float[] CalcFadingAlpha() { float dt = 4f; float rt = dt * 0.8f; CSong Song = CGame.GetSong(); if (Song == null) return null; float[] Alpha = new float[Song.Notes.Lines.Length * 2]; CLines[] lines = new CLines[Song.Notes.Lines.Length]; float CurrentTime = _CurrentTime - Song.Gap; for (int i = 0; i < lines.Length; i++) { 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].FirstBeat, Song.BPM) <= _CurrentTime - Song.Gap + 10f) { CurrentLineSub = j; } } } // find current line for lyric main fading int CurrentLine = 0; for (int j = 0; j < line.Length; j++) { if (line[j].FirstBeat <= _CurrentBeat) { CurrentLine = j; } } // default values Alpha[i * 2] = 1f; Alpha[i * 2 + 1] = 1f; // main line alpha if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM)) { // first main line and fist note is not reached // => fade in float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM) - CurrentTime; if (diff > dt) { Alpha[i * 2] = 1f - (diff - dt) / rt; } } else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime && CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) > CurrentTime) { // current position is between two lines // time between the to lines float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); // fade only if there is enough time for fading if (diff > 3.3f * dt) { // time elapsed since last line float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); // time to next line float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime; if (last < next) { // fade out Alpha[i * 2] = 1f - last / rt; } else { // fade in if it is time for if (next > dt) Alpha[i * 2] = 1f - (next - dt) / rt; } } } else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime) { // last main line and last note was reached // => fade out float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); Alpha[i * 2] = 1f - diff / rt; } // sub if (CurrentLineSub < line.Length - 2) { float diff = 0f; diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstBeat, Song.BPM) - CurrentTime; if (diff > dt) { Alpha[i * 2 + 1] = 1f - (diff - dt) / rt; } } if (Alpha[i * 2] < 0f) Alpha[i * 2] = 0f; if (Alpha[i * 2 + 1] < 0f) Alpha[i * 2 + 1] = 0f; } return Alpha; }