/// <summary>
 /// Receives a short midi error message.
 /// </summary>
 /// <param name="data">The short error message data.</param>
 /// <param name="timestamp">Not used. A new timestamp is generated.</param>
 public override void ShortError(int data, long timestamp)
 {
     if (NextErrorReceiver != null)
     {
         NextErrorReceiver.ShortError(data, GetCurrentTimestamp());
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Handles the long and short error messages.
        /// </summary>
        /// <param name="umsg">Type of message.</param>
        /// <param name="param1">First parameter.</param>
        /// <param name="param2">Second parameter.</param>
        /// <returns>Returns true if the <paramref name="umsg"/> has been handled.</returns>
        private bool HandleErrorMessage(uint umsg, IntPtr param1, IntPtr param2)
        {
            bool handled = true;

            switch (umsg)
            {
            case NativeMethods.MIM_ERROR:
                NextErrorReceiver.ShortError(param1.ToInt32(), param2.ToInt32());
                break;

            case NativeMethods.MIM_LONGERROR:
                var buffer = BufferManager.FindBuffer(param1);

                if (buffer != null)
                {
                    NextErrorReceiver.LongError(buffer, param2.ToInt32());

                    if (AutoReturnBuffers)
                    {
                        BufferManager.ReturnBuffer(buffer);
                    }
                }
                break;

            default:
                handled = false;
                break;
            }

            return(handled);
        }
Esempio n. 3
0
        /// <summary>
        /// Dispatches the <paramref name="record"/> to the appropriate receiver component.
        /// </summary>
        /// <param name="record">Must not be null.</param>
        private void DispatchRecord(MidiPortEvent record)
        {
            Contract.Requires(record != null);
            Check.IfArgumentNull(record, "record");

            if (NextReceiver != null)
            {
                switch (record.RecordType)
                {
                case MidiPortEventType.MoreData:
                case MidiPortEventType.ShortData:
                    NextReceiver.ShortData(record.Data, (int)record.Timestamp);
                    break;

                case MidiPortEventType.LongData:
                    NextReceiver.LongData(record.Buffer, (int)record.Timestamp);
                    break;
                }
            }

            if (NextErrorReceiver != null)
            {
                switch (record.RecordType)
                {
                case MidiPortEventType.ShortError:
                    NextErrorReceiver.ShortError(record.Data, (int)record.Timestamp);
                    break;

                case MidiPortEventType.LongError:
                    NextErrorReceiver.LongError(record.Buffer, (int)record.Timestamp);
                    break;
                }
            }

            if (NextPortEventReceiver != null)
            {
                NextPortEventReceiver.PortEvent(record);
            }
        }