public void WriteHeaders(int channels, int sampleRate, ushort preSkip) { var opusHead = new OpusHead { Version = 1, OutputChannelCount = (byte)channels, PreSkip = preSkip, InputSampleRate = (uint)sampleRate, OutputGain = 0, ChannelMappingFamily = 0 }; Span <byte> span = stackalloc byte[opusHead.Size]; var opusHeadSpanWriter = new SpanWriter(span); opusHeadSpanWriter.WriteOpusHead(opusHead); WriteOggPage(OggHeaderType.BeginningOfStream, opusHeadSpanWriter.ToArray()); span.Clear(); var opusTags = new OpusTags(); var opusTagsSpanWriter = new SpanWriter(span); opusTagsSpanWriter.WriteOpusTags(opusTags); WriteOggPage(OggHeaderType.None, opusTagsSpanWriter.ToArray()); }