Ejemplo n.º 1
0
        /// <summary>
        /// Sends a system realtime message.
        /// </summary>
        /// <param name="message">
        /// The system realtime message to send.
        /// </param>
        /// <exception cref="OutputDeviceException">
        /// Thrown if an error occurred while sending the message.
        /// </exception>
        public void Send(SysRealtimeMessage message)
        {
            // Guard.
            if (!IsOpen())
            {
                return;
            }

            ThrowOnError(midiOutShortMsg(handle, message.Message));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines the type of message received and triggers the correct
        /// event in response.
        /// </summary>
        /// <param name="message">
        /// The short Midi message received.
        /// </param>
        /// <param name="timeStamp">
        /// Number of milliseconds that have passed since the input device
        /// began recording.
        /// </param>
        private void DispatchShortMessage(int message, int timeStamp)
        {
            // Unpack status value.
            int status = ShortMessage.UnpackStatus(message);

            // If a channel message was received.
            if (ChannelMessage.IsChannelMessage(status))
            {
                // If anyone is listening for channel messages.
                if (ChannelMessageReceived != null)
                {
                    // Create channel message.
                    ChannelMessage msg = new ChannelMessage(message);

                    // Create channel message event argument.
                    ChannelMessageEventArgs e =
                        new ChannelMessageEventArgs(msg, timeStamp);

                    // Trigger channel message received event.
                    ChannelMessageReceived(this, e);
                }
            }
            // Else if a system common message was received
            else if (SysCommonMessage.IsSysCommonMessage(status))
            {
                // If anyone is listening for system common messages
                if (SysCommonReceived != null)
                {
                    // Create system common message.
                    SysCommonMessage msg = new SysCommonMessage(message);

                    // Create system common event argument.
                    SysCommonEventArgs e = new SysCommonEventArgs(msg, timeStamp);

                    // Trigger system common received event.
                    SysCommonReceived(this, e);
                }
            }
            // Else if a system realtime message was received
            else if (SysRealtimeMessage.IsSysRealtimeMessage(status))
            {
                // If anyone is listening for system realtime messages
                if (SysRealtimeReceived != null)
                {
                    // Create system realtime message.
                    SysRealtimeMessage msg = new SysRealtimeMessage(message);

                    // Create system realtime event argument.
                    SysRealtimeEventArgs e = new SysRealtimeEventArgs(msg, timeStamp);

                    // Trigger system realtime received event.
                    SysRealtimeReceived(this, e);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the SysRealtimeMessage class with a
        /// system realtime message packed as an integer.
        /// </summary>
        /// <param name="message">
        /// The packed system realtime message to use for initialization.
        /// </param>
        public SysRealtimeMessage(int message)
        {
            // Enforce preconditions.
            if (!SysRealtimeMessage.IsSysRealtimeMessage(message))
            {
                throw new ArgumentException(
                          "Message is not a system realtime message.", "message");
            }

            // Initialize type.
            Type = (SysRealtimeType)message;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="message"></param>
 public virtual void Visit(SysRealtimeMessage message)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Sends a system realtime message.
        /// </summary>
        /// <param name="message">
        /// The system realtime message to send.
        /// </param>
        /// <exception cref="OutputDeviceException">
        /// Thrown if an error occurred while sending the message.
        /// </exception>
        public void Send(SysRealtimeMessage message)
        {
            // Guard.
            if(!IsOpen())
                return;

            ThrowOnError(midiOutShortMsg(handle, message.Message));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the SysRealtimeEventArgs class with 
 /// the specified SysRealtimeMessage and time stamp.
 /// </summary>
 /// <param name="message">
 /// The SysRealtimeMessage for this event.
 /// </param>
 /// <param name="timeStamp">
 /// The time in milliseconds since the input device began recording.
 /// </param>
 public SysRealtimeEventArgs(SysRealtimeMessage message, int timeStamp)
 {
     this.message = message;
     this.timeStamp = timeStamp;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the SysRealtimeMessage class with 
 /// another instance of the SysRealtimeMessage class.
 /// </summary>
 /// <param name="message">
 /// The SysRealtimeMessage instance to use for initialization.
 /// </param>
 public SysRealtimeMessage(SysRealtimeMessage message)
 {
     Type = message.Type;
 }
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public virtual void Visit(SysRealtimeMessage message)
 {
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Determines the type of message received and triggers the correct
        /// event in response.
        /// </summary>
        /// <param name="message">
        /// The short Midi message received.
        /// </param>
        /// <param name="timeStamp">
        /// Number of milliseconds that have passed since the input device 
        /// began recording.
        /// </param>
        private void DispatchShortMessage(int message, int timeStamp)
        {
            // Unpack status value.
            int status = ShortMessage.UnpackStatus(message);

            // If a channel message was received.
            if(ChannelMessage.IsChannelMessage(status))
            {
                // If anyone is listening for channel messages.
                if(ChannelMessageReceived != null)
                {
                    // Create channel message.
                    ChannelMessage msg = new ChannelMessage(message);

                    // Create channel message event argument.
                    ChannelMessageEventArgs e =
                        new ChannelMessageEventArgs(msg, timeStamp);

                    // Trigger channel message received event.
                    ChannelMessageReceived(this, e);
                }
            }
            // Else if a system common message was received
            else if(SysCommonMessage.IsSysCommonMessage(status))
            {
                // If anyone is listening for system common messages
                if(SysCommonReceived != null)
                {
                    // Create system common message.
                    SysCommonMessage msg = new SysCommonMessage(message);

                    // Create system common event argument.
                    SysCommonEventArgs e = new SysCommonEventArgs(msg, timeStamp);

                    // Trigger system common received event.
                    SysCommonReceived(this, e);
                }
            }
            // Else if a system realtime message was received
            else if(SysRealtimeMessage.IsSysRealtimeMessage(status))
            {
                // If anyone is listening for system realtime messages
                if(SysRealtimeReceived != null)
                {
                    // Create system realtime message.
                    SysRealtimeMessage msg = new SysRealtimeMessage(message);

                    // Create system realtime event argument.
                    SysRealtimeEventArgs e = new SysRealtimeEventArgs(msg, timeStamp);

                    // Trigger system realtime received event.
                    SysRealtimeReceived(this, e);
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the SysRealtimeEventArgs class with
 /// the specified SysRealtimeMessage and time stamp.
 /// </summary>
 /// <param name="message">
 /// The SysRealtimeMessage for this event.
 /// </param>
 /// <param name="timeStamp">
 /// The time in milliseconds since the input device began recording.
 /// </param>
 public SysRealtimeEventArgs(SysRealtimeMessage message, int timeStamp)
 {
     this.message   = message;
     this.timeStamp = timeStamp;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the SysRealtimeMessage class with
 /// another instance of the SysRealtimeMessage class.
 /// </summary>
 /// <param name="message">
 /// The SysRealtimeMessage instance to use for initialization.
 /// </param>
 public SysRealtimeMessage(SysRealtimeMessage message)
 {
     Type = message.Type;
 }