MIDI file time division.
Time division specifies the meaning of the delta-times of events. There are two types of the time division: ticks per quarter note and SMPTE. Time division of the first type has bit 15 set to 0. In this case bits 14 thru 0 represent the number of ticks which make up a quarter-note. Division of the second type has bit 15 set to 1. In this case bits 14 thru 8 contain one of the four values: -24, -25, -29, or -30, corresponding to the four standard SMPTE and MIDI Time Code formats (-29 corresponds to 30 drop frame), and represents the number of frames per second. Bits 7 thru 0 (which represent a byte stored positive) is the resolution within a frame: typical values may be 4 (MIDI Time Code resolution), 8, 10, 80 (bit resolution), or 100.
Example #1
0
        /// <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>
 /// Handles finish of header chunk reading. Called after header chunk is read.
 /// </summary>
 /// <param name="timeDivision">Time division of the file is being read.</param>
 /// <remarks>
 /// This method called within <see cref="TargetScope.File"/> scope.
 /// </remarks>
 public virtual void OnFinishHeaderChunkReading(TimeDivision timeDivision)
 {
 }
 /// <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());
 }