public List <SplitAtom> GetCurrentNoteAtom(string prev, string current, string next, double BaseTempo) { List <string> GetCurrent = GetAtomItem(current); if (GetCurrent.Count == 0) { SplitAtom sa = new SplitAtom(); sa.PhonemeAtom = current; return(new List <SplitAtom>() { sa }); } List <string> GetPrev = GetAtomItem(prev); List <string> GetNext = GetAtomItem(next); List <SplitAtom> RetAtom = new List <SplitAtom>(); string[] List = _FunctionString.Split('|'); for (int i = 0; i < List.Length; i++) { string si = List[i]; int sIdx = si.LastIndexOf('$'); string AtomBody = sIdx > 0?si.Substring(0, sIdx):si; string AtomLength = "0"; if (sIdx > 0 && sIdx + 1 < si.Length) { AtomLength = si.Substring(sIdx + 1); } string AtomStr = CalcAtomStr(AtomBody, GetPrev, GetCurrent, GetNext).Trim(); if (AtomStr.Trim() != "") { SplitAtom sa = new SplitAtom(); sa.PhonemeAtom = AtomStr; sa.AtomLength = (long)Microsoft.VisualBasic.Conversion.Val(AtomLength); if (AtomLength.IndexOf('%') != -1) { sa.LengthIsPercent = true; } else if (BaseTempo != 120) { double db = MidiMathUtils.Tick2Time(sa.AtomLength, BaseTempo); sa.AtomLength = (long)Math.Round((double)MidiMathUtils.Time2Tick(db, BaseTempo)); } RetAtom.Add(sa); } } return(RetAtom); }
public void SetupCurrentPhonmem(NoteObject prevObject, NoteObject curObject, NoteObject nextObject, double BaseTempo, bool UseLyricDictionary) { if (BaseTempo <= 0) { BaseTempo = 120; } if (curObject == null) { return; } if (curObject.LockPhoneme) { return; } string prevLyric = "{R}"; string nextLyric = "{R}"; string currentLyric = curObject.Lyric; if (prevObject != null) { if (Math.Abs(curObject.Tick - (prevObject.Tick + prevObject.Length)) < 480) { prevLyric = prevObject.Lyric; } } if (nextObject != null) { if (Math.Abs(nextObject.Tick - (curObject.Tick + curObject.Length)) < 480) { nextLyric = nextObject.Lyric; } } List <SplitAtom> SList = null; if (UseLyricDictionary) { SList = GetCurrentNoteAtom(prevLyric, currentLyric, nextLyric, BaseTempo); } else { SplitAtom sa = new SplitAtom(); sa.PhonemeAtom = currentLyric; SList = new List <SplitAtom>() { sa }; } if (curObject.PhonemeAtoms.Count == SList.Count) { bool isSame = true; for (int i = 0; i < SList.Count; i++) { if (curObject.PhonemeAtoms[i].PhonemeAtom != SList[i].PhonemeAtom) { isSame = false; break; } } if (!isSame) { NoteAtomObject obj = curObject.PhonemeAtoms.Count > 0?curObject.PhonemeAtoms[0]:new NoteAtomObject(); curObject.PhonemeAtoms.Clear(); for (int i = 0; i < SList.Count; i++) { string lastPn = ""; if (curObject.PhonemeAtoms.Count > 0) { lastPn = curObject.PhonemeAtoms[curObject.PhonemeAtoms.Count - 1].PhonemeAtom; } if (lastPn != SList[i].PhonemeAtom) { NoteAtomObject nao = new NoteAtomObject(); nao.AtomLength = SList[i].AtomLength; nao.LengthIsPercent = SList[i].LengthIsPercent; nao.PhonemeAtom = SList[i].PhonemeAtom; nao.FadeInLengthMs = obj.FadeInLengthMs; nao.FadeOutLengthMs = obj.FadeOutLengthMs; nao.Flags = obj.Flags; nao.Intensity = obj.Intensity; nao.Modulation = obj.Modulation; curObject.PhonemeAtoms.Add(nao); } } } } else { NoteAtomObject obj = curObject.PhonemeAtoms.Count > 0 ? curObject.PhonemeAtoms[0] : new NoteAtomObject(); curObject.PhonemeAtoms.Clear(); for (int i = 0; i < SList.Count; i++) { string lastPn = ""; if (curObject.PhonemeAtoms.Count > 0) { lastPn = curObject.PhonemeAtoms[curObject.PhonemeAtoms.Count - 1].PhonemeAtom; } if (lastPn != SList[i].PhonemeAtom) { NoteAtomObject nao = new NoteAtomObject(); nao.AtomLength = SList[i].AtomLength; nao.LengthIsPercent = SList[i].LengthIsPercent; nao.PhonemeAtom = SList[i].PhonemeAtom; nao.FadeInLengthMs = obj.FadeInLengthMs; nao.FadeOutLengthMs = obj.FadeOutLengthMs; nao.Flags = obj.Flags; nao.Intensity = obj.Intensity; nao.Modulation = obj.Modulation; curObject.PhonemeAtoms.Add(nao); } } } }