protected internal override SoundEffect Read( ContentReader input, SoundEffect existingInstance ) { // Format block length uint formatLength = input.ReadUInt32(); // Wavedata format ushort format = input.ReadUInt16(); // Number of channels ushort channels = input.ReadUInt16(); // Sample rate uint sampleRate = input.ReadUInt32(); // Averate bytes per second, unused input.ReadUInt32(); // Block alignment, needed for MSADPCM ushort blockAlign = input.ReadUInt16(); // Bit depth ushort bitDepth = input.ReadUInt16(); // cbSize, unused input.ReadUInt16(); // Seek past the rest of this crap input.BaseStream.Seek(formatLength - 18, SeekOrigin.Current); // Wavedata byte[] data = input.ReadBytes(input.ReadInt32()); // Loop information uint loopStart = input.ReadUInt32(); uint loopLength = input.ReadUInt32(); // Sound duration in milliseconds, unused input.ReadUInt32(); return(new SoundEffect( input.AssetName, data, sampleRate, channels, loopStart, loopLength, format == 2, (uint)((format == 2) ? (((blockAlign / channels) - 6) * 2) : (bitDepth / 16)) )); }
protected internal override SoundEffect Read( ContentReader input, SoundEffect existingInstance ) { /* Swap endian - this is one of the very few places requiring this! * Note: This only affects the fmt chunk that's glued into the file. */ bool se = input.platform == 'x'; // Format block length uint formatLength = input.ReadUInt32(); // WaveFormatEx data ushort wFormatTag = Swap(se, input.ReadUInt16()); ushort nChannels = Swap(se, input.ReadUInt16()); uint nSamplesPerSec = Swap(se, input.ReadUInt32()); uint nAvgBytesPerSec = Swap(se, input.ReadUInt32()); ushort nBlockAlign = Swap(se, input.ReadUInt16()); ushort wBitsPerSample = Swap(se, input.ReadUInt16()); /* ushort cbSize =*/ input.ReadUInt16(); // Seek past the rest of this crap (cannot seek though!) input.ReadBytes((int)(formatLength - 18)); // Wavedata byte[] data = input.ReadBytes(input.ReadInt32()); // Loop information int loopStart = input.ReadInt32(); int loopLength = input.ReadInt32(); // Sound duration in milliseconds, unused input.ReadUInt32(); return(new SoundEffect( input.AssetName, data, 0, data.Length, wFormatTag, nChannels, nSamplesPerSec, nAvgBytesPerSec, nBlockAlign, wBitsPerSample, loopStart, loopLength )); }
protected internal override SoundEffect Read( ContentReader input, SoundEffect existingInstance ) { // Format block length uint formatLength = input.ReadUInt32(); // WaveFormatEx data ushort wFormatTag = input.ReadUInt16(); ushort nChannels = input.ReadUInt16(); uint nSamplesPerSec = input.ReadUInt32(); uint nAvgBytesPerSec = input.ReadUInt32(); ushort nBlockAlign = input.ReadUInt16(); ushort wBitsPerSample = input.ReadUInt16(); /* ushort cbSize =*/ input.ReadUInt16(); // Seek past the rest of this crap (cannot seek though!) input.ReadBytes((int)(formatLength - 18)); // Wavedata byte[] data = input.ReadBytes(input.ReadInt32()); // Loop information int loopStart = input.ReadInt32(); int loopLength = input.ReadInt32(); // Sound duration in milliseconds, unused input.ReadUInt32(); return(new SoundEffect( input.AssetName, data, 0, data.Length, wFormatTag, nChannels, nSamplesPerSec, nAvgBytesPerSec, nBlockAlign, wBitsPerSample, loopStart, loopLength )); }
internal static SkinnedModelBone Read(ContentReader input) { // Read bone data ushort index = input.ReadUInt16(); string name = input.ReadString(); // Read bind pose Pose bindPose; bindPose.Translation = input.ReadVector3(); bindPose.Orientation = input.ReadQuaternion(); bindPose.Scale = input.ReadVector3(); Matrix inverseBindPoseTransform = input.ReadMatrix(); SkinnedModelBone skinnedBone = new SkinnedModelBone(index, name, bindPose, inverseBindPoseTransform); // Read bone parent input.ReadSharedResource<SkinnedModelBone>( delegate(SkinnedModelBone parentBone) { skinnedBone.parent = parentBone; }); // Read bone children int numChildren = input.ReadInt32(); List<SkinnedModelBone> childrenList = new List<SkinnedModelBone>(numChildren); for (int i = 0; i < numChildren; i++) { input.ReadSharedResource<SkinnedModelBone>( delegate(SkinnedModelBone childBone) { childrenList.Add(childBone); }); } skinnedBone.children = new SkinnedModelBoneCollection(childrenList); return skinnedBone; }
protected internal override ushort Read(ContentReader input, ushort existingInstance) { return(input.ReadUInt16()); }
protected internal override SoundEffect Read( ContentReader input, SoundEffect existingInstance ) { /* Swap endian - this is one of the very few places requiring this! * Note: This only affects the fmt chunk that's glued into the file. */ bool se = input.platform == 'x'; // Format block length uint formatLength = input.ReadUInt32(); // WaveFormatEx data ushort wFormatTag = Swap(se, input.ReadUInt16()); ushort nChannels = Swap(se, input.ReadUInt16()); uint nSamplesPerSec = Swap(se, input.ReadUInt32()); uint nAvgBytesPerSec = Swap(se, input.ReadUInt32()); ushort nBlockAlign = Swap(se, input.ReadUInt16()); ushort wBitsPerSample = Swap(se, input.ReadUInt16()); byte[] extra = null; if (formatLength > 16) { ushort cbSize = Swap(se, input.ReadUInt16()); if (wFormatTag == 0x166 && cbSize == 34) { // XMA2 has got some nice extra crap. extra = new byte[34]; using (MemoryStream extraStream = new MemoryStream(extra)) using (BinaryWriter extraWriter = new BinaryWriter(extraStream)) { // See FAudio.FAudioXMA2WaveFormatEx for the layout. extraWriter.Write(Swap(se, input.ReadUInt16())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(Swap(se, input.ReadUInt32())); extraWriter.Write(input.ReadByte()); extraWriter.Write(input.ReadByte()); extraWriter.Write(Swap(se, input.ReadUInt16())); } // Is there any crap that needs skipping? Eh whatever. input.ReadBytes((int)(formatLength - 18 - 34)); } else { // Seek past the rest of this crap (cannot seek though!) input.ReadBytes((int)(formatLength - 18)); } } // Wavedata byte[] data = input.ReadBytes(input.ReadInt32()); // Loop information int loopStart = input.ReadInt32(); int loopLength = input.ReadInt32(); // Sound duration in milliseconds, unused input.ReadUInt32(); return(new SoundEffect( input.AssetName, data, 0, data.Length, extra, wFormatTag, nChannels, nSamplesPerSec, nAvgBytesPerSec, nBlockAlign, wBitsPerSample, loopStart, loopLength )); }