ProjectObject LoadUST(string FilePath) { USTOriginalProject USTPO = USTOriginalSerializer.Deserialize(FilePath); PartsObject pro = USTOriginalSerializer.UST2Parts(USTPO); ProjectObject poj = new ProjectObject(); poj.InitEmpty(); poj.TrackerList[1].PartList[0] = pro; foreach (NoteObject po in pro.NoteList) { byte[] bt = System.Text.Encoding.Default.GetBytes(po.Lyric); string Str = System.Text.Encoding.GetEncoding("Shift-JIS").GetString(bt); po.Lyric = Str; } int sg = 1; for (long i = 1; i <= pro.TickLength; i += 32)// { sg = sg * -1; pro.PitchList.Add(new PitchObject(i, sg * 0.5)); } pro.PitchCompiler.FixedPitch(); string abc = ProjectObject.Serializer.Serialize(poj); return(poj); }
public void NewProject() { projectObject = new ProjectObject(); projectObject.InitEmpty(); projectObject.BasicData.IntroduceText = ""; projectObject.BasicData.ProjectFilePath = ""; projectObject.BasicData.SavePassword = ""; projectObject.BackerList.Clear(); LoadProjectObject(ref projectObject); tw.Text = "UnsavedProject"; }
public bool OpenUSTs(Form baseFrom = null) { FormSpaner.LockFrom(baseFrom); FormSpaner.SetFromProcess(0, "查找UST文件", baseFrom); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "utau工程(*.ust)|*.ust|全部文件(*.*)|*.*"; ofd.FilterIndex = 0; ofd.CheckFileExists = true; ofd.Multiselect = true; if (ofd.ShowDialog(baseFrom) == DialogResult.OK) { try { FormSpaner.SetFromProcess(5, "有效性验证", baseFrom); string[] FileList = ofd.FileNames; List <string> RealList = new List <string>(); for (int i = 0; i < FileList.Length; i++) { if (System.IO.File.Exists(FileList[i])) { RealList.Add(FileList[i]); } } ProjectObject Proj = new ProjectObject(); Proj.InitEmpty(); Proj.BasicData.IntroduceText = ""; Proj.BasicData.ProjectFilePath = ""; Proj.BasicData.SavePassword = ""; Proj.SingerList.Clear(); Proj.TrackerList.Clear(); Proj.BackerList.Clear(); FormSpaner.SetFromProcess(10, "正在装载UST文件", baseFrom); Object thisLock = new Object(); Parallel.For(0, RealList.Count, (i) => { USTOriginalProject USTPO = USTOriginalSerializer.Deserialize(RealList[i]); PartsObject pro = USTOriginalSerializer.UST2Parts(USTPO); TrackerObject toj = new TrackerObject((uint)i); toj.Name = pro.PartName; toj.PartList.Clear(); toj.PartList.Add(pro); lock (thisLock) { Proj.TrackerList.Add(toj); } }); Proj.TrackerList.Sort(); FormSpaner.SetFromProcess(90, "正在装载工程文件", baseFrom); LoadProjectObject(ref Proj); FormSpaner.SetFromProcess(100, "完成", baseFrom); FormSpaner.UnLockFrom(baseFrom); tw.Text = "UnsavedProject"; return(true); } catch {; } } FormSpaner.UnLockFrom(baseFrom); return(false); }
ProjectObject LoadUST(string[] FilePath) { ProjectObject poj = new ProjectObject(); poj.InitEmpty(); try { for (int i = 0; i < FilePath.Length; i++) { USTOriginalProject USTPO = USTOriginalSerializer.Deserialize(FilePath[i]); PartsObject pro = USTOriginalSerializer.UST2Parts(USTPO); if (poj.TrackerList.Count <= i) { poj.TrackerList.Add(new TrackerObject((uint)i)); poj.TrackerList[i].PartList.Add(new PartsObject()); } poj.TrackerList[i].PartList[0] = pro; foreach (NoteObject po in pro.NoteList) { byte[] bt = System.Text.Encoding.Default.GetBytes(po.Lyric); string Str = System.Text.Encoding.GetEncoding("Shift-JIS").GetString(bt); po.Lyric = Str; } } } catch {; } /* int sg = 1; * for (long i = 1; i <= pro.TickLength; i += 32) * { * sg = sg * -1; * pro.PitchBendsList.Add(new PitchObject(i, sg * 0.5)); * }*/ int ci = poj.TrackerList.Count; poj.TrackerList.Add(new TrackerObject((uint)ci)); poj.TrackerList[ci].PartList.Add(new PartsObject()); poj.TrackerList[ci].PartList[0].StartTime = 0.2; // poj.TrackerList[ci].PartList[0].TickLength = 1920; poj.TrackerList[ci].PartList[0].PartName = "NAME"; poj.TrackerList[ci].PartList.Add(new PartsObject()); poj.TrackerList[ci].PartList[1].StartTime = 2.5; // poj.TrackerList[ci].PartList[1].TickLength = 1920; poj.TrackerList[ci].PartList[1].PartName = "NAME2"; poj.BackerList[0].WavPartList.Add(new WavePartsObject()); poj.BackerList[0].WavPartList[0].StartTime = 0.2; poj.BackerList[0].WavPartList[0].DuringTime = 100; poj.BackerList[0].WavPartList[0].PartName = "WA1"; poj.BackerList.Add(new BackerObject(1)); poj.BackerList[1].WavPartList.Add(new WavePartsObject()); poj.BackerList[1].WavPartList[0].StartTime = 0.2; poj.BackerList[1].WavPartList[0].DuringTime = 4; poj.BackerList[1].WavPartList[0].PartName = "WA2"; poj.BackerList[1].WavPartList.Add(new WavePartsObject()); poj.BackerList[1].WavPartList[1].StartTime = 5; poj.BackerList[1].WavPartList[1].DuringTime = 100; poj.BackerList[1].WavPartList[1].PartName = "WA3"; poj.SingerList.Clear(); poj.SingerList.Add(new SingerObject("Singer1")); poj.SingerList[0].PartResampler = "resampler.exe"; poj.SingerList[0].Flags = "B0Y0"; poj.SingerList[0].SingerFolder = @"D:\VocalUtau\VocalUtau.DebugExampleFiles\UTAUKernel\voice\uta"; poj.SingerList.Add(new SingerObject("Singer2")); poj.SingerList[1].PartResampler = "tn_fnds.exe"; poj.SingerList[1].Flags = "B0Y1"; poj.SingerList[1].SingerFolder = @"D:\VocalUtau\VocalUtau.DebugExampleFiles\UTAUKernel\voice\uta"; return(poj); }