Exemple #1
0
        /// <summary>
        /// Creates a new Meta midi message object.
        /// </summary>
        /// <param name="metaType">The type of meta message.</param>
        /// <param name="longData">The data of the meta message. Must not be null or empty.</param>
        /// <returns>Never returns null.</returns>
        /// <remarks>The Meta message objects are NOT pooled.
        /// For some <paramref name="metaType"/> value a <see cref="MidiMetaTextMessage"/>
        /// instance is returned.</remarks>
        public MidiMetaMessage CreateMetaMessage(MidiMetaType metaType, byte[] longData)
        {
            Check.IfArgumentNull(longData, nameof(longData));

            var buffer = CopyBuffer(longData);

            if (MidiMetaTextMessage.IsMetaTextType(metaType))
            {
                return(new MidiMetaTextMessage(metaType, buffer));
            }

            return(new MidiMetaMessage(metaType, buffer));
        }
        public MidiMetaMessage CreateMetaMessage(MidiMetaType metaType, byte[] longData)
        {
            Contract.Requires(metaType != MidiMetaType.Unknown);
            Contract.Requires(longData != null);
            Contract.Ensures(Contract.Result <MidiMetaMessage>() != null);
            Check.IfArgumentNull(longData, "longData");

            var buffer = this.CopyBuffer(longData);

            if (MidiMetaTextMessage.IsMetaTextType(metaType))
            {
                return(new MidiMetaTextMessage(metaType, buffer));
            }

            return(new MidiMetaMessage(metaType, buffer));
        }