26 using SiliconStudio.Core;
28 namespace SiliconStudio.Paradox.Audio.Wave
33 internal class RiffChunk
44 public RiffChunk(
Stream stream, FourCC type, uint
size, uint dataPosition,
bool isList =
false,
bool isHeader =
false)
49 DataPosition = dataPosition;
62 public FourCC Type {
get;
private set; }
67 public uint Size {
get;
private set; }
72 public uint DataPosition {
get;
private set; }
80 public bool IsList {
get;
private set; }
88 public bool IsHeader {
get;
private set; }
94 public byte[] GetData()
96 var data =
new byte[Size];
97 Stream.Position = DataPosition;
98 Stream.Read(data, 0, (int)Size);
109 public unsafe T GetDataAs<T>() where T :
struct
112 var data = GetData();
113 fixed (
void* ptr = data)
115 Utilities.Read((IntPtr)ptr, ref value);
125 public unsafe T[] GetDataAsArray<T>() where T :
struct
127 int sizeOfT = Utilities.SizeOf<T>();
128 if ((Size % sizeOfT) != 0)
129 throw new ArgumentException(
"Size of T is incompatible with size of chunk");
131 var values =
new T[Size / sizeOfT];
132 var data = GetData();
133 fixed (
void* ptr = data)
135 Utilities.Read((IntPtr)ptr, values, 0, values.Length);
146 public override string ToString()
148 return string.Format(System.Globalization.CultureInfo.InvariantCulture,
"Type: {0}, Size: {1}, Position: {2}, IsList: {3}, IsHeader: {4}", Type, Size, DataPosition, IsList, IsHeader);
_In_ size_t _In_ size_t size