Beispiel #1
0
        /// <summary>
        /// Constructs the type-specific message object using the given data. Use MessageType property
        /// to determine the type of the message.
        /// </summary>
        /// <param name="Data">The binary coded data from the style file</param>
        /// <param name="TotalTime">The timestamp of the message in ticks</param>
        /// <returns>An object derived from MidiMessage class that represents the message</returns>
        public static MidiMessage CreateFromData(byte[] Data, int TotalTime)
        {
            MidiMessageType type  = MidiMessage.GetMessageType(Data[1]);
            Type            Class = Type.GetType("TomiSoft.RolandStyleReader." + type.ToString() + "Message", true);

            try {
                return((MidiMessage)Class.GetConstructor(
                           new Type[] {
                    typeof(byte[]),
                    typeof(int)
                }
                           ).Invoke(new object[] { Data, TotalTime }));
            }
            catch (TargetInvocationException e) {
                throw e.InnerException;
            }
        }