예제 #1
0
        public void debugSound()
        {
            Console.WriteLine("--- Header Start ---");
            Console.WriteLine("Head : " + _header._head);
            Console.WriteLine("Length : " + _header._length);
            Console.WriteLine("Version : " + _header._version);
            Console.WriteLine("ID : " + _header._id);
            Console.WriteLine("UNK Field32 1 : " + _header._unk_field32_1);
            Console.WriteLine("UNK Field32 2 : " + _header._unk_field32_2);

            if (_header._unk_data != null)
            {
                Console.WriteLine("UNK Data Length : " + _header._unk_data.Length);
            }
            Console.WriteLine("--- Header ---");
            Console.WriteLine("");

            if (!_isInit)
            {
                if (_dataIndex != null && _dataIndex._isSet)
                {
                    Console.WriteLine("--- Data Index Start ---");
                    Console.WriteLine("Head : " + _dataIndex._head);
                    Console.WriteLine("Length : " + _dataIndex._length);

                    int i = 1;
                    foreach (WEM w in _dataIndex._data_info)
                    {
                        Console.WriteLine("Data info " + i + " : (ID: " + w._id + "), (Offset: " + w._offset + "), (Size: " + w._size + ")");
                        i++;
                    }
                    Console.WriteLine("--- Data Index End ---");
                    Console.WriteLine("");
                }

                if (_data != null && _data._isSet)
                {
                    Console.WriteLine("--- Data Start ---");
                    Console.WriteLine("Head : " + _data._head);
                    Console.WriteLine("Length (Non padded) : " + _dataIndex.get_total_size());
                    Console.WriteLine("Length : " + _data._length);
                    Console.WriteLine("Offset : " + _data._offset);
                    Console.WriteLine("--- Data End ---");
                    Console.WriteLine("");
                }
            }
            else
            {
                if (_stmg != null && _stmg._isSet)
                {
                    Console.WriteLine("--- Manager Start ---");
                    Console.WriteLine("Head : " + _stmg._head);
                    Console.WriteLine("Length : " + _stmg._length);
                    Console.WriteLine("Volume : " + _stmg._volume);
                    Console.WriteLine("Max voice instances : " + _stmg._max_voice_instances);
                    Console.WriteLine("State groups : " + _stmg._state_groups_count);
                    Console.WriteLine("Switch groups : " + _stmg._switch_groups_count);
                    Console.WriteLine("Game parameters : " + _stmg._game_parameters_count);
                    Console.WriteLine("--- Manager End ---");
                    Console.WriteLine("");
                }
            }

            Console.WriteLine("--- Objects Start ----");
            Console.WriteLine("Head : " + _objects._head);
            Console.WriteLine("Length : " + _objects._length);
            Console.WriteLine("Quantity : " + _objects._quantity);

            var objTypes = new Dictionary <byte, int>();

            foreach (SBObject obj in _objects._objects)
            {
                if (objTypes.ContainsKey(obj._type))
                {
                    objTypes[obj._type] += 1;
                }
                else
                {
                    objTypes.Add(obj._type, 1);
                }
            }

            foreach (KeyValuePair <byte, int> t in objTypes)
            {
                Console.WriteLine("Type " + t.Key + " : " + t.Value);
            }
            Console.WriteLine("--- Objects End ---");
            Console.WriteLine("");

            if (!_isInit)
            {
                if (_stid != null && _stid._isSet)
                {
                    Console.WriteLine("--- Sound type id Start ---");
                    Console.WriteLine("Head : " + _stid._head);
                    Console.WriteLine("Length : " + _stid._length);
                    Console.WriteLine("UNK Field32 1 : " + _stid._unk_field32_1);
                    Console.WriteLine("Quantity : " + _stid._quantity);
                    Console.WriteLine("Remaining size : " + _stid._remaining.Length);
                    Console.WriteLine("--- Sound type id End ---");
                    Console.WriteLine("");
                }
                else if (_envs != null && _envs._isSet)
                {
                    Console.WriteLine("--- Environments Start ---");
                    Console.WriteLine("Head : " + _envs._head);
                    Console.WriteLine("Length : " + _envs._length);
                    Console.WriteLine("Unk data length : " + _envs._unk_data.Length);
                    Console.WriteLine("--- Environments End ---");
                    Console.WriteLine("");
                }
            }
        }
예제 #2
0
파일: Soundbank.cs 프로젝트: q4a/Wolven-kit
        public void build_bnk(string outpath)
        {
            if (_isInit)
            {
                Console.WriteLine("Sound bank: Rebuilding init.bnk not yet supported.");
                return;
            }

            FileWrite fw = new FileWrite(outpath ?? _fileName + ".wkrebuilt");

            fw._file.Write(_header._head.ToCharArray());
            fw._file.Write((UInt32)_header._length);
            fw._file.Write((UInt32)_header._version);
            fw._file.Write((UInt32)_header._id);
            fw._file.Write((UInt32)_header._unk_field32_1);
            fw._file.Write((UInt32)_header._unk_field32_2);

            if (_header._unk_data != null)
            {
                fw._file.Write(_header._unk_data);
            }

            if (_dataIndex != null && _dataIndex._isSet)
            {
                _dataIndex.calculate_offset();
                fw._file.Write(_dataIndex._head.ToCharArray());
                fw._file.Write((UInt32)_dataIndex._length);

                foreach (var info in _dataIndex._data_info)
                {
                    fw._file.Write((UInt32)info._id);
                    fw._file.Write((UInt32)info._offset);
                    fw._file.Write((UInt32)info._size);
                }
            }
            if (_data != null && _data._isSet)
            {
                fw._file.Write(_data._head.ToCharArray());
                fw._file.Write((UInt32)_dataIndex.get_total_size());

                _data._offset = (uint)fw.getPosition();
                foreach (var info in _dataIndex._data_info)
                {
                    fw._file.Write(info._data);
                }
            }

            fw._file.Write(_objects._head.ToCharArray());
            fw._file.Write((UInt32)_objects._length);
            fw._file.Write((UInt32)_objects._quantity);

            foreach (var obj in _objects._objects)
            {
                fw._file.Write((byte)obj._type);
                fw._file.Write((UInt32)obj._length);
                fw._file.Write((UInt32)obj._id);

                if (obj._type == SBObject.TYPE_SOUND)
                {
                    if (obj._obj_so._include_type == SBSoundObject.SOUND_EMBEDED && _dataIndex != null && _dataIndex._isSet)
                    {
                        uint offset = obj._obj_so._offset;
                        uint size   = obj._obj_so._size;
                        bool bSet   = true;
                        try
                        {
                            offset = _data._offset + (uint)_dataIndex.get_offset(obj._obj_so._audio_id);
                            size   = (uint)_dataIndex.get_size(obj._obj_so._audio_id);
                        }
                        catch
                        {
                            bSet = false;
                        }
                        if (bSet)
                        {
                            obj._obj_so._offset = offset;
                            obj._obj_so._size   = size;
                        }
                    }
                }

                fw._file.Write(obj.getData());
            }

            if (_stid != null && _stid._isSet)
            {
                fw._file.Write(_stid._head.ToCharArray());
                fw._file.Write((UInt32)_stid._length);
                fw._file.Write((UInt32)_stid._unk_field32_1);
                fw._file.Write((UInt32)_stid._quantity);
                fw._file.Write(_stid._remaining);
            }

            fw._file.Close();
        }