/// <summary> /// /// </summary> /// <param name="pack"></param> /// <param name="fighter"></param> /// <param name="editor"></param> /// <returns>Dictionary to maps old sound id values to new values</returns> private void ImportSoundData(ZipFile pack, MEXFighterEntry fighter, string semFile) { Console.WriteLine($"Importing Sound Data..."); var root = Path.GetDirectoryName(MainForm.Instance.FilePath); // Load SEM File SemEntries = SEM.ReadSEMFile(semFile, true, editor._data); // narrator call----------------------------------------------- var narratorScript = @".SFXID : (id) .REVERB : 48 .PRIORITY : 15 .UNKNOWN06 : 229 .END : 0"; var narr = pack["Sound/narrator.dsp"]; var nameBank = SemEntries.Find(e => e.SoundBank?.Name == "nr_name.ssm"); if (narr != null && nameBank != null) { var narsound = new DSP(); narsound.FromFormat(GetBytes(narr), "dsp"); var index = nameBank.SoundBank.Sounds.Length; nameBank.SoundBank.AddSound(narsound); var script = new SEMScript(); SEM.CompileSEMScript(narratorScript.Replace("(id)", index.ToString()), out script.CommandData); var scriptIndex = nameBank.Scripts.Length; nameBank.AddScript(script); fighter.AnnouncerCall = scriptIndex + SemEntries.IndexOf(nameBank) * 10000; Console.WriteLine("Imported Announcer Call"); } // Create and import SSM----------------------------------------------- var semYAML = pack["Sound/sem.yaml"]; var ssmFile = pack["Sound/sound.ssm"]; if (semYAML != null) { using (MemoryStream zos = new MemoryStream()) { semYAML.Extract(zos); zos.Position = 0; using (StreamReader r = new StreamReader(zos)) { var semEntry = SEMEntry.Deserialize(r.ReadToEnd()); if (ssmFile != null) { var ssmName = fighter.NameText.ToLower() + ".ssm"; semEntry.SoundBank = new SSM(); using (MemoryStream ssmStream = new MemoryStream()) { ssmFile.Extract(ssmStream); ssmStream.Position = 0; semEntry.SoundBank.Open(ssmName, ssmStream); } var ssmFilePath = Path.Combine(root, "audio\\us\\" + ssmName); File.WriteAllBytes(ssmFilePath, GetBytes(ssmFile)); } fighter.SSMIndex = SemEntries.Count; SemEntries.Add(semEntry); } } } // Import Victory Theme var victory = pack["Sound/victory.hps"]; if (victory != null) { var ffname = $"ff_{fighter.NameText.ToLower()}.hps"; fighter.VictoryThemeID = editor.MusicControl.AddMusic(new HSD_String() { Value = ffname }); var fffilePath = Path.Combine(root, "audio\\" + ffname); File.WriteAllBytes(fffilePath, GetBytes(victory)); } }
/// <summary> /// /// </summary> /// <param name="fighter"></param> /// <param name="editor"></param> private void RemoveSounds() { var root = Path.GetDirectoryName(MainForm.Instance.FilePath); var sem = Path.Combine(root, "audio\\us\\smash2.sem"); if (!File.Exists(sem)) { return; } // Load SEM File SemEntries = SEM.ReadSEMFile(sem, true, editor._data); // remove narrator call var inUse = editor.FighterControl.FighterEntries.Any(e => e.AnnouncerCall == fighter.AnnouncerCall); if (!inUse) { var nameBank = SemEntries.Find(e => e.SoundBank?.Name == "nr_name.ssm"); //nameBank.RemoveSoundAt(fighter.AnnouncerCall % 10000); // TODO: remove narrator name call foreach (var v in editor.FighterControl.FighterEntries) { if (v.AnnouncerCall > fighter.AnnouncerCall) { v.AnnouncerCall -= 1; } } } // remove ssm var ssminUse = editor.FighterControl.FighterEntries.Any(e => e.SSMIndex == fighter.SSMIndex); if (!ssminUse) { SemEntries.RemoveAt(fighter.SSMIndex); foreach (var v in editor.FighterControl.FighterEntries) { if (v.SSMIndex > fighter.SSMIndex) { v.SSMIndex -= 1; } } } // remove victory theme var vicinUse = editor.FighterControl.FighterEntries.Any(e => e.VictoryThemeID == fighter.VictoryThemeID); if (!vicinUse) { editor.MusicControl.RemoveMusicAt(fighter.VictoryThemeID); foreach (var v in editor.FighterControl.FighterEntries) { if (v.VictoryThemeID > fighter.VictoryThemeID) { v.VictoryThemeID -= 1; } } } }
/// <summary> /// /// </summary> /// <param name="path"></param> public void OpenSEMFile(string path, MEX_Data mex = null) { Entries = SEM.ReadSEMFile(path, true, mex).ToArray(); entryList.SetArrayFromProperty(this, "Entries"); }