コード例 #1
0
    public string GetLyrics()
    {
        positionInLyricsToNoteMap.Clear();

        StringBuilder   stringBuilder   = new StringBuilder();
        List <Sentence> sortedSentences = SongMetaUtils.GetSortedSentences(songMeta);
        Note            lastNote        = null;

        foreach (Sentence sentence in sortedSentences)
        {
            List <Note> sortedNotes = SongMetaUtils.GetSortedNotes(sentence);
            foreach (Note note in sortedNotes)
            {
                foreach (char c in note.Text)
                {
                    positionInLyricsToNoteMap[stringBuilder.Length] = note;
                    stringBuilder.Append(c);
                }
                lastNote = note;
            }
            stringBuilder.Append("\n");
        }
        if (lastNote != null)
        {
            positionInLyricsToNoteMap[stringBuilder.Length] = lastNote;
        }
        return(stringBuilder.ToString());
    }
コード例 #2
0
ファイル: SongMetaAnalyzer.cs プロジェクト: xxxDSSxxx/Play
    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;
        }
    }
コード例 #3
0
ファイル: PlayerPitchTracker.cs プロジェクト: segmeton/Play
    private void SetRecordingSentence(int sentenceIndex)
    {
        RecordingSentence = playerController.GetSentence(sentenceIndex);
        if (RecordingSentence == null)
        {
            currentAndUpcomingNotesInRecordingSentence = new List <Note>();
            BeatToAnalyze = 0;
            return;
        }
        currentAndUpcomingNotesInRecordingSentence = SongMetaUtils.GetSortedNotes(RecordingSentence);

        BeatToAnalyze = RecordingSentence.MinBeat;
    }
コード例 #4
0
    private Note GetNoteForCaretPosition(string text, int caretPosition)
    {
        // Count sentence borders
        int relevantSentenceIndex          = 0;
        int relevantSentenceTextStartIndex = 0;

        for (int i = 0; i < text.Length && i < caretPosition; i++)
        {
            if (text[i] == sentenceSeparator)
            {
                relevantSentenceIndex++;
                relevantSentenceTextStartIndex = i + 1;
            }
        }

        // Get relevant sentence
        List <Sentence> sortedSentences = SongMetaUtils.GetSortedSentences(Voice);

        if (relevantSentenceIndex >= sortedSentences.Count ||
            sortedSentences[relevantSentenceIndex].Notes.IsNullOrEmpty())
        {
            return(null);
        }
        Sentence relevantSentence = sortedSentences[relevantSentenceIndex];

        // Count note borders
        int noteIndex = 0;

        for (int i = relevantSentenceTextStartIndex; i < text.Length && i < caretPosition; i++)
        {
            char c = text[i];
            if (c == spaceCharacter ||
                c == ShowWhiteSpaceText.spaceReplacement[0] ||
                c == syllableSeparator)
            {
                noteIndex++;
            }
        }

        // Get relevant note
        List <Note> sortedNotes = SongMetaUtils.GetSortedNotes(relevantSentence);

        if (noteIndex >= sortedNotes.Count)
        {
            return(null);
        }
        return(sortedNotes[noteIndex]);
    }
コード例 #5
0
    private string GetViewModeText()
    {
        StringBuilder   stringBuilder   = new StringBuilder();
        List <Sentence> sortedSentences = SongMetaUtils.GetSortedSentences(Voice);

        foreach (Sentence sentence in sortedSentences)
        {
            List <Note> sortedNotes = SongMetaUtils.GetSortedNotes(sentence);
            foreach (Note note in sortedNotes)
            {
                stringBuilder.Append(note.Text);
            }
            stringBuilder.Append(sentenceSeparator);
        }
        return(stringBuilder.ToString());
    }
コード例 #6
0
    private string GetEditModeText()
    {
        StringBuilder   stringBuilder   = new StringBuilder();
        List <Sentence> sortedSentences = SongMetaUtils.GetSortedSentences(Voice);
        Note            lastNote        = null;

        void ProcessNote(Note note)
        {
            if (lastNote != null &&
                lastNote.Sentence == note.Sentence)
            {
                // Add a space when the last note ended or the current note started with a space.
                // Otherwise use the non-whitespace syllabeSeparator as end-of-note.
                if (lastNote.Text.EndsWith(spaceCharacter) ||
                    note.Text.StartsWith(spaceCharacter))
                {
                    stringBuilder.Append(spaceCharacter);
                }
                else
                {
                    stringBuilder.Append(syllableSeparator);
                }
            }
            stringBuilder.Append(note.Text.Trim());

            lastNote = note;
        }

        void ProcessSentence(Sentence sentence)
        {
            List <Note> sortedNotes = SongMetaUtils.GetSortedNotes(sentence);

            sortedNotes.ForEach(ProcessNote);

            stringBuilder.Append(sentenceSeparator);
        }

        sortedSentences.ForEach(ProcessSentence);

        return(stringBuilder.ToString());
    }
コード例 #7
0
    private void MapEditModeTextToNotes(string editModeText)
    {
        int             sentenceIndex   = 0;
        int             noteIndex       = 0;
        List <Sentence> sortedSentences = SongMetaUtils.GetSortedSentences(Voice);
        List <Note>     sortedNotes     = (sentenceIndex < sortedSentences.Count)
            ? SongMetaUtils.GetSortedNotes(sortedSentences[sentenceIndex])
            : new List <Note>();

        StringBuilder stringBuilder = new StringBuilder();

        void ApplyNoteText()
        {
            if (noteIndex < sortedNotes.Count)
            {
                sortedNotes[noteIndex].SetText(stringBuilder.ToString());
            }
            stringBuilder = new StringBuilder();
        }

        void SelectNextSentence()
        {
            ApplyNoteText();

            for (int i = noteIndex + 1; i < sortedNotes.Count; i++)
            {
                sortedNotes[i].SetText("");
            }

            sentenceIndex++;
            noteIndex = 0;

            sortedNotes = (sentenceIndex < sortedSentences.Count)
                    ? SongMetaUtils.GetSortedNotes(sortedSentences[sentenceIndex])
                    : new List <Note>();
        }

        void SelectNextNote()
        {
            ApplyNoteText();

            noteIndex++;
        }

        foreach (char c in editModeText)
        {
            if (c == sentenceSeparator)
            {
                SelectNextSentence();
            }
            else if (c == syllableSeparator)
            {
                SelectNextNote();
            }
            else if (c == ' ')
            {
                stringBuilder.Append(c);
                SelectNextNote();
            }
            else
            {
                stringBuilder.Append(c);
            }
        }

        for (int s = sentenceIndex; s < sortedSentences.Count; s++)
        {
            sortedNotes = SongMetaUtils.GetSortedNotes(sortedSentences[s]);
            for (int n = noteIndex; n < sortedNotes.Count; n++)
            {
                sortedNotes[n].SetText("");
            }
        }
    }