예제 #1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="masterList">All of the music/soundbanks and their locations.</param>
 /// <param name="reset">The callback to reset the game audio.</param>
 public MusicHexProcessor(XACTMusicPack masterList, Action reset)
 {
     this.MasterList = masterList;
     this.Reset      = reset;
 }
예제 #2
0
        /// <summary>
        /// Process the soundbank.swb file's hex info and extract the song names from it.
        /// </summary>
        /// <param name="musicPack"></param>
        /// <param name="reset"></param>
        /// <param name="FileName"></param>
        /// <returns></returns>
        public static List <string> ProcessSongNamesFromHex(XACTMusicPack musicPack, Action reset, string FileName)
        {
            List <string> cleanCueNames = new List <string>();

            byte[] array   = File.ReadAllBytes(FileName);
            string rawName = FileName.Substring(0, FileName.Length - 4);
            string cueName = rawName + "CueList.txt";

            //Not used as the music pack can change between loads

            /*
             * if (File.Exists(cueName))
             * {
             *  string[] arr = File.ReadAllLines(cueName);
             *  List<string> names = new List<string>();
             *  foreach(var v in arr)
             *  {
             *      names.Add(v);
             *  }
             *  return names;
             * }
             */
            string hexDumpContents = HexDump(array);

            string rawHexName = rawName + "HexDump.txt";

            File.WriteAllText(rawHexName, hexDumpContents);

            string[] readText    = File.ReadAllLines(rawHexName);
            string   largeString = "";

            foreach (var line in readText)
            {
                try
                {
                    string newString = "";
                    for (int i = 62; i <= 77; i++)
                    {
                        newString += line[i];
                    }
                    largeString += newString;
                }
                catch { }
            }
            string[] splits = largeString.Split('ÿ');
            string   fix    = "";

            foreach (string s in splits)
            {
                if (s == "")
                {
                    continue;
                }
                fix += s;
            }
            splits = fix.Split('.');

            foreach (var split in splits)
            {
                if (split == "")
                {
                    continue;
                }
                try
                {
                    Game1.waveBank  = musicPack.WaveBank;
                    Game1.soundBank = musicPack.SoundBank;

                    if (Game1.soundBank.GetCue(split) != null)
                    {
                        cleanCueNames.Add(split);
                    }

                    reset.Invoke();
                }
                catch (Exception err)
                {
                    err.ToString();
                    reset.Invoke();
                }
            }


            return(cleanCueNames);
        }
예제 #3
0
 /// <summary>
 /// Adds a valid xwb music pack to the list of music packs available.
 /// </summary>
 /// <param name="xwbMusicPack"></param>
 public void addMusicPack(XACTMusicPack xwbMusicPack)
 {
     this.musicPacks.Add(xwbMusicPack.musicPackInformation.name, xwbMusicPack);
 }