示例#1
0
        /*
        ** CHUNKS DO NOT HAVE __ANY__ OFFSET POINTERS, LOCATION IS COMPLETELY VARIABLE **
        **  Chunks must be aligned multiple of 4 bytes of one another.
        **  JAIV2 IBNK Structure
        **  ??? ENVT - Envelope Table
        **  ??? OSCT - Oscillator Table
        **  ??? RAND - Random Effects Table
        **  ??? SENS - Sensor Effect Table
        **  ??? INST - Instrument Table
        **  ??? PMAP - Percussion Map
        **  ??? LIST - Instrument List
        */
        public JIBank loadIBNK(BeBinaryReader binStream, int Base)
        {
            Console.WriteLine("Start load ibnk");
            var RetIBNK = new JIBank();

            Console.WriteLine(Base);
            iBase = Base;
            if (binStream.ReadInt32() != IBNK)
            {
                throw new InvalidDataException("Section doesn't have an IBNK header");
            }
            Boundaries      = binStream.ReadInt32() + 8;             // total length of our section, the data of the section starts at +8, so we need to account for that, too.
            RetIBNK.id      = binStream.ReadInt32();                 // Forgot this. Ibank ID. Important.
            OscTableOffset  = findChunk(binStream, OSCT);            // Load oscillator table chunk
            EnvTableOffset  = findChunk(binStream, ENVT);            // Load envelope table chunk
            RanTableOffset  = findChunk(binStream, RAND);            // Load random effect table chunk
            SenTableOffset  = findChunk(binStream, SENS);            // Load sensor table chunk
            ListTableOffset = findChunk(binStream, LIST);            // load the istrument list
            PmapTableOffset = findChunk(binStream, PMAP);            // Percussion mapping lookup table

            binStream.BaseStream.Position = OscTableOffset + iBase;  // Seek to the position of the oscillator table
            loadBankOscTable(binStream, Base);                       // Load oscillator table, also handles the ENVT!!
            binStream.BaseStream.Position = ListTableOffset + iBase; // Seek to the instrument list base
            var instruments = loadInstrumentList(binStream, Base);   // Load it.

            RetIBNK.Instruments = instruments;
            return(RetIBNK);
        }
示例#2
0
        private short currentBankID = 0; // also runtime -- just for tracking
        public JIBank loadIBNK(BeBinaryReader binStream, int Base)
        {
            var RetIBNK = new JIBank();

            binStream.BaseStream.Position = Base;
            long anchor = 0; // Return / Seekback anchor

            //binStream.BaseStream.Seek(-4, SeekOrigin.Current);
            if (binStream.ReadInt32() != IBNK) // Check if first 4 bytes are IBNK
            {
                throw new InvalidDataException("Data is not an IBANK");
            }
            var SectionSize = binStream.ReadUInt32(); // Read IBNK Size
            var IBankID     = binStream.ReadInt32();  // Read the global IBankID

            currentBankID = (short)IBankID;
            var IBankFlags = binStream.ReadUInt32();             // Flags?

            binStream.BaseStream.Seek(0x10, SeekOrigin.Current); // Skip Padding
            anchor = binStream.BaseStream.Position;
            var Instruments = loadBank(binStream, Base);         // Load the instruments

            RetIBNK.id          = IBankID;                       // Store bankID
            RetIBNK.Instruments = Instruments;                   // Store instruments

            return(RetIBNK);
        }