Exemplo n.º 1
0
        protected override void ReadChunk(IntPtr ptr, int chunkSize, string chunkType)
        {
            switch (chunkType)
            {
            case "dlid":
            case "guid":
                break;

            case "fmt ":
                Format = Marshal.PtrToStructure <CK_FMT>(ptr);
                break;

            case "data":
                Data = new byte[chunkSize];
                Marshal.Copy(ptr, Data, 0, Data.Length);
                break;

            case "wsmp":
                Sampler = Marshal.PtrToStructure <CK_WSMP>(ptr);
                var pLoop = ptr + Marshal.SizeOf <CK_WSMP>();
                for (var i = 0; i < Sampler.LoopCount; ++i)
                {
                    Loops.Add(Loops.Count, Marshal.PtrToStructure <WaveLoop>(pLoop));
                    pLoop += Marshal.SizeOf <WaveLoop>();
                }
                break;
            }
        }
Exemplo n.º 2
0
        protected override void ReadChunk(IntPtr ptr, int chunkSize, string chunkType)
        {
            switch (chunkType)
            {
            case "rgnh":
                Header = Marshal.PtrToStructure <CK_RGNH>(ptr);
                if (chunkSize < Marshal.SizeOf <CK_RGNH>())
                {
                    Header.Layer = 0;
                }
                break;

            case "wsmp":
                Sampler = Marshal.PtrToStructure <CK_WSMP>(ptr);
                var pLoop = ptr + Marshal.SizeOf <CK_WSMP>();
                for (var i = 0; i < Sampler.LoopCount; ++i)
                {
                    Loops.Add(Loops.Count, Marshal.PtrToStructure <WaveLoop>(pLoop));
                    pLoop += Marshal.SizeOf <WaveLoop>();
                }
                break;

            case "wlnk":
                WaveLink = Marshal.PtrToStructure <CK_WLNK>(ptr);
                break;

            default:
                throw new Exception(string.Format("Unknown ChunkType [{0}]", chunkType));
            }
        }