Exemple #1
0
        private static string DescribeNumber(int type, byte[] bytes)
        {
            int n = MidiMetaEvent.GetDataLength(type);

            if (bytes.Length < n)
            {
                return(null);
            }
            return(Midi.ReadNumber(bytes, 0, n).ToString());
        }
Exemple #2
0
        private static string DescribeTempo(byte[] bytes)
        {
            int n = MidiMetaEvent.GetDataLength(MidiMetaEvent.SetTempoType);

            if (bytes.Length < n)
            {
                return(null);
            }
            n = Midi.ReadNumber(bytes, 0, n);
            return(string.Format("{0} {1} ({2} {3})", n, Properties.Resources.MicrosecondsPerQuarterNote,
                                 (n == 0) ? double.PositiveInfinity : (60000000 / n), Properties.Resources.BeatsPerMinute));
        }
Exemple #3
0
 /// <summary>Reads a number as an integer (in network byte order) from this file's byte array.</summary>
 /// <param name="offset">
 /// Offset into the byte array at which the number is stored (most significant byte first).
 /// </param>
 /// <param name="length">The number of bytes to read (should not be greater than 4).</param>
 /// <returns>The number that is read.</returns>
 public int ReadNumber(int offset, int length)
 {
     return(Midi.ReadNumber(this.Bytes, offset, length));
 }
Exemple #4
0
        /// <summary>Attempts to convert the data bytes of a meta-event to a MidiKeySignature value.</summary>
        /// <param name="bytes">The data bytes of the event.</param>
        /// <returns>
        /// The data bytes converted to a MidiKeySignature value, or MidiKeySignature.NA if the data could not be converted.
        /// </returns>
        public static MidiKeySignature DataToKeySignature(byte[] bytes)
        {
            int n = Midi.ReadNumber(bytes, 0, bytes.Length);

            return(Enum.IsDefined(typeof(MidiKeySignature), n) ? (MidiKeySignature)n : MidiKeySignature.NA);
        }