Esempio n. 1
0
        /*// Structures to hold data about song metadata
         * public StringTable freSong;
         * public StringTable engSong;
         * public StringTable japSong;
         * public StringTable espSong;
         * public StringTable gerSong;
         * public StringTable itaSong;
         * // public SongObject zobjSong;
         *
         * // Structure to hold information about master track
         * // public MasterObject zobjMaster;
         *
         * // Structure to hold information about measure track
         * // public MeasureObject zobjMeasure;
         *
         * // Structure to hold information about sections
         * // public SectionObject zobjSection;
         *
         * // Structure to hold information about events
         * // public EventObject zobjEvent;
         *
         * // Structure to hold information about tempo track
         * // public TempoObject zobjTempo;
         *
         * // Structure to hold information about time signature
         * // public TimeSigObject zobjTimeSig;
         *
         * // Structures to hold information about gtr_jam
         * public StringTable freJam;
         * public StringTable engJam;
         * public StringTable japJam;
         * public StringTable espJam;
         * public StringTable gerJam;
         * public StringTable itaJam;
         * // public JamObject zobjJam;
         *
         * // Structure to hold chord info for gtr_jam
         * // public ChordObject jamChord;
         *
         * // Structure to hold tab for gtr_jam
         * // public NoteObject jamNotes;
         *
         * // Structure to hold audio effect for gtr_jam
         * // public AudioEffectObject jamEffect;
         *
         * // Structures to hold information about video
         * public StringTable freVideo;
         * public StringTable engVideo;
         * public StringTable japVideo;
         * public StringTable espVideo;
         * public StringTable gerVideo;
         * public StringTable itaVideo;
         *
         * // Structures to hold information about gtr_beg
         * public StringTable freBeg;
         * public StringTable engBeg;
         * public StringTable japBeg;
         * public StringTable espBeg;
         * public StringTable gerBeg;
         * public StringTable itaBeg;
         * // public JamObject zobjBeg;
         *
         * // Structure to hold chord info for gtr_beg
         * // public ChordObject begChord;
         *
         * // Structure to hold tab for gtr_beg
         * // public NoteObject begNotes;
         *
         * // Structure to hold audio effect for gtr_jam
         * // public AudioEffectObject begEffect;
         *
         * // Structures to hold information about bss_nov
         * public StringTable fre_bssNov;
         * public StringTable eng_bssNov;
         * public StringTable jap_bssNov;
         * public StringTable esp_bssNov;
         * public StringTable ger_bssNov;
         * public StringTable ita_bssNov;
         * // public JamObject zobj_bssNov;
         *
         * // Structure to hold bss)nov instrument info
         * // public InstrumentInfo instrument_bssNov;
         *
         * // Structure to hold tab for bss_nov;
         * // public NoteObject bss_novNotes;
         *
         * // Structures to hold lyrics
         * public StringTable freLyrics;
         * public StringTable engLyrics;
         * public StringTable japLyrics;
         * public StringTable espLyrics;
         * public StringTable gerLyrics;
         * public StringTable itaLyrics;
         *
         * // Structure to hold vox instrument information
         * // public InstrumentInfo instrument_vox;
         *
         * // Structure to hold vox push phrase info
         * // public VoxPushPhrase pushPhrase;
         *
         * // Structure to hold vocals notes
         * // public VocalsNoteObject voxNotes;
         *
         * // Structure to hold bss_beg instrument info
         * // public InstrumentInfo instrument_bssBeg;
         *
         * // Structures to hold information about bss_beg
         * public StringTable fre_bssBeg;
         * public StringTable eng_bssBeg;
         * public StringTable jap_bssBeg;
         * public StringTable esp_bssBeg;
         * public StringTable ger_bssBeg;
         * public StringTable ita_bssBeg;
         * // public JamObject zobj_bssBeg;
         *
         * // Structure to hold audio effect for bss_beg
         * // public AudioEffectObject bss_begEffect;
         *
         * // Structure to hold tab for bss_beg
         * // public NoteObject bss_begNotes;
         *
         * // Structures to hold information about gtr_nov
         * public StringTable fre_gtrNov;
         * public StringTable eng_gtrNov;
         * public StringTable jap_gtrNov;
         * public StringTable esp_gtrNov;
         * public StringTable ger_gtrNov;
         * public StringTable ita_gtrNov;
         * // public JamObject zobj_gtrNov;
         *
         * // Structure to hold instrument info about gtr_nov
         * // public InstrumentInfo instrument_gtrNov;
         *
         * // Structure to hold notes for gtr_nov
         * // public NoteObject gtr_novNotes;
         *
         * // Structure to hold audio effect for gtr_nov
         * // public AudioEffectObject gtr_novEffect;
         *
         * // Structure to hold texture information
         * // public TextureObject texture;
         *
         * // Structures to hold preview information
         * public StringTable frePreview;
         * public StringTable engPreview;
         * public StringTable japPreview;
         * public StringTable espPreview;
         * public StringTable gerPreview;
         * public StringTable itaPreview;
         * // public PreviewObject preview;
         *
         * // Structure to hold gtr_adv information
         * // public InstrumentInfo instrument_gtrAdv;
         *
         * // Structures to hold gtr_adv chords
         * public StringTable fre_gtrAdv_chords;
         * public StringTable eng_gtrAdv_chords;
         * public StringTable jap_gtrAdv_chords;
         * public StringTable esp_gtrAdv_chords;
         * public StringTable ger_gtrAdv_chords;
         * public StringTable ita_gtrAdv_chords;
         * // public ChordObject gtrAdv_chord;
         *
         * // Structure to hold gtr_adv AudioEffect
         * // public AudioEffectObject gtr_advEffect;
         *
         * // Structure to hold gtr_adv events
         * // public EventObject gtr_advEvents;
         *
         * // Structure to hold gtr_adv tab
         * // public NoteObject gtr_advNotes;
         *
         * // Structures to hold info for GTR2
         * public StringTable freGtr2;
         * public StringTable engGtr2;
         * public StringTable japGtr2;
         * public StringTable espGtr2;
         * public StringTable gerGtr2;
         * public StringTable itaGtr2;
         * // public StemObject gtr2_stem;
         *
         * // Structure to hold bss_jam information
         * // public InstrumentInfo instrument_bssJam;
         *
         * // Structures to hold info for bss_jam
         * public StringTable fre_bssJam;
         * public StringTable eng_bssJam;
         * public StringTable jap_bssJam;
         * public StringTable esp_bssJam;
         * public StringTable ger_bssJam;
         * public StringTable ita_bssJam;
         *
         * // Structure to hold bss_jam AudioEffect
         * // public AudioEffectObject bss_jamEffect;
         *
         * // Structure to hold tab for bss_jam
         * // public NoteObject bss_jamNotes;
         *
         * // Structures to hold info for gtr_int chords
         * public StringTable fre_gtrInt_chords;
         * public StringTable eng_gtrInt_chords;
         * public StringTable jap_gtrInt_chords;
         * public StringTable esp_gtrInt_chords;
         * public StringTable ger_gtrInt_chords;
         * public StringTable ita_gtrInt_chords;
         * // public ChordObject gtrInt_chord;
         *
         * // Structure to hold gtr_int information
         * // public InstrumentInfo instrument_gtrInt;
         *
         * // Structure to hold gtr_int AudioEffect
         * // public AudioEffectObject gtr_intEffect;
         *
         * // Structure to hold tab for gtr_int
         * // public NoteObject gtr_intNotes;
         *
         * // Structures to hold info for gtr_rhy chords
         * public StringTable fre_gtrRhy_chords;
         * public StringTable eng_gtrRhy_chords;
         * public StringTable jap_gtrRhy_chords;
         * public StringTable esp_gtrRhy_chords;
         * public StringTable ger_gtrRhy_chords;
         * public StringTable ita_gtrRhy_chords;
         * // public ChordObject gtrRhy_chord;
         *
         * // Structure to hold gtr_rhy information
         * // public InstrumentInfo instrument_gtrRhy;
         *
         * // Structure to hold gtr_rhy AudioEffect
         * // public AudioEffectObject gtr_rhyEffect;
         *
         * // Structure to hold tab for gtr_rhy
         * // public NoteObject gtr_rhyNotes;
         *
         * // Structures to hold info for bass stems
         * public StringTable fre_stems_bass;
         * public StringTable eng_stems_bass;
         * public StringTable jap_stems_bass;
         * public StringTable esp_stems_bass;
         * public StringTable ger_stems_bass;
         * public StringTable ita_stems_bass;
         * // public StemObject bass_stem;
         *
         * // Structures to hold info for GTR1 stems
         * public StringTable fre_stems_GTR1;
         * public StringTable eng_stems_GTR1;
         * public StringTable jap_stems_GTR1;
         * public StringTable esp_stems_GTR1;
         * public StringTable ger_stems_GTR1;
         * public StringTable ita_stems_GTR1;
         * // public StemObject GTR1_stem;
         *
         * // Structures to hold info for drum stems
         * public StringTable fre_stems_drums;
         * public StringTable eng_stems_drums;
         * public StringTable jap_stems_drums;
         * public StringTable esp_stems_drums;
         * public StringTable ger_stems_drums;
         * public StringTable ita_stems_drums;
         * // public StemObject drums_stem;
         *
         * // Structures to hold info for bss_adv
         * public StringTable fre_bssAdv;
         * public StringTable eng_bssAdv;
         * public StringTable jap_bssAdv;
         * public StringTable esp_bssAdv;
         * public StringTable ger_bssAdv;
         * public StringTable ita_bssAdv;
         *
         * // Structure to hold bss_adv information
         * // public InstrumentInfo instrument_bssAdv;
         *
         * // Structure to hold bss_adv AudioEffect
         * // public AudioEffectObject bss_advEffect;
         *
         * // Structure to hold tab for bss_adv
         * // public NoteObject bss_advNotes;
         *
         * // Structure to hold bss_adv events
         * // public EventObject bss_advEvents;*/

        /// <summary>
        /// Parses out the fused.rif file.
        /// </summary>
        /// <param name="file_bytes">Byte representation of the fused.rif file we are analyzing.</param>
        /// <param name="indexDictionary">Dictionary to check keys against.</param>
        public ChartParser(string filepath, StringTable indexDictionary)
        {
            string     fused_filepath = filepath;
            FileStream file           = System.IO.File.OpenRead(fused_filepath);

            byte[] file_bytes = new byte[file.Length];

            file.Read(file_bytes, 0, file_bytes.Length);
            file.Close();

            parser           = new StringTableParser();
            list_stringtable = new List <StringTable>();
            tempList         = new List <tempZOBJ>();

            // Skip the first twelve bytes, unnecessary for parsing.  We will
            // skip the index section of the file, as it is useless to us.
            int index       = 12;
            int indx_length = 0;

            byte[] indx_length_byte = new byte[4];
            int    temp             = index;

            for (; index < temp + 4; index++)
            {
                indx_length_byte[index - temp] = file_bytes[index];
            }

            indx_length = BitConverter.ToInt32(indx_length_byte.Reverse().ToArray(), 0);
            index      += indx_length;

            while (index < file_bytes.Length)
            {
                // Test to print out a section name
                string sectionName      = "";
                byte[] sectionName_byte = new byte[4];
                temp = index;
                for (; index < temp + 4; index++)
                {
                    sectionName_byte[index - temp] = file_bytes[index];
                }

                sectionName = System.Text.Encoding.Default.GetString(sectionName_byte.Reverse().ToArray());

                // Get the section size, skip it
                int    section_length      = 0;
                byte[] section_length_byte = new byte[4];
                temp = index;

                for (; index < temp + 4; index++)
                {
                    section_length_byte[index - temp] = file_bytes[index];
                }

                section_length = BitConverter.ToInt32(section_length_byte.Reverse().ToArray(), 0);

                // Copy data into a byte array
                temp = index;
                byte[] section_byte = new byte[section_length];

                for (; index < temp + section_length; index++)
                {
                    section_byte[index - temp] = file_bytes[index];
                }

                switch (sectionName)
                {
                case "ZOBJ":
                    zobjHelper(section_byte);
                    break;

                case "STbl":
                    stblHelper(section_byte);
                    break;

                default:
                    break;
                }

                // Fix any lingering issues
                if (file_bytes.Length - index < 4)
                {
                    index = file_bytes.Length;
                }
            }

            int i = 0;

            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("gtr_adv.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("gtr_rhy.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("gtr_nov.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("gtr_beg.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("gtr_int.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("gtr_jam.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("bss_adv.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("bss_nov.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("bss_beg.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("bss_int.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("bss_jam.tab"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateRawData();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("tempo"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateTempo();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("measure"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateMeasure();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("timesignature"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateTimeSignature();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }

            i = 0;
            foreach (tempZOBJ elem in tempList)
            {
                if (indexDictionary.stringTable[elem.indexKey].Contains("vox.vox") && !indexDictionary.stringTable[elem.indexKey].Contains("vox.voxpushphrase"))
                {
                    Console.WriteLine(indexDictionary.stringTable[elem.indexKey]);

                    tempZOBJ newElem = tempList[i];
                    newElem.rawData = generateVocals();
                    tempList[i]     = newElem;
                    break;
                }

                i++;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Deals with all forms of string tables
        /// </summary>
        /// <param name="section">Object section to analyze</param>
        private void zobjHelper(byte[] section)
        {
            // Get the index key
            int   index = 0;
            ulong indexKey;

            byte[] indexKey_byte = new byte[8];

            int i = index;

            for (; index < i + 8; index++)
            {
                indexKey_byte[index - i] = section[index];
            }

            indexKey = BitConverter.ToUInt64(indexKey_byte.Reverse().ToArray(), 0);

            // Get the object key
            ulong objectKey;

            byte[] objectKey_byte = new byte[8];

            i = index;
            for (; index < i + 8; index++)
            {
                objectKey_byte[index - i] = section[index];
            }

            objectKey = BitConverter.ToUInt64(objectKey_byte.Reverse().ToArray(), 0);

            // Get the type string key
            ulong typeStringKey;

            byte[] typeStringKey_byte = new byte[8];

            i = index;
            for (; index < i + 8; index++)
            {
                typeStringKey_byte[index - i] = section[index];
            }

            typeStringKey = BitConverter.ToUInt64(typeStringKey_byte.Reverse().ToArray(), 0);

            // Skip zeroed data
            index += 8;

            int size_raw = section.Length - index;

            byte[] section_raw_byte = new byte[size_raw];
            i = index;

            for (; index < i + size_raw; index++)
            {
                section_raw_byte[index - i] = section[index];
            }

            tempZOBJ temp = new tempZOBJ();

            temp.indexKey      = indexKey;
            temp.objectKey     = objectKey;
            temp.typeStringKey = typeStringKey;
            temp.rawData       = section_raw_byte;

            tempList.Add(temp);
        }