private void DrawIssue(int songDurationInMillis, SongIssue issue) { Color color = SongIssueUtils.GetColorForIssue(issue); int startMillis = (int)BpmUtils.BeatToMillisecondsInSong(songMeta, issue.StartBeat); int endMillis = (int)BpmUtils.BeatToMillisecondsInSong(songMeta, issue.EndBeat); // Use a minimum width of 0.5% such that the issue is not overlooked int lengthInMillis = endMillis - startMillis; double lengthInPercent = (double)lengthInMillis / songDurationInMillis; if (lengthInPercent < 0.005) { endMillis = (int)(startMillis + songDurationInMillis * 0.005); } int xStart = (int)(dynImage.TextureWidth * startMillis / songDurationInMillis); int xEnd = (int)(dynImage.TextureWidth * endMillis / songDurationInMillis); if (xEnd < xStart) { ObjectUtils.Swap(ref xStart, ref xEnd); } dynImage.DrawRectByCorners(xStart, 0, xEnd, dynImage.TextureHeight, color); }
private static void AnalyzeNotesInSentence(Sentence sentence, List <SongIssue> result) { // Find overlapping notes List <Note> sortedNotes = SongMetaUtils.GetSortedNotes(sentence); Note lastNote = null; foreach (Note note in sortedNotes) { if (lastNote != null && note.StartBeat < lastNote.EndBeat) { SongIssue issue = SongIssue.CreateError("Notes overlap", note.StartBeat, lastNote.EndBeat); result.Add(issue); } // Find pitches outside of the singable range if (note.MidiNote < MidiUtils.SingableNoteMin || note.MidiNote > MidiUtils.SingableNoteMax) { SongIssue issue = SongIssue.CreateWarning("Unusual pitch (human range is roughly from C2 to C6).", note.StartBeat, note.EndBeat); result.Add(issue); } // Check that each note has lyrics if (note.Text.IsNullOrEmpty()) { SongIssue issue = SongIssue.CreateWarning("Missing lyrics on note", note.StartBeat, note.EndBeat); result.Add(issue); } lastNote = note; } }
private void DrawIssue(SongIssue issue) { if (dynamicTexture == null) { return; } Color color = SongIssueUtils.GetColorForIssue(issue); int songDurationInMillis = (int)Math.Ceiling(songAudioPlayer.AudioClip.length * 1000); int startMillis = (int)BpmUtils.BeatToMillisecondsInSong(songMeta, issue.StartBeat); int endMillis = (int)BpmUtils.BeatToMillisecondsInSong(songMeta, issue.EndBeat); // Use a minimum width of 0.5% such that the issue is not overlooked int lengthInMillis = endMillis - startMillis; double lengthInPercent = (double)lengthInMillis / songDurationInMillis; if (lengthInPercent < 0.005) { endMillis = (int)(startMillis + songDurationInMillis * 0.005); } int xStart = (int)(dynamicTexture.TextureWidth * startMillis / songDurationInMillis); int xEnd = (int)(dynamicTexture.TextureWidth * endMillis / songDurationInMillis); if (xEnd < xStart) { ObjectUtils.Swap(ref xStart, ref xEnd); } dynamicTexture.DrawRectByCorners(xStart, 0, xEnd, (int)(dynamicTexture.TextureHeight * 0.5f), color); }
public void Init(SongIssue songIssue) { this.SongIssue = songIssue; uiText.text = SongIssue.Message; SetTextVisible(false); backgroundImage.color = SongIssueUtils.GetColorForIssue(songIssue); }
private void CreateUiIssue(SongIssue issue) { EditorUiIssue uiIssue = Instantiate(issuePrefab, uiIssueContainer.transform); injector.Inject(uiIssue); uiIssue.Init(issue); PositionUiIssue(uiIssue, issue.StartBeat); }
public static Color GetColorForIssue(SongIssue issue) { if (issue.Severity == ESongIssueSeverity.Warning) { return(Colors.yellow); } else { return(Colors.red); } }
private void CreateUiIssue(SongIssue issue) { VisualElement visualElement = editorIssueUi.CloneTree().Children().First(); EditorIssueControl editorIssueControl = injector .WithRootVisualElement(visualElement) .WithBindingForInstance(issue) .CreateAndInject <EditorIssueControl>(); noteAreaIssues.Add(visualElement); editorIssueControl.VisualElement.RegisterCallbackOneShot <GeometryChangedEvent>(evt => { PositionEditorIssueControl(editorIssueControl.VisualElement, issue.StartBeat); }); }
private static void AnalyzeSentencesInVoice(Voice voice, List <SongIssue> result) { // Find overlapping sentences List <Sentence> sortedSentences = SongMetaUtils.GetSortedSentences(voice); Sentence lastSentence = null; foreach (Sentence sentence in sortedSentences) { if (lastSentence != null && sentence.MinBeat < lastSentence.ExtendedMaxBeat) { SongIssue issue = SongIssue.CreateError("Sentences overlap", sentence.MinBeat, lastSentence.ExtendedMaxBeat); result.Add(issue); } lastSentence = sentence; AnalyzeNotesInSentence(sentence, result); } }
public static SongIssue CreateError(string message, int startBeat, int endBeat) { SongIssue issue = new SongIssue(ESongIssueSeverity.Error, message, startBeat, endBeat); return(issue); }
public void Init(SongIssue songIssue) { this.SongIssue = songIssue; backgroundImage.color = SongIssueUtils.GetColorForIssue(songIssue); tooltipHandler.tooltipText = songIssue.Message; }