/// <summary>
 /// Initializes a new instance of the TimeSignatureBuilder class with the 
 /// specified MetaMessage.
 /// </summary>
 /// <param name="message">
 /// The MetaMessage to use for initializing the TimeSignatureBuilder class.
 /// </param>
 /// <exception cref="ArgumentException">
 /// If the specified MetaMessage is not a time signature type.
 /// </exception>
 /// <remarks>
 /// The TimeSignatureBuilder uses the specified MetaMessage to 
 /// initialize its property values.
 /// </remarks>
 public TimeSignatureBuilder(MetaMessage message)
 {
     Initialize(message);
 }
 /// <summary>
 /// Builds the time signature MetaMessage.
 /// </summary>
 public void Build()
 {
     // If any of the properties have changed since the last time the
     // message was built.
     if(changed)
     {
         result = new MetaMessage(MetaType.TimeSignature, data);
         changed = false;
     }
 }
        /// <summary>
        /// Initializes the TimeSignatureBuilder with the specified MetaMessage.
        /// </summary>
        /// <param name="message">
        /// The MetaMessage to use for initializing the TimeSignatureBuilder. 
        /// </param>
        /// <exception cref="ArgumentException">
        /// If the specified MetaMessage is not a time signature type.
        /// </exception>
        public void Initialize(MetaMessage message)
        {
            #region Require

            if(message.MetaType != MetaType.TimeSignature)
            {
                throw new ArgumentException("Wrong meta event type.", "message");
            }

            #endregion

            data = message.GetBytes();
        }
 /// <summary>
 /// Initialize a new instance of the TempoChangeBuilder class with the 
 /// specified MetaMessage.
 /// </summary>
 /// <param name="message">
 /// The MetaMessage to use for initializing the TempoChangeBuilder class.
 /// </param>
 /// <exception cref="ArgumentException">
 /// If the specified MetaMessage is not a tempo type.
 /// </exception>
 /// <remarks>
 /// The TempoChangeBuilder uses the specified MetaMessage to initialize 
 /// its property values.
 /// </remarks>
 public TempoChangeBuilder(MetaMessage e)
 {
     Initialize(e);
 }
 public MetaMessageEventArgs(MetaMessage message)
 {
     this.message = message;
 }
        /// <summary>
        /// Builds the tempo change MetaMessage.
        /// </summary>
        public void Build()
        {
            // If the tempo has been changed since the last time the message
            // was built.
            if(changed)
            {
                byte[] data = new byte[MetaMessage.TempoLength];

                // If this platform uses little endian byte order.
                if(BitConverter.IsLittleEndian)
                {
                    int d = data.Length - 1;

                    // Unpack tempo.
                    for(int i = 0; i < data.Length; i++)
                    {
                        data[d] = (byte)(tempo >> (Shift * i));
                        d--;
                    }
                }
                // Else this platform uses big endian byte order.
                else
                {
                    // Unpack tempo.
                    for(int i = 0; i < data.Length; i++)
                    {
                        data[i] = (byte)(tempo >> (Shift * i));
                    }
                }

                changed = false;

                result = new MetaMessage(MetaType.Tempo, data);
            }
        }
        /// <summary>
        /// Initializes the TempoChangeBuilder with the specified MetaMessage.
        /// </summary>
        /// <param name="message">
        /// The MetaMessage to use for initializing the TempoChangeBuilder.
        /// </param>
        /// <exception cref="ArgumentException">
        /// If the specified MetaMessage is not a tempo type.
        /// </exception>
        public void Initialize(MetaMessage e)
        {
            #region Require

            if(e == null)
            {
                throw new ArgumentNullException("e");
            }
            else if(e.MetaType != MetaType.Tempo)
            {
                throw new ArgumentException("Wrong meta message type.", "e");
            }

            #endregion

            int t = 0;

            // If this platform uses little endian byte order.
            if(BitConverter.IsLittleEndian)
            {
                int d = e.Length - 1;

                // Pack tempo.
                for(int i = 0; i < e.Length; i++)
                {
                    t |= e[d] << (Shift * i);
                    d--;
                }
            }
            // Else this platform uses big endian byte order.
            else
            {
                // Pack tempo.
                for(int i = 0; i < e.Length; i++)
                {
                    t |= e[i] << (Shift * i);
                }
            }

            tempo = t;
        }
Beispiel #8
0
 public TimeSignatureMessage(MetaMessage msg)
 {
     this.msg = msg;
 }
Beispiel #9
0
        private void Write(MetaMessage message)
        {
            trackData.Add((byte)message.Status);
            trackData.Add((byte)message.MetaType);

            WriteVariableLengthValue(message.Length);

            trackData.AddRange(message.GetBytes());
        }
Beispiel #10
0
 public TempoMessage(MetaMessage msg)
 {
     this.msg = msg;
 }
Beispiel #11
0
        /// <summary>
        /// Indicates whether or not the specified MetaType is a text based 
        /// type.
        /// </summary>
        /// <param name="type">
        /// The MetaType to test.
        /// </param>
        /// <returns>
        /// <b>true</b> if the MetaType is a text based type; 
        /// otherwise, <b>false</b>.
        /// </returns>
        private bool IsTextType(MetaType type)
        {
            bool result;

            if(type == MetaType.Copyright ||
                type == MetaType.CuePoint ||
                type == MetaType.DeviceName ||
                type == MetaType.InstrumentName ||
                type == MetaType.Lyric ||
                type == MetaType.Marker ||
                type == MetaType.ProgramName ||
                type == MetaType.Text ||
                type == MetaType.TrackName)
            {
                result = true;
            }
            else
            {
                result = false;
            }

            return result;
        }
Beispiel #12
0
        /// <summary>
        /// Initializes the MetaMessageTextBuilder with the specified MetaMessage.
        /// </summary>
        /// <param name="message">
        /// The MetaMessage to use for initializing the MetaMessageTextBuilder.
        /// </param>
        /// <exception cref="ArgumentException">
        /// If the MetaMessage is not a text based type.
        /// </exception>
        public void Initialize(MetaMessage message)
        {
            #region Require

            if(!IsTextType(message.MetaType))
            {
                throw new ArgumentException("Not text based meta message.",
                    "message");
            }

            #endregion

            ASCIIEncoding encoding = new ASCIIEncoding();

            text = encoding.GetString(message.GetBytes());
            this.type = message.MetaType;
        }
Beispiel #13
0
        /// <summary>
        /// Builds the text MetaMessage.
        /// </summary>
        public void Build()
        {
            // If the text has changed since the last time this method was
            // called.
            if(changed)
            {
                //
                // Build text MetaMessage.
                //

                ASCIIEncoding encoding = new ASCIIEncoding();
                byte[] data = encoding.GetBytes(text);
                result = new MetaMessage(Type, data);
                changed = false;
            }
        }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the MetaMessageTextBuilder class with the
 /// specified MetaMessage.
 /// </summary>
 /// <param name="message">
 /// The MetaMessage to use for initializing the MetaMessageTextBuilder.
 /// </param>
 /// <exception cref="ArgumentException">
 /// If the MetaMessage is not a text based type.
 /// </exception>
 /// <remarks>
 /// The MetaMessage must be one of the following text based types:
 /// <list>
 /// <item>
 /// Copyright
 /// </item>
 /// <item>
 /// Cuepoint
 /// </item>
 /// <item>
 /// DeviceName
 /// </item>
 /// <item>
 /// InstrumentName
 /// </item>
 /// <item>
 /// Lyric
 /// </item>
 /// <item>
 /// Marker
 /// </item>
 /// <item>
 /// ProgramName
 /// </item>
 /// <item>
 /// Text
 /// </item>
 /// <item>
 /// TrackName
 /// </item>
 /// </list>
 /// If the MetaMessage is not a text based type, an exception will be 
 /// thrown.
 /// </remarks>
 public MetaTextBuilder(MetaMessage message)
 {
     Initialize(message);
 }