public void writeSingerTest() { var sequence = new VsqFile("singer", 1, 4, 4, 500000); var premeasaure_clock = sequence.getPreMeasureClocks(); var temporary = Path.GetTempFileName(); var writer = new VsqxWriter(); Assert.DoesNotThrow(() => writer.write(sequence, temporary)); var text = File.ReadAllText(temporary); var document = XElement.Parse(text); XNamespace ns = "http://www.yamaha.co.jp/vocaloid/schema/vsq3/"; var singer = document .Descendants(ns + "vsTrack") .First() .Descendants(ns + "musicalPart") .First() .Descendants(ns + "singer") .FirstOrDefault(); Assert.NotNull(singer); var pos_tick = singer.Descendants(ns + "posTick").FirstOrDefault(); Assert.NotNull(pos_tick); Assert.AreEqual("0", pos_tick.Value); }
/// <summary> /// エクスポートを行う。 /// </summary> /// <param name="path">出力先のファイルパス</param> /// <param name="sequence">出力するシーケンス</param> public void write(VsqFile sequence, string path) { doc_ = new XmlDocument(); const string xsi_url = "http://www.w3.org/2001/XMLSchema-instance"; var root = doc_.CreateElement("vsq3"); { var xmlns = doc_.CreateAttribute("xmlns"); xmlns.Value = "http://www.yamaha.co.jp/vocaloid/schema/vsq3/"; root.Attributes.Append(xmlns); } { var xsi = doc_.CreateAttribute("xmlns:xsi"); xsi.Value = xsi_url; root.Attributes.Append(xsi); } { var schema = doc_.CreateAttribute("xsi", "schemaLocation", xsi_url); schema.Value = "http://www.yamaha.co.jp/vocaloid/schema/vsq3/ vsq3.xsd"; root.Attributes.Append(schema); } root.AppendChild(createNode("vender", "Yamaha corporation")); root.AppendChild(createNode("version", "3.0.0.11")); root.AppendChild(createVoiceTableNode(sequence)); root.AppendChild(createMixerNode(sequence.Mixer)); root.AppendChild(createMasterTrackNode(sequence, sequence.Track[0])); for (int i = 1; i < sequence.Track.Count; ++i) { root.AppendChild(createTrackNode(sequence.Track[i], i - 1, sequence.getPreMeasureClocks(), sequence.TotalClocks)); } root.AppendChild(doc_.CreateElement("seTrack")); root.AppendChild(doc_.CreateElement("karaokeTrack")); doc_.AppendChild(root); using (var stream = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { var writer = new XmlTextWriter(stream, Encoding.UTF8); writer.Formatting = Formatting.Indented; doc_.Save(writer); } }