public static byte[] GetHeader( int numChannels, int sampleRate, int numBytes )
{
byte[] header;
int val;
int offset;
header = new byte[ 44 ];
Buffer.BlockCopy( __canonicalHeader, 0, header, 0, 44 );
// Chunk size
offset = 4;
val = numBytes - 8; //Chunk size
Buffer.BlockCopy( BitConverter.GetBytes( ( Int32 )val ), 0, header, offset, 4 );
// SubChunk1 size
offset = 16;
val = 16;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int32 )val ), 0, header, offset, 4 );
// Format 1
offset = 20;
val = 1;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int16 )val ), 0, header, offset, 2 );
// NumChannels
offset = 22;
val = numChannels;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int16 )val ), 0, header, offset, 2 );
// SampleRate
offset = 24;
val = sampleRate;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int32 )val ), 0, header, offset, 4 );
// ByteRate
offset = 28;
val = sampleRate * numChannels * 16 / 8;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int32 )val ), 0, header, offset,4 );
// BlockAlign
offset = 32;
val = numChannels * 2;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int16 )val ), 0, header, offset, 2 );
// BitDepth
offset = 34;
val = 16;
Buffer.BlockCopy( BitConverter.GetBytes( ( Int16 )val ), 0, header, offset, 2 );
// Data size
offset = 40;
val = numBytes - headerSize; //Chunk size
Buffer.BlockCopy( BitConverter.GetBytes( ( Int32 )val ), 0, header, offset, 4 );
return header;
}