Skip to content

Commit

Permalink
Clear phrase after ending for generic vox (#276)
Browse files Browse the repository at this point in the history
* Parse phrase length from midi and clear phrase when complete for generic vox

* Ignore percussion phrases when parsing midi for generic vox
  • Loading branch information
PikminGuts92 authored May 8, 2023
1 parent c29e3f4 commit 280009e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Assets/Script/Data/GenericLyricInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Collections.Generic;

namespace YARG.Data {
public class GenericLyricInfo {
public float time;
public class GenericLyricInfo : AbstractInfo {
public List<(float time, string word)> lyric;

public GenericLyricInfo(float time, List<(float, string)> lyric) {
public GenericLyricInfo(float time, float length, List<(float, string)> lyric) {
this.time = time;
this.length = length;
this.lyric = lyric;
}
}
Expand Down
8 changes: 6 additions & 2 deletions Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,14 @@ private void Update() {
// Update lyrics
if (lyricIndex < chart.genericLyrics.Count) {
var lyric = chart.genericLyrics[lyricIndex];
if (lyricPhraseIndex >= lyric.lyric.Count) {

if (lyricPhraseIndex >= lyric.lyric.Count && lyric.EndTime < SongTime) {
// Clear phrase
GameUI.Instance.SetGenericLyric(string.Empty);

lyricPhraseIndex = 0;
lyricIndex++;
} else if (lyric.lyric[lyricPhraseIndex].time < SongTime) {
} else if (lyricPhraseIndex < lyric.lyric.Count && lyric.lyric[lyricPhraseIndex].time < SongTime) {
// Consolidate lyrics
string o = "<color=#ffb700>";
for (int i = 0; i < lyric.lyric.Count; i++) {
Expand Down
8 changes: 6 additions & 2 deletions Assets/Script/Serialization/Parser/MidiParser.Vocals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ private List<GenericLyricInfo> ParseGenericLyrics(TrackChunk trackChunk, TempoMa
// Create lyric
startTimings.Add(note.Time);
var time = (float) TimeConverter.ConvertTo<MetricTimeSpan>(note.Time, tempo).TotalSeconds;
GenericLyricInfo lyric = new(time, new());
var length = (float) TimeConverter.ConvertTo<MetricTimeSpan>(note.EndTime, tempo).TotalSeconds - time;
GenericLyricInfo lyric = new(time, length, new());

// Get lyrics from this phrase
long totalDelta = 0;
Expand Down Expand Up @@ -73,7 +74,10 @@ private List<GenericLyricInfo> ParseGenericLyrics(TrackChunk trackChunk, TempoMa
}

// Add phrase to result
lyrics.Add(lyric);
// Ignore phrases w/o lyrics (i.e. percussion)
if (lyric.lyric.Count > 0) {
lyrics.Add(lyric);
}
}

return lyrics;
Expand Down

0 comments on commit 280009e

Please sign in to comment.