public SoundBankMusicTrack(EndianReader reader, uint id)
        {
            ID = id;

            reader.Skip(0xC);
            AudioID = reader.ReadUInt32();
            SourceID = reader.ReadUInt32();
        }
        public SoundBankVoice(EndianReader reader, uint id)
        {
            ID = id;

            reader.Skip(4);
            StorageType = (SoundStorageType)reader.ReadInt32();
            AudioID = reader.ReadUInt32();
            SourceID = reader.ReadUInt32();
        }
 public SoundBankFile(SoundBank parent, EndianReader reader)
 {
     ParentBank = parent;
     ID = reader.ReadUInt32();
     Offset = reader.ReadInt32();
     Size = reader.ReadInt32();
 }
        public SoundInfo(EndianReader reader)
        {
            OverrideParentEffectSettings = (reader.ReadByte() != 0);

            ReadEffects(reader);

            BusID = reader.ReadUInt32();
            ParentID = reader.ReadUInt32();

            OverrideParentPrioritySettings = (reader.ReadByte() != 0);
            OffsetPriorityAtMaxDistance = (reader.ReadByte() != 0);

            byte numParameters = reader.ReadByte();
            // TODO: actually store the parameter values instead of skipping over them
            reader.Skip(numParameters);
            reader.Skip(numParameters * 4);

            sbyte unknownCount = reader.ReadSByte();
            if (unknownCount > 0)
            {
                reader.Skip(unknownCount);
                reader.Skip(unknownCount * 8);
            }

            ReadPositioningInfo(reader);

            // Read auxiliary send settings
            OverrideParentGameDefinedAuxiliarySendSettings = (reader.ReadByte() != 0);
            UseGameDefinedAuxiliarySends = (reader.ReadByte() != 0);
            OverrideParentUserDefinedAuxiliarySendSettings = (reader.ReadByte() != 0);
            ReadUserDefinedAuxiliarySends(reader);

            bool unknown = (reader.ReadByte() != 0);
            /*if (unknown)
                reader.Skip(4);*/

            // Read voice settings
            LimitMethod = (SoundLimitMethod)reader.ReadSByte();
            VirtualVoiceBehavior = (SoundVirtualVoiceBehavior)reader.ReadSByte();
            OverrideParentPlaybackLimitSettings = (reader.ReadByte() != 0);
            OverrideParentVirtualVoiceSettings = (reader.ReadByte() != 0);

            ReadStateGroups(reader);
            ReadRTPCs(reader);

            reader.Skip(4); // I think this is part of the sound info data...
        }
 public SoundPackFile(SoundPack parent, EndianReader reader)
 {
     ParentPack = parent;
     ID = reader.ReadUInt32();
     reader.Skip(4); // Flags?
     Size = reader.ReadInt32();
     Offset = reader.ReadInt32();
     FolderID = reader.ReadInt32();
 }
        public SoundBankEvent(EndianReader reader, uint id)
        {
            ID = id;

            // Read the action list
            int numActions = reader.ReadInt32();
            ActionIDs = new uint[numActions];
            for (int i = 0; i < numActions; i++)
                ActionIDs[i] = reader.ReadUInt32();
        }
        public SoundBankAction(EndianReader reader, uint id)
        {
            ID = id;

            Type = (SoundBankActionType)reader.ReadSByte();
            Scope = (SoundBankActionScope)reader.ReadSByte();
            ObjectID = reader.ReadUInt32();

            // TODO: read parameters and state/switch group IDs
        }
        public StateGroup(EndianReader reader)
        {
            ID = reader.ReadUInt32();
            ChangeMoment = (StateGroupChangeMoment)reader.ReadSByte();

            // Read custom states
            short numCustomStates = reader.ReadInt16();
            CustomStates = new CustomState[numCustomStates];
            for (short i = 0; i < numCustomStates; i++)
                CustomStates[i] = new CustomState(reader);
        }
        public SoundBankMusicSegment(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read child IDs
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
        public SoundBankActorMixer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Actor-mixers are just a list of children
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
Esempio n. 11
0
        public RTPC(EndianReader reader)
        {
            XAxisParameterID = reader.ReadUInt32();
            YAxisType = (RTPCYAxisType)reader.ReadInt32();

            reader.Skip(5);
            short numPoints = reader.ReadInt16();
            Points = new RTPCPoint[numPoints];

            // Read points
            for (byte i = 0; i < numPoints; i++)
                Points[i] = new RTPCPoint(reader);
        }
        public SoundBankMusicPlaylist(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read segment IDs
            int numSegments = reader.ReadInt32();
            SegmentIDs = new uint[numSegments];
            for (int i = 0; i < numSegments; i++)
                SegmentIDs[i] = reader.ReadUInt32();

            // TODO: read the rest of the data
        }
        public SoundBankSequenceContainer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // hax
            reader.Skip(0x18);

            // Read child IDs
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
        public SoundBankMusicSwitchContainer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read segment IDs
            // TODO: this is pretty similar to SoundBankMusicPlaylist,
            // maybe this can be factored out into a common class somehow?
            int numSegments = reader.ReadInt32();
            SegmentIDs = new uint[numSegments];
            for (int i = 0; i < numSegments; i++)
                SegmentIDs[i] = reader.ReadUInt32();

            // TODO: read the rest of the data
        }
Esempio n. 15
0
        public UVDataBlock_3001(EndianReader reader, bool loadMesh, Vertex[] Vertices)
            : base(reader, 0x3001)
        {
            DataCount = reader.ReadInt32(); //vCount

            x2E00 = reader.ReadInt16(); //2E00
            reader.EndianType = EndianFormat.BigEndian;

            unkUV0 = reader.ReadInt16(); //flags? 0x1C00 when world
            unkUV1 = reader.ReadByte();
            unkUV2 = reader.ReadByte();
            unkUV3 = reader.ReadByte();
            unkUV4 = reader.ReadByte(); //0x00 when world, else 0x20
            DataSize = reader.ReadByte();

            if (!loadMesh) reader.SeekTo(EOBOffset);
            else for (int i = 0; i < DataCount; i++)
            {
                Vector tex0 = new Vector();

                #region switch
                switch (DataSize)
                {
                    case 8:
                        tex0 = Vector.FromUByteN4(reader.ReadUInt32());
                        reader.Skip(0);
                        break;
                    case 12:
                        reader.Skip(4);
                        break;
                    case 16:
                        reader.Skip(12);
                        break;
                    case 20:
                        reader.Skip(16);
                        break;
                    case 24:
                        reader.Skip(16);
                        break;
                    case 28:
                        reader.Skip(20);
                        break;
                    case 32:
                        reader.Skip(16);
                        break;
                    case 36:
                        reader.Skip(24);
                        break;
                    case 44:
                        reader.Skip(28);
                        break;
                }
                #endregion

                int u = reader.ReadInt16();
                int v = reader.ReadInt16();

                //var tex0 = new RealQuat(((float)a + (float)0) / (float)0xFFFF, ((float)b + (float)0) / (float)0xFFFF);
                var tex1 = new Vector((float)u / (float)(0x7FFF), (float)v / (float)(0x7FFF));

                #region switch
                switch (DataSize)
                {
                    case 8:
                        reader.Skip(0);
                        break;
                    case 12:
                        reader.Skip(4);
                        break;
                    case 16:
                        reader.Skip(0);
                        break;
                    case 20:
                        reader.Skip(0);
                        break;
                    case 24:
                        reader.Skip(4);
                        break;
                    case 28:
                        reader.Skip(4);
                        break;
                    case 32:
                        reader.Skip(12);
                        break;
                    case 36:
                        reader.Skip(8);
                        break;
                    case 44:
                        reader.Skip(12);
                        break;
                }
                #endregion

                //Vertices[i].Values.Add(new VertexValue(tex0, 0, "normal", 0));
                Vertices[i].Values.Add(new VertexValue(tex1, VertexValue.ValueType.Int16_N2, "texcoords", 0));
            }

            reader.EndianType = EndianFormat.LittleEndian;
        }
Esempio n. 16
0
        public Block_3301(EndianReader reader, bool loadSkin, Vertex[] Vertices)
            : base(reader, 0x3301)
        {
            FirstNodeID = reader.ReadInt16();
            NodeCount = reader.ReadInt16();

            if (!loadSkin) reader.Skip(Vertices.Length * 4);
            else foreach (var v in Vertices)
                {
                    var val = Vector.FromUByte4(reader.ReadUInt32());
                    nodes.Add(val);
                    v.Values.Add(new VertexValue(val, VertexValue.ValueType.UInt8_4, "blendindices", 0));
                }
        }
Esempio n. 17
0
 public Block_1A01(EndianReader reader, bool loadSkin, Vertex[] Vertices)
     : base(reader, 0x1A01)
 {
     if (!loadSkin) reader.Skip(Vertices.Length * 4);
     else foreach (var v in Vertices)
         {
             var val = Vector.FromUByteN4(reader.ReadUInt32());
             v.Values.Add(new VertexValue(val, VertexValue.ValueType.UInt8_4, "blendweight", 0));
         }
 }
Esempio n. 18
0
 private void ReadEffects(EndianReader reader)
 {
     byte numEffects = reader.ReadByte();
     if (numEffects > 0)
     {
         EffectBypassMask = reader.ReadByte();
         EffectIDs = new uint[numEffects];
         for (byte i = 0; i < numEffects; i++)
         {
             reader.Skip(1); // Effect index, useless
             EffectIDs[i] = reader.ReadUInt32();
             reader.Skip(2);
         }
     }
     else
     {
         EffectIDs = new uint[0];
     }
 }
Esempio n. 19
0
        private void ReadPositioningInfo(EndianReader reader)
        {
            HasPositioning = (reader.ReadByte() != 0);
            if (!HasPositioning)
                return;

            PositionType = (SoundPositionType)reader.ReadByte();
            if (PositionType == SoundPositionType.Position2D)
            {
                EnablePanner = (reader.ReadByte() != 0);
            }
            else
            {
                PositionSourceType = (SoundPositionSourceType)reader.ReadInt32();
                AttenuationID = reader.ReadUInt32();
                EnableSpatialization = (reader.ReadByte() != 0);

                if (PositionSourceType == SoundPositionSourceType.UserDefined)
                {
                    PlayType = (SoundPlayType)reader.ReadInt32();
                    Loop = (reader.ReadByte() != 0);
                    TransitionTime = reader.ReadUInt32();
                    FollowListenerOrientation = (reader.ReadByte() != 0);

                    ReadPaths(reader);
                }
                else if (PositionSourceType == SoundPositionSourceType.GameDefined)
                {
                    UpdateEachFrame = (reader.ReadByte() != 0);
                }
            }
        }
 public CustomState(EndianReader reader)
 {
     ID = reader.ReadUInt32();
     SettingsID = reader.ReadUInt32();
 }
Esempio n. 21
0
 private void ReadUserDefinedAuxiliarySends(EndianReader reader)
 {
     HasUserDefinedAuxiliarySends = (reader.ReadByte() != 0);
     if (HasUserDefinedAuxiliarySends)
     {
         AuxiliaryBusIDs = new uint[4];
         for (int i = 0; i < 4; i++)
             AuxiliaryBusIDs[i] = reader.ReadUInt32();
     }
     else
     {
         AuxiliaryBusIDs = new uint[0];
     }
 }
Esempio n. 22
0
        private void ReadHeader(EndianReader reader)
        {
            reader.EndianType = EndianFormat.BigEndian;// Endianness = Endian.BigEndian;
            reader.SeekTo(0);

            // Validate the magic number at the beginning
            if (reader.ReadUInt32() != HeaderMagic)
                throw new InvalidOperationException("Invalid sound pack magic");

            reader.Skip(4 * 2); // Skip two unknown uint32s

            // Read the size of the folder list (needed to find the start of the file table)
            _folderListSize = reader.ReadInt32();
        }
Esempio n. 23
0
 private void ReadHeader(EndianReader reader)
 {
     reader.Skip(4);
     ID = reader.ReadUInt32();
 }
Esempio n. 24
0
        private void ReadObjects(EndianReader reader)
        {
            int numObjects = reader.ReadInt32();
            long offset = reader.Position;

            for (int i = 0; i < numObjects; i++)
            {
                // Read the object's header
                ObjectType type = (ObjectType)reader.ReadSByte();
                int size = reader.ReadInt32();
                offset += 5;

                // Read the object's ID
                uint id = reader.ReadUInt32();

                // Read the rest of the object based upon its type
                IWwiseObject obj = null;
                switch (type)
                {
                    case ObjectType.Voice:
                        obj = new SoundBankVoice(reader, id);
                        break;

                    case ObjectType.Action:
                        obj = new SoundBankAction(reader, id);
                        break;

                    case ObjectType.Event:
                        SoundBankEvent ev = new SoundBankEvent(reader, id);
                        _eventsById[ev.ID] = ev;
                        obj = ev;
                        break;

                    case ObjectType.SequenceContainer:
                        obj = new SoundBankSequenceContainer(reader, id);
                        break;

                    case ObjectType.SwitchContainer:
                        obj = new SoundBankSwitchContainer(reader, id);
                        break;

                    case ObjectType.ActorMixer:
                        obj = new SoundBankActorMixer(reader, id);
                        break;

                    case ObjectType.MusicPlaylistContainer:
                        obj = new SoundBankMusicPlaylist(reader, id);
                        break;

                    case ObjectType.MusicSegment:
                        obj = new SoundBankMusicSegment(reader, id);
                        break;

                    case ObjectType.MusicTrack:
                        obj = new SoundBankMusicTrack(reader, id);
                        break;

                    case ObjectType.MusicSwitchContainer:
                        obj = new SoundBankMusicSwitchContainer(reader, id);
                        break;
                }

                // Register the object if something was read
                if (obj != null)
                    _objects.Add(obj);

                // Skip to the next object
                offset += size;
                reader.SeekTo(offset);
            }
        }
Esempio n. 25
0
        public VertexValue(XmlNode Node, EndianReader reader)
        {
            if (Convert.ToInt32(Node.Attributes["stream"].Value) > 0) throw new NotSupportedException("Multi-streamed vertices not supported");
            Type = (ValueType)Enum.Parse(typeof(ValueType), Node.Attributes["type"].Value);
            Usage = Node.Attributes["usage"].Value;
            UsageIndex = Convert.ToInt32(Node.Attributes["usageIndex"].Value);
            
            switch (Type)
            {
                case ValueType.Float32_2:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Float32_3:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Float32_4:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Int8_N4:
                    Data = new Vector((float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F);
                    break;

                case ValueType.UInt8_2:
                    Data = new Vector(reader.ReadByte(), reader.ReadByte(), 0, 0);
                    break;

                case ValueType.UInt8_3:
                    Data = new Vector(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), 0);
                    break;

                case ValueType.UInt8_4:
                    Data = Vector.FromUByte4(reader.ReadUInt32());
                    break;

                case ValueType.UInt8_N2:
                    Data = new Vector((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0, 0);
                    break;

                case ValueType.UInt8_N3:
                    Data = new Vector((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0);
                    break;

                case ValueType.UInt8_N4:
                    Data = Vector.FromUByteN4(reader.ReadUInt32());
                    break;

                case ValueType.Int16_N3:
                    Data = new Vector(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, 0);
                    break;

                case ValueType.Int16_N4:
                    Data = new Vector(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF);
                    break;

                case ValueType.UInt16_2:
                    Data = new Vector(reader.ReadUInt16(), reader.ReadUInt16());
                    break;

                case ValueType.UInt16_4:
                    Data = new Vector(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16());
                    break;

                case ValueType.UInt16_N2:
                    Data = new Vector((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                    break;

                case ValueType.UInt16_N4:
                    Data = new Vector((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                    break;

                case ValueType.DecN4:
                    Data = Vector.FromDecN4(reader.ReadUInt32());
                    break;

                case ValueType.UDecN4:
                    Data = Vector.FromUDecN4(reader.ReadUInt32());
                    break;

                case ValueType.DHenN3:
                    Data = Vector.FromDHenN3(reader.ReadUInt32());
                    break;

                case ValueType.UDHenN3:
                    Data = Vector.FromUDHenN3(reader.ReadUInt32());
                    break;

                case ValueType.HenDN3:
                    Data = Vector.FromHenDN3(reader.ReadUInt32());
                    break;

                case ValueType.UHenDN3:
                    Data = Vector.FromUHenDN3(reader.ReadUInt32());
                    break;

                case ValueType.Float16_2:
                    Data = new Vector(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                    break;

                case ValueType.Float16_4:
                    Data = new Vector(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                    break;

                case ValueType.D3DColour:
                    reader.ReadUInt32();
                    break;
            }
        }