Esempio n. 1
0
        public Lyric(string str)
        {
            NRC      = new NRCModel();
            NRC.NRCS = new List <NRCSentenceModel>();

            LyricType lt = GetLyricType(str);

            NRC.LyricType = lt;
            if (lt == LyricType.LRC)
            {
                LoadLRC(str);
                Export();
            }
            else
            {
                LoadNRC(str);
            }
        }
Esempio n. 2
0
        private void LyricTypeAnalyse()
        {
            var projectLyricType = LyricType.None;

            foreach (var track in Data.TrackList)
            {
                var   noteList  = track.NoteList;
                int[] typeCount = new int[4] {
                    0, 0, 0, 0
                };
                foreach (var note in noteList)
                {
                    if (note.NoteLyric.Contains(" "))
                    {
                        try
                        {
                            string subLyric = note.NoteLyric.Substring(note.NoteLyric.IndexOf(" ") + 1);
                            for (int i = 1; i < 4; i++)
                            {
                                if (FindKana(subLyric.Substring(0, i)) != -1)
                                {
                                    typeCount[3]++;
                                    break;
                                }
                                else
                                {
                                    if (FindRomaji(subLyric.Substring(0, i)) != -1)
                                    {
                                        typeCount[1]++;
                                        break;
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            for (int i = 1; i < 4; i++)
                            {
                                if (FindKana(note.NoteLyric.Substring(0, i)) != -1)
                                {
                                    typeCount[2]++;
                                    break;
                                }
                                else
                                {
                                    if (FindRomaji(note.NoteLyric.Substring(0, i)) != -1)
                                    {
                                        typeCount[0]++;
                                        break;
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }
                var trackLyricType = LyricType.None;
                for (int i = 0; i < 4; i++)
                {
                    if (100 * typeCount[i] / noteList.Count > 50)
                    {
                        if (trackLyricType == LyricType.None)
                        {
                            trackLyricType = (LyricType)(i + 1);
                        }
                        else
                        {
                            trackLyricType = LyricType.None;
                            break;
                        }
                    }
                }
                if (trackLyricType > 0)
                {
                    if (projectLyricType == LyricType.None)
                    {
                        projectLyricType = trackLyricType;
                    }
                    else
                    {
                        if (projectLyricType != trackLyricType)
                        {
                            return;
                        }
                    }
                }
            }
            TypeAnalysed = projectLyricType;
        }
Esempio n. 3
0
        private void CleanLyric(LyricType type)
        {
            foreach (var track in Data.TrackList)
            {
                var noteList = track.NoteList;
                switch (type)
                {
                case LyricType.RomajiTandoku:
                {
                    for (int i = 0; i < noteList.Count; i++)
                    {
                        if (noteList[i].NoteLyric != "")
                        {
                            noteList[i].NoteLyric = noteList[i].NoteLyric.ToLower();
                            if (noteList[i].NoteLyric.Substring(0, 1) == "?")
                            {
                                noteList[i].NoteLyric = noteList[i].NoteLyric.Remove(0, 1);
                            }
                            try
                            {
                                for (int j = 3; j >= 1; j--)
                                {
                                    if (FindRomaji(noteList[i].NoteLyric.Substring(0, j)) != -1)
                                    {
                                        noteList[i].NoteLyric = noteList[i].NoteLyric.Substring(0, j);
                                        break;
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                    break;
                }         // Prefix other than “?” is not considered for Romaji Tandoku

                case LyricType.RomajiRenzoku:
                {
                    for (int i = 0; i < noteList.Count; i++)
                    {
                        if (noteList[i].NoteLyric != "")
                        {
                            noteList[i].NoteLyric = noteList[i].NoteLyric.ToLower();
                            if (noteList[i].NoteLyric.Contains(" "))
                            {
                                int    blankPos = noteList[i].NoteLyric.IndexOf(" ");
                                string body     = "";
                                try
                                {
                                    for (int j = 1; j <= 3; j++)
                                    {
                                        if (FindRomaji(noteList[i].NoteLyric.Substring(blankPos + 1, j)) != -1)
                                        {
                                            body = noteList[i].NoteLyric.Substring(blankPos + 1, j);
                                        }
                                    }
                                }
                                catch { }
                                if (body != "" && IsEnd(noteList[i].NoteLyric.Substring(blankPos - 1, 1)))
                                {
                                    noteList[i].NoteLyric = noteList[i].NoteLyric.Substring(blankPos - 1, 1) + " " + body;
                                }
                            }
                            else
                            {
                                if (noteList[i].NoteLyric.Substring(0, 1) == "?")
                                {
                                    noteList[i].NoteLyric = noteList[i].NoteLyric.Remove(0, 1);
                                }
                                try
                                {
                                    for (int j = 3; j >= 1; j--)
                                    {
                                        if (FindRomaji(noteList[i].NoteLyric.Substring(0, j)) != -1)
                                        {
                                            noteList[i].NoteLyric = noteList[i].NoteLyric.Substring(0, j);
                                            break;
                                        }
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                    break;
                }

                case LyricType.KanaTandoku:
                {
                    for (int i = 0; i < noteList.Count; i++)
                    {
                        if (noteList[i].NoteLyric != "")
                        {
                            string buffer = "";
                            for (int j = 0; j < noteList[i].NoteLyric.Length; j++)
                            {
                                try
                                {
                                    buffer = noteList[i].NoteLyric.Substring(j, 2);
                                    if (FindKana(buffer) == -1)
                                    {
                                        buffer = noteList[i].NoteLyric.Substring(j, 1);
                                    }
                                }
                                catch
                                {
                                    buffer = noteList[i].NoteLyric.Substring(j, 1);
                                }
                                if (FindKana(buffer) != -1)
                                {
                                    noteList[i].NoteLyric = buffer;
                                    break;
                                }
                            }
                        }
                        noteList[i].NoteLyric = noteList[i].NoteLyric.Replace("っ", "");
                    }
                    break;
                }

                case LyricType.KanaRenzoku:
                {
                    for (int i = 0; i < noteList.Count; i++)
                    {
                        if (noteList[i].NoteLyric != "")
                        {
                            if (noteList[i].NoteLyric.Contains(" "))
                            {
                                int    blankPos = noteList[i].NoteLyric.IndexOf(" ");
                                string body;
                                try
                                {
                                    body = noteList[i].NoteLyric.Substring(blankPos + 1, 2);
                                    if (FindKana(body) == -1)
                                    {
                                        body = noteList[i].NoteLyric.Substring(blankPos + 1, 1);
                                    }
                                }
                                catch
                                {
                                    body = noteList[i].NoteLyric.Substring(blankPos + 1, 1);
                                }
                                if (FindKana(body) != -1 && IsEnd(noteList[i].NoteLyric.Substring(blankPos - 1, 1)))
                                {
                                    noteList[i].NoteLyric = noteList[i].NoteLyric.Substring(blankPos - 1, 1) + " " + body;
                                }
                            }
                            else
                            {
                                string buffer = "";
                                for (int j = 0; j < noteList[i].NoteLyric.Length; j++)
                                {
                                    try
                                    {
                                        buffer = noteList[i].NoteLyric.Substring(j, 2);
                                        if (FindKana(buffer) == -1)
                                        {
                                            buffer = noteList[i].NoteLyric.Substring(j, 1);
                                        }
                                    }
                                    catch
                                    {
                                        buffer = noteList[i].NoteLyric.Substring(j, 1);
                                    }
                                    if (FindKana(buffer) != -1)
                                    {
                                        noteList[i].NoteLyric = buffer;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
                }
            }
        }
Esempio n. 4
0
        public void Transform(LyricType fromType, LyricType toType)
        {
            if (fromType != LyricType.None && toType != LyricType.None)
            {
                CleanLyric(fromType);
                switch (fromType - toType)
                {
                case 0: break;

                case 1:
                {
                    if (fromType != LyricType.KanaTandoku)
                    {
                        TransLyricsTan2Ren(TransDirection.Reverse);
                    }
                    else
                    {
                        TransLyricsRomaji2Kana(TransDirection.Reverse);
                        TransLyricsTan2Ren(TransDirection.Sequential);
                    }
                    break;
                }

                case 2:
                {
                    TransLyricsRomaji2Kana(TransDirection.Reverse);
                    break;
                }

                case 3:
                {
                    TransLyricsRomaji2Kana(TransDirection.Reverse);
                    TransLyricsTan2Ren(TransDirection.Reverse);
                    break;
                }

                case -1:
                {
                    if (fromType != LyricType.RomajiRenzoku)
                    {
                        TransLyricsTan2Ren(TransDirection.Sequential);
                    }
                    else
                    {
                        TransLyricsRomaji2Kana(TransDirection.Sequential);
                        TransLyricsTan2Ren(TransDirection.Reverse);
                    }
                    break;
                }

                case -2:
                {
                    TransLyricsRomaji2Kana(TransDirection.Sequential);
                    break;
                }

                case -3:
                {
                    TransLyricsRomaji2Kana(TransDirection.Sequential);
                    TransLyricsTan2Ren(TransDirection.Sequential);
                    break;
                }
                }
            }
        }
Esempio n. 5
0
        void LyricTypeAnalyze()
        {
            LyricType projectLyrictype = LyricType.None;

            foreach (Track track in _data.TrackList)
            {
                List <Note> noteList  = track.NoteList;
                int[]       typecount = new int[4] {
                    0, 0, 0, 0
                };
                foreach (Note note in noteList)
                {
                    switch (InferLyricType(note.NoteLyric))
                    {
                    case LyricType.None:
                        break;

                    case LyricType.Romaji_Tandoku:
                        typecount[0]++;
                        break;

                    case LyricType.Romaji_Renzoku:
                        typecount[1]++;
                        break;

                    case LyricType.Kana_Tandoku:
                        typecount[2]++;
                        break;

                    case LyricType.Kana_Renzoku:
                        typecount[3]++;
                        break;
                    }
                }
                LyricType trackLyrictype = LyricType.None;
                for (int i = 0; i < 4; i++)
                {
                    if (100 * typecount[i] / noteList.Count > 50)
                    {
                        if (trackLyrictype == LyricType.None)
                        {
                            trackLyrictype = (LyricType)(i + 1);
                        }
                        else
                        {
                            trackLyrictype = LyricType.None;
                            break;
                        }
                    }
                }
                if (trackLyrictype > 0)
                {
                    if (projectLyrictype == LyricType.None)
                    {
                        projectLyrictype = trackLyrictype;
                    }
                    else
                    {
                        if (projectLyrictype != trackLyrictype)
                        {
                            return;
                        }
                    }
                }
            }
            AnalyzedType = projectLyrictype;
        }
Esempio n. 6
0
        void CleanLyric(LyricType type)
        {
            foreach (Track track in _data.TrackList)
            {
                List <Note> noteList = track.NoteList;
                switch (type)
                {
                case LyricType.Romaji_Tandoku:
                    foreach (Note note in noteList)
                    {
                        var lrc = note.NoteLyric.ToLower();
                        if (string.IsNullOrWhiteSpace(lrc))
                        {
                            continue;
                        }
                        lrc            = lrc.Replace("?", "");
                        note.NoteLyric = _romajiList.Find(s => lrc.Contains(s)) ?? lrc;
                    }
                    break;

                //未考虑罗马音单独音除“?”以外的前缀
                case LyricType.Romaji_Renzoku:
                    foreach (Note note in noteList)
                    {
                        var lrc = note.NoteLyric.ToLower();
                        if (string.IsNullOrWhiteSpace(lrc))
                        {
                            continue;
                        }

                        if (lrc.Contains(" "))
                        {
                            var           lrcs = lrc.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                            StringBuilder sb   = new StringBuilder();
                            foreach (var s in lrcs)
                            {
                                sb.Append(_romajiList.Find(roma => s.Contains(roma)) ?? lrc);
                                sb.Append(' ');
                            }
                            note.NoteLyric = sb.ToString().TrimEnd();
                            //if (body != "" && IsGobi(note.NoteLyric.Substring(blankPos - 1, 1)))
                            //{
                            //    note.NoteLyric = note.NoteLyric.Substring(blankPos - 1, 1) + " " + body;
                            //}
                        }
                        else
                        {
                            lrc            = lrc.Replace("?", "");
                            note.NoteLyric = _romajiList.Find(s => lrc.Contains(s)) ?? lrc;
                        }
                    }
                    break;

                case LyricType.Kana_Tandoku:
                {
                    foreach (Note note in noteList)
                    {
                        var lrc = note.NoteLyric.ToLower();
                        if (string.IsNullOrWhiteSpace(lrc))
                        {
                            continue;
                        }
                        lrc            = lrc.Replace("?", "");
                        note.NoteLyric = _kanaList.Find(s => lrc.Contains(s)) ?? lrc;
                    }
                    break;
                }

                case LyricType.Kana_Renzoku:
                {
                    foreach (Note note in noteList)
                    {
                        var lrc = note.NoteLyric.ToLower();
                        if (string.IsNullOrWhiteSpace(lrc))
                        {
                            continue;
                        }

                        if (lrc.Contains(" "))
                        {
                            var           lrcs = lrc.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                            StringBuilder sb   = new StringBuilder();
                            foreach (var s in lrcs)
                            {
                                sb.Append(_kanaList.Find(kana => s.Contains(kana)) ?? lrc);
                                sb.Append(' ');
                            }
                            note.NoteLyric = sb.ToString().TrimEnd();
                            //if (body != "" && IsGobi(note.NoteLyric.Substring(blankPos - 1, 1)))
                            //{
                            //    note.NoteLyric = note.NoteLyric.Substring(blankPos - 1, 1) + " " + body;
                            //}
                        }
                        else
                        {
                            lrc            = lrc.Replace("?", "");
                            note.NoteLyric = _kanaList.Find(s => lrc.Contains(s)) ?? lrc;
                        }
                    }
                    break;
                }
                }
            }
        }
Esempio n. 7
0
        private void LyricTypeAnalyse()
        {
            LyricType projectLyricType = LyricType.None;

            foreach (Track track in _converter.TrackList)
            {
                var   noteList  = track.NoteList;
                int[] typeCount = { 0, 0, 0, 0 };
                foreach (Note note in noteList)
                {
                    if (note.NoteLyric.Contains(" "))
                    {
                        try
                        {
                            string subLyric =
                                note.NoteLyric.Substring(note.NoteLyric.IndexOf(" ", StringComparison.Ordinal) + 1);
                            for (int i = 1; i < 4; i++)
                            {
                                if (FindKana(subLyric.Substring(0, i)) != -1)
                                {
                                    typeCount[3]++;
                                    break;
                                }

                                if (FindRomaji(subLyric.Substring(0, i)) == -1)
                                {
                                    continue;
                                }
                                typeCount[1]++;
                                break;
                            }
                        }
                        catch
                        {
                            // Ignore
                        }
                    }
                    else
                    {
                        try
                        {
                            for (int i = 1; i < 4; i++)
                            {
                                if (FindKana(note.NoteLyric.Substring(0, i)) != -1)
                                {
                                    typeCount[2]++;
                                    break;
                                }

                                if (FindRomaji(note.NoteLyric.Substring(0, i)) == -1)
                                {
                                    continue;
                                }
                                typeCount[0]++;
                                break;
                            }
                        }
                        catch
                        {
                            // Ignore
                        }
                    }
                }
                LyricType trackLyricType = LyricType.None;
                for (int i = 0; i < 4; i++)
                {
                    if (100 * typeCount[i] / noteList.Count <= 50)
                    {
                        continue;
                    }
                    if (trackLyricType == LyricType.None)
                    {
                        trackLyricType = (LyricType)(i + 1);
                    }
                    else
                    {
                        trackLyricType = LyricType.None;
                        break;
                    }
                }

                if (trackLyricType <= 0)
                {
                    continue;
                }
                if (projectLyricType == LyricType.None)
                {
                    projectLyricType = trackLyricType;
                }
                else
                {
                    if (projectLyricType != trackLyricType)
                    {
                        return;
                    }
                }
            }
            TypeAnalysed = projectLyricType;
        }