Ejemplo n.º 1
0
        public byte[] getData()
        {
            var       ms = new MemoryStream();
            FileWrite fr = new FileWrite(ms);

            fr._file.Write(_unk_field32_1);
            fr._file.Write(_unk_field32_2);
            fr._file.Write(_unk_field32_3);
            fr._file.Write(_id1);

            if (_id1 > 0)
            {
                fr._file.Write(_id2);
                fr._file.Write(_unk_field32_4);
                fr._file.Write(_unk_field32_5);
                fr._file.Write(_unk_field8_1);
                fr._file.Write(_id3);
                fr._file.Write(_unk_field64_1);
                fr._file.Write(_unk_field64_2);
                fr._file.Write(_unk_field64_3);
                fr._file.Write(_time_length);
            }
            if (_unk_data != null)
            {
                fr._file.Write(_unk_data);
            }

            byte[] result = ms.ToArray();
            fr._file.Close();

            return(result);
        }
Ejemplo n.º 2
0
        public byte[] getData()
        {
            var       ms = new MemoryStream();
            FileWrite fr = new FileWrite(ms);

            fr._file.Write(_sound_structure.getData().ToCharArray());
            fr._file.Write(_children);
            foreach (uint id in _child_ids)
            {
                fr._file.Write(id);
            }

            fr._file.Write(_unk_double_1);
            fr._file.Write(_unk_field64_1);
            fr._file.Write(_tempo);
            fr._file.Write(_time_sig1);
            fr._file.Write(_time_sig2);
            fr._file.Write(_unk_field32_1);
            fr._file.Write(_unk_field8_1);
            fr._file.Write(_time_length);
            fr._file.Write(_unk_field32_2);
            fr._file.Write(_unk_field32_3);
            fr._file.Write(_unk_field64_2);
            fr._file.Write(_unk_field32_4);
            fr._file.Write(_unk_field32_5);
            fr._file.Write(_time_length_next);
            fr._file.Write(_unk_field32_6);

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

            byte[] result = ms.ToArray();
            fr._file.Close();

            return(result);
        }
Ejemplo n.º 3
0
        public byte[] getData()
        {
            var       ms = new MemoryStream();
            FileWrite fr = new FileWrite(ms);

            fr._file.Write(_unk_field32_1);
            fr._file.Write((UInt32)_include_type);
            fr._file.Write((UInt32)_audio_id);
            fr._file.Write((UInt32)_source_id);

            if (_include_type == SOUND_EMBEDED)
            {
                fr._file.Write((UInt32)_offset);
                fr._file.Write((UInt32)_size);
            }
            fr._file.Write(_sound_type);
            fr._file.Write(_sound_structure);

            byte[] result = ms.ToArray();
            fr._file.Close();

            return(result);
        }
Ejemplo n.º 4
0
        public byte[] getData()
        {
            var       ms = new MemoryStream();
            FileWrite fr = new FileWrite(ms);

            fr._file.Write(_unk_field32_1);
            fr._file.Write(_unk_field32_2);
            fr._file.Write(_unk_field32_3);
            fr._file.Write(_id1);
            fr._file.Write(_id2);
            fr._file.Write(_unk_field32_4);
            fr._file.Write(_unk_field32_5);
            fr._file.Write(_unk_field8_1);
            fr._file.Write(_id3);
            fr._file.Write(_unk_field64_1);
            fr._file.Write(_unk_field64_2);
            fr._file.Write(_unk_field64_3);
            fr._file.Write(_time_length);
            fr._file.Write(_unk_field32_6);
            fr._file.Write(_unk_field64_4);
            fr._file.Write(_unk_field16_1);
            fr._file.Write(_parent);
            fr._file.Write(_unk_field64_5);
            fr._file.Write(_unk_field8_2);
            fr._file.Write(_unk_field32_7);
            fr._file.Write(_unk_field64_6);
            fr._file.Write(_unk_field64_7);
            fr._file.Write(_unk_field16_2);
            fr._file.Write(_unk_field8_3);
            fr._file.Write(_unk_field32_8);

            byte[] result = ms.ToArray();
            fr._file.Close();

            return(result);
        }
Ejemplo n.º 5
0
        public void build_bnk(string outpath)
        {
            if (_isInit)
            {
                Console.WriteLine("Soundbank : Rebuilding init.bnk is 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();
        }
Ejemplo n.º 6
0
        public byte[] getData()
        {
            var       ms = new MemoryStream();
            FileWrite fr = new FileWrite(ms);

            fr._file.Write(_sound_structure.getData());
            fr._file.Write(_segments);
            foreach (uint id in _segment_ids)
            {
                fr._file.Write(id);
            }
            fr._file.Write(_unk_double_1);
            fr._file.Write(_unk_field64_1);
            fr._file.Write(_tempo);
            fr._file.Write(_time_sig1);
            fr._file.Write(_time_sig2);
            fr._file.Write(_unk_field8_1);
            fr._file.Write(_transition_count);

            foreach (MusicPlaylistObject_Transition mt in _transitions)
            {
                fr._file.Write(mt._source_id);
                fr._file.Write(mt._dest_id);
                fr._file.Write(mt._source_fadeout);
                fr._file.Write(mt._source_shape_curve_fadeout);
                fr._file.Write(mt._source_fadeout_offset);
                fr._file.Write(mt._unk_field32_1);
                fr._file.Write(mt._unk_field32_2);
                fr._file.Write(mt._unk_field32_3);
                fr._file.Write(mt._src_type);
                fr._file.Write(mt._dest_fadein);
                fr._file.Write(mt._dest_shape_curve_fadein);
                fr._file.Write(mt._dest_fadein_offset);
                fr._file.Write(mt._unk_field32_4);
                fr._file.Write(mt._unk_field32_5);
                fr._file.Write(mt._unk_field16_1);
                fr._file.Write(mt._dest_type);
                fr._file.Write(mt._unk_field8_1);
                fr._file.Write(mt._has_segment);
                fr._file.Write(mt._trans_segment_id);
                fr._file.Write(mt._trans_fadein);
                fr._file.Write(mt._trans_shape_curve_fadein);
                fr._file.Write(mt._trans_fadein_offset);
                fr._file.Write(mt._trans_fadeout);
                fr._file.Write(mt._trans_shape_curve_fadeout);
                fr._file.Write(mt._trans_fadeout_offset);
                fr._file.Write(mt._trans_fadein_type);
                fr._file.Write(mt._trans_fadeout_type);
            }

            fr._file.Write(_playlist_elements_count);

            foreach (MusicPlaylistObject_PlaylistElement mp in _playlist_elements)
            {
                fr._file.Write(mp._music_segment_id);
                fr._file.Write(mp._id);
                fr._file.Write(mp._child_elements);
                fr._file.Write(mp._playlist_type);
                fr._file.Write(mp._loop_count);
                fr._file.Write(mp._weight);
                fr._file.Write(mp._times_in_row);
                fr._file.Write(mp._unk_field8_1);
                fr._file.Write(mp._random_type);
            }

            byte[] result = ms.ToArray();
            fr._file.Close();

            return(result);
        }
        public string getData()
        {
            var       ms = new MemoryStream();
            FileWrite fr = new FileWrite(ms);

            fr._file.Write(_effects_override);
            fr._file.Write(_effects_count);

            if (_effects_count > 0)
            {
                fr._file.Write(_effects_bitmask);
                foreach (SoundStructure_Effect se in _effects)
                {
                    fr._file.Write(se._index);
                    fr._file.Write(se._id);
                    fr._file.Write(se._unk_field16_1);
                }
            }

            fr._file.Write(_output_bus_id);
            fr._file.Write(_parent_id);
            fr._file.Write(_override_playback_priority);
            fr._file.Write(_offset_priority);
            fr._file.Write(_additional_parameters_count);

            foreach (SoundStructure_Additional sa in _additional_parameters)
            {
                fr._file.Write(sa._type);
            }
            foreach (SoundStructure_Additional sa in _additional_parameters)
            {
                if (sa._type == 0x07)
                {
                    fr._file.Write(sa._value_u);
                }
                else
                {
                    fr._file.Write(sa._value_f);
                }
            }

            fr._file.Write(_unk_field8_1);
            fr._file.Write(_has_positioning);

            if (_has_positioning)
            {
                fr._file.Write(_positioning_type);
                if (_positioning_type == 0x2D)
                {
                    fr._file.Write(_enable_panner);
                }
                else if (_positioning_type == 0x3D)
                {
                    fr._file.Write(_position_source);
                    fr._file.Write(_attenuation_id);
                    fr._file.Write(_enable_spatialization);
                    if (_position_source == 0x02)
                    {
                        fr._file.Write(_play_type);
                        fr._file.Write(_do_loop);
                        fr._file.Write(_transition_time);
                        fr._file.Write(_follow_listener_orientation);
                    }
                    else if (_position_source == 0x03)
                    {
                        fr._file.Write(_update_at_each_frame);
                    }
                }
                else if (_positioning_type == 0x01)
                {
                    fr._file.Write(_unk_field16_1);
                }
                else
                {
                    fr._file.Write(_unk_field32_1);
                    fr._file.Write(_unk_field32_2);
                }
            }

            fr._file.Write(_override_game_auxiliary_sends);
            fr._file.Write(_use_game_auxiliary_sends);
            fr._file.Write(_override_user_auxiliary_sends);
            fr._file.Write(_user_auxiliary_sends_exists);

            if (_user_auxiliary_sends_exists)
            {
                fr._file.Write(_auxiliary_bus_id0);
                fr._file.Write(_auxiliary_bus_id1);
                fr._file.Write(_auxiliary_bus_id2);
                fr._file.Write(_auxiliary_bus_id3);
            }

            fr._file.Write(_unk_field8_2);

            if (_unk_field8_2)
            {
                fr._file.Write(_priority_equal);
                fr._file.Write(_limit_reached);
                fr._file.Write(_limit_sound_instances);
            }

            fr._file.Write(_how_to_limit_sound_instances);
            fr._file.Write(_virtual_voice_behavior);
            fr._file.Write(_override_playback_limit);
            fr._file.Write(_override_virtual_voice);

            fr._file.Write(_state_groups_count);
            foreach (SoundStructure_StateGroup ss in _state_groups)
            {
                fr._file.Write(ss._id);
                fr._file.Write(ss._change_occurs);
                fr._file.Write(ss._different);

                for (int i = 0; i < ss._different; i++)
                {
                    fr._file.Write(ss._ids[i]);
                    fr._file.Write(ss._ids_object_contain[i]);
                }
            }

            fr._file.Write(_rtpc_count);
            foreach (SoundStructure_RTPC sr in _rtpcs)
            {
                fr._file.Write(sr._x_axis_id);
                fr._file.Write(sr._y_axis_type);
                fr._file.Write(sr._unk_field32_1);
                fr._file.Write(sr._unk_field8_1);
                fr._file.Write(sr._points_count);
                fr._file.Write(sr._unk_field8_2);

                for (int i = 0; i < sr._points_count; i++)
                {
                    fr._file.Write(sr._x_coordinates[i]);
                    fr._file.Write(sr._y_coordinates[i]);
                    fr._file.Write(sr._curve_shape[i]);
                }
            }

            fr._file.Write(_unk_field32_3);

            if (_unk_data != "")
            {
                fr._file.Write(_unk_data);
            }

            string result = new String(ms.ToArray().ToList().Select(x => (char)x).ToArray());

            fr._file.Close();

            return(result);
        }