예제 #1
0
        /// <summary>
        /// Creates a new short midi message object.
        /// </summary>
        /// <param name="message">A full short midi message with the lower 3 bytes filled.</param>
        /// <returns>Never returns null.</returns>
        public MidiShortMessage CreateShortMessage(int message)
        {
            MidiShortMessage result = Lookup(message);

            if (result == null)
            {
                int  statusChannel = MidiData.GetStatus(message);
                byte status        = (byte)(statusChannel & (byte)0xF0);

                if (status == 0xF0)
                {
                    if (statusChannel >= 0xF8)
                    {
                        result = new MidiSysRealtimeMessage(message);
                    }
                    else
                    {
                        result = new MidiSysCommonMessage(message);
                    }
                }
                else if (status == (byte)MidiChannelCommand.ControlChange)
                {
                    result = new MidiControllerMessage(message);
                }
                else
                {
                    result = new MidiChannelMessage(message);
                }

                Add(result);
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Add the <paramref name="message"/> to the pool.
        /// </summary>
        /// <param name="message">Must not be null.</param>
        private void Add(MidiShortMessage message)
        {
            Check.IfArgumentNull(message, nameof(message));

            lock (_msgPool)
            {
                _msgPool.Add(message.Data, message);
            }
        }
예제 #3
0
        /// <summary>
        /// Add the <paramref name="message"/> to the pool.
        /// </summary>
        /// <param name="message">Must not be null.</param>
        private void Add(MidiShortMessage message)
        {
            Contract.Requires(message != null);
            Check.IfArgumentNull(message, "message");

            lock (this.msgPool)
            {
                this.msgPool.Add(message.Data, message);
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a new short midi message object.
        /// </summary>
        /// <param name="message">A full short midi message with the lower 3 bytes filled.</param>
        /// <returns>Never returns null.</returns>
        public MidiShortMessage CreateShortMessage(int message)
        {
            Contract.Ensures(Contract.Result <MidiShortMessage>() != null);

            MidiShortMessage result = this.Lookup(message);

            if (result == null)
            {
                int  statusChannel = MidiData.GetStatus(message);
                byte status        = (byte)(statusChannel & (byte)0xF0);

                if (status == 0xF0)
                {
                    if (statusChannel >= 0xF8)
                    {
                        result = new MidiSysRealTimeMessage(message);
                    }
                    else
                    {
                        result = new MidiSysCommonMessage(message);
                    }
                }
                else if (status == (byte)MidiChannelCommand.ControlChange)
                {
                    result = new MidiControllerMessage(message);
                }
                else
                {
                    result = new MidiChannelMessage(message);
                }

                this.Add(result);
            }

            return(result);
        }
예제 #5
0
        /// <summary>
        /// Contract specification.
        /// </summary>
        /// <param name="message">Must not be null.</param>
        /// <param name="timestamp">No contract.</param>
        void IMidiMessageReceiver.ShortMessage(MidiShortMessage message, long timestamp)
        {
            Contract.Requires(message != null);

            throw new NotImplementedException();
        }
예제 #6
0
        /// <summary>
        /// Contract specification.
        /// </summary>
        /// <param name="message">Must not be null.</param>
        void IMidiMessageSender.Send(MidiShortMessage message)
        {
            Contract.Requires(message != null);

            throw new NotImplementedException();
        }