/// <summary>
        /// Clones MIDI file by creating a copy of it.
        /// </summary>
        /// <returns>Copy of the MIDI file.</returns>
        public MidiFile Clone()
        {
            var result = new MidiFile(Chunks.Select(c => c.Clone()))
            {
                TimeDivision = TimeDivision.Clone()
            };

            result._originalFormat = _originalFormat;

            return(result);
        }
 /// <summary>
 /// Writes content of a <see cref="HeaderChunk"/>.
 /// </summary>
 /// <remarks>
 /// Content of a <see cref="HeaderChunk"/> is format of the file, number of track chunks and time division.
 /// Six bytes required to write all of this information.
 /// </remarks>
 /// <param name="writer">Writer to write the chunk's content with.</param>
 /// <param name="settings">Settings according to which the chunk's content must be written.</param>
 /// <exception cref="ObjectDisposedException">Method was called after the writer's underlying stream was disposed.</exception>
 /// <exception cref="IOException">An I/O error occurred on the writer's underlying stream.</exception>
 protected override void WriteContent(MidiWriter writer, WritingSettings settings)
 {
     writer.WriteWord(FileFormat);
     writer.WriteWord(TracksNumber);
     writer.WriteInt16(TimeDivision.ToInt16());
 }