Пример #1
0
        internal MidiSongSelectMessage(byte[] rawData, TimeSpan timestamp)
        {
            MidiMessageValidators.VerifyMessageLength(rawData, 2, Type);
            MidiMessageValidators.VerifyMessageType(rawData[0], Type);
            MidiMessageValidators.VerifyRange(rawData[1], MidiMessageParameter.Song);

            _buffer   = new Storage.Streams.Buffer(rawData);
            Timestamp = timestamp;
        }
Пример #2
0
        internal MidiTimeCodeMessage(byte[] rawData, TimeSpan timestamp)
        {
            MidiMessageValidators.VerifyMessageLength(rawData, 2, Type);
            MidiMessageValidators.VerifyMessageType(rawData[0], Type);
            MidiMessageValidators.VerifyRange(MidiHelpers.GetFrame(rawData[1]), MidiMessageParameter.Frame);
            MidiMessageValidators.VerifyRange(MidiHelpers.GetFrameValues(rawData[1]), MidiMessageParameter.FrameValues);

            _buffer   = new Storage.Streams.Buffer(rawData);
            Timestamp = timestamp;
        }
Пример #3
0
        internal MidiChannelPressureMessage(byte[] rawData, TimeSpan timestamp)
        {
            MidiMessageValidators.VerifyMessageLength(rawData, 2, MidiMessageType.ChannelPressure);
            MidiMessageValidators.VerifyMessageType(rawData[0], MidiMessageType.ChannelPressure);
            MidiMessageValidators.VerifyRange(MidiHelpers.GetChannel(rawData[0]), MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(rawData[1], MidiMessageParameter.Pressure);

            _buffer   = new Storage.Streams.Buffer(rawData);
            Timestamp = timestamp;
        }
Пример #4
0
        /// <summary>
        /// Creates a new MidiSongPositionPointerMessage object.
        /// </summary>
        /// <param name="beats">The song position pointer encoded in a 14-bit value from 0-16383.</param>
        public MidiSongPositionPointerMessage(ushort beats)
        {
            MidiMessageValidators.VerifyRange(beats, MidiMessageParameter.Beats);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)MidiMessageType.SongPositionPointer,
                (byte)(beats & 0b0111_1111),
                (byte)(beats >> 7)
            });
Пример #5
0
        /// <summary>
        /// Creates a new MidiSongSelectMessage object.
        /// </summary>
        /// <param name="song">The song to select from 0-127.</param>
        public MidiSongSelectMessage(byte song)
        {
            MidiMessageValidators.VerifyRange(song, MidiMessageParameter.Song);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)MidiMessageType.SongSelect,
                song
            });
        }
Пример #6
0
        /// <summary>
        /// Creates a new MidiTimeCodeMessage object.
        /// </summary>
        /// <param name="frameType">The frame type from 0-7.</param>
        /// <param name="values">The time code from 0-15.</param>
        public MidiTimeCodeMessage(byte frameType, byte values)
        {
            MidiMessageValidators.VerifyRange(frameType, MidiMessageParameter.Frame);
            MidiMessageValidators.VerifyRange(values, MidiMessageParameter.FrameValues);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)Type,
                (byte)(frameType << 4 | values)
            });
        }
Пример #7
0
        /// <summary>
        /// Creates a new MidiPitchBendChangeMessage object.
        /// </summary>
        /// <param name="channel">Channel.</param>
        /// <param name="bend">Bend.</param>
        public MidiPitchBendChangeMessage(byte channel, ushort bend)
        {
            MidiMessageValidators.VerifyRange(channel, MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(bend, MidiMessageParameter.Bend);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)((byte)Type | channel),
                (byte)(bend & 0b0111_1111),
                (byte)(bend >> 7)
            });
Пример #8
0
        /// <summary>
        /// Creates a new MidiChannelPressureMessage object.
        /// </summary>
        /// <param name="channel">The channel from 0-15 that this message applies to.</param>
        /// <param name="pressure">The pressure from 0-127.</param>
        public MidiChannelPressureMessage(byte channel, byte pressure)
        {
            MidiMessageValidators.VerifyRange(channel, MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(pressure, MidiMessageParameter.Pressure);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)((byte)Type | channel),
                pressure
            });
        }
Пример #9
0
        internal MidiNoteOnMessage(byte[] rawData, TimeSpan timestamp)
        {
            MidiMessageValidators.VerifyMessageLength(rawData, 3, Type);
            MidiMessageValidators.VerifyMessageType(rawData[0], Type);
            MidiMessageValidators.VerifyRange(MidiHelpers.GetChannel(rawData[0]), MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(rawData[1], MidiMessageParameter.Note);
            MidiMessageValidators.VerifyRange(rawData[2], MidiMessageParameter.Velocity);

            _buffer   = new Storage.Streams.Buffer(rawData);
            Timestamp = timestamp;
        }
Пример #10
0
        /// <summary>
        /// Creates a new MidiProgramChangeMessage object.
        /// </summary>
        /// <param name="channel">The channel from 0-15 that this message applies to.</param>
        /// <param name="program">The program to change from 0-127.</param>
        public MidiProgramChangeMessage(byte channel, byte program)
        {
            MidiMessageValidators.VerifyRange(channel, MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(program, MidiMessageParameter.Program);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)((byte)MidiMessageType.ProgramChange | channel),
                program,
            });
        }
Пример #11
0
        /// <summary>
        /// Creates a new MidiNoteOnMessage object.
        /// </summary>
        /// <param name="channel">The channel from 0-15 that this message applies to.</param>
        /// <param name="note">The note which is specified as a value from 0-127.</param>
        /// <param name="velocity">The velocity which is specified as a value from 0-127.</param>
        public MidiNoteOnMessage(byte channel, byte note, byte velocity)
        {
            MidiMessageValidators.VerifyRange(channel, MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(note, MidiMessageParameter.Note);
            MidiMessageValidators.VerifyRange(velocity, MidiMessageParameter.Velocity);

            _buffer = new Storage.Streams.Buffer(new byte[] {
                (byte)((byte)Type | channel),
                note,
                velocity
            });
        }
Пример #12
0
        /// <summary>
        /// Creates a new MidiControlChangeMessage object.
        /// </summary>
        /// <param name="channel">The channel from 0-15 that this message applies to.</param>
        /// <param name="controller">The controller from 0-127 to receive this message.</param>
        /// <param name="controlValue">The value from 0-127 to apply to the controller.</param>
        public MidiControlChangeMessage(byte channel, byte controller, byte controlValue)
        {
            MidiMessageValidators.VerifyRange(channel, MidiMessageParameter.Channel);
            MidiMessageValidators.VerifyRange(controller, MidiMessageParameter.Controller);
            MidiMessageValidators.VerifyRange(controlValue, MidiMessageParameter.ControlValue);

            _buffer = new Storage.Streams.Buffer(new byte[]
            {
                (byte)((byte)MidiMessageType.ControlChange | channel),
                controller,
                controlValue
            });
        }