Accord.Audio.Formats.DataChunk.GetBytes C# (CSharp) Method

GetBytes() public method

public GetBytes ( ) : byte[]
return byte[]
        public byte[] GetBytes()
        {
            int rawsize = Marshal.SizeOf(this);
            byte[] rawdata = new byte[rawsize];
            GCHandle handle = GCHandle.Alloc(rawdata, GCHandleType.Pinned);
            IntPtr buffer = handle.AddrOfPinnedObject();
            Marshal.StructureToPtr(this, buffer, false);
            handle.Free();
            return rawdata;
        }
    }

Usage Example

Ejemplo n.º 1
0
        private void updateHeaders()
        {
            header.Length = this.bytes;
            byte[] dataHeader = header.GetBytes();

            riff.Length = this.bytes + dataHeader.Length + waveFormat.Length;
            byte[] riffHeader = riff.GetBytes();

            waveStream.Write(riffHeader, 0, riffHeader.Length);
            waveStream.Write(waveFormat, 0, waveFormat.Length);
            waveStream.Write(dataHeader, 0, dataHeader.Length);
        }
DataChunk