/// <summary> /// xml要素から音符イベントを生成する /// </summary> /// <param name="note">xml要素</param> /// <param name="tickOffset">指定したxml要素が所属しているmusicalPartの、オフセットtick数</param> /// <returns>生成した音符イベント</returns> private static VsqEvent createNoteEvent(XmlNode note, int tickOffset) { int posTick = int.Parse(note["posTick"].InnerText); VsqEvent item = new VsqEvent(); item.Clock = posTick + tickOffset; item.ID = new VsqID(); item.ID.type = VsqIDType.Anote; item.ID.LyricHandle = new LyricHandle(); string lyric = note["lyric"].InnerText; XmlElement phnmsElement = note["phnms"]; string symbols = phnmsElement.InnerText; bool symbolsProtected = false; if (phnmsElement.HasAttribute("lock")) { int value = int.Parse(phnmsElement.Attributes["lock"].Value); symbolsProtected = value == 1; } item.ID.LyricHandle.L0.PhoneticSymbolProtected = symbolsProtected; item.ID.LyricHandle.L0.Phrase = lyric; item.ID.LyricHandle.L0.setPhoneticSymbol(symbols); item.ID.Note = int.Parse(note["noteNum"].InnerText); item.ID.setLength(int.Parse(note["durTick"].InnerText)); item.ID.Dynamics = int.Parse(note["velocity"].InnerText); var attributes = getNoteAttributes(note); if (attributes.ContainsKey("accent")) { item.ID.DEMaccent = attributes["accent"]; } if (attributes.ContainsKey("bendDep")) { item.ID.PMBendDepth = attributes["bendDep"]; } if (attributes.ContainsKey("bendLen")) { item.ID.PMBendLength = attributes["bendLen"]; } if (attributes.ContainsKey("decay")) { item.ID.DEMdecGainRate = attributes["decay"]; } if (attributes.ContainsKey("fallPort")) { item.ID.setFallPortamento(attributes["fallPort"] == 1); } if (attributes.ContainsKey("risePort")) { item.ID.setRisePortamento(attributes["risePort"] == 1); } // vibrato if (attributes.ContainsKey("vibLen") && attributes.ContainsKey("vibType")) { int lengthPercentage = attributes["vibLen"]; int vibratoType = attributes["vibType"] - 1; if (lengthPercentage > 0) { var vibratoHandle = new VibratoHandle(); int length = item.ID.getLength(); int duration = (int)(length * (lengthPercentage / 100.0)); vibratoHandle.setLength(duration); item.ID.VibratoDelay = length - duration; vibratoHandle.IconID = "$0404" + vibratoType.ToString("X4"); double delayRatio = (double)(length - duration) / (double)length; // VibDepth vibratoHandle.setDepthBP(getVibratoCurve(note, "vibDep", delayRatio)); // VibRate vibratoHandle.setRateBP(getVibratoCurve(note, "vibRate", delayRatio)); item.ID.VibratoHandle = vibratoHandle; } } return(item); }