Ejemplo n.º 1
0
        /// <summary>
        /// Reads the MIDI messages at the given address
        /// </summary>
        /// <param name="Address">The address to read</param>
        /// <param name="CType">The chord family to read</param>
        /// <returns>A collection that stores the MidiMessage instances</returns>
        private IEnumerable <MidiMessage> GetMidiMessages(InstrumentAddress Address, ChordType CType)
        {
            int Addr;

            if (Address.IsAvailable(CType) && Address[CType] < this.FileContents.Length)
            {
                Addr = Address[CType];
            }
            else
            {
                yield break;
            }

            Debug.WriteLine("Address: {0} Chord: {1}", new object[] {
                Address, CType
            });

            int Time = 0;

            for (int Offset = Addr - 1; true; Offset += 6)
            {
                if (this.FileContents[Offset + 1] == 0x8F)
                {
                    Debug.WriteLine("Break\n");
                    yield break;
                }

                byte[] Data = new byte[6];
                Array.Copy(
                    this.FileContents,
                    Offset,
                    Data,
                    0,
                    6
                    );

                MidiMessage msg = MidiMessage.CreateFromData(Data, Time);
                Time += this.FileContents[Offset];

                Debug.WriteLine("Offset: {0}, Message: {1}", new object[] {
                    Offset.ToString("X"),
                    msg.MessageType.ToString()
                });

                yield return(msg);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads the MIDI messages at the given address
        /// </summary>
        /// <param name="Address">The address to read</param>
        /// <param name="CType">The chord family to read</param>
        /// <returns>A collection that stores the MidiMessage instances</returns>
        private IEnumerable <MidiMessage> GetMidiMessages(InstrumentAddress Address, ChordType CType)
        {
            int Addr;

            if (Address.IsAvailable(CType) && Address[CType] < this.FileContents.Length)
            {
                Addr = Address[CType];
            }
            else
            {
                yield break;
            }

            int Time = 0;

            for (int Offset = Addr; true; Offset += 6)
            {
                if (this.FileContents[Offset + 1] == 0x8F)
                {
                    yield break;
                }

                byte[] Data = new byte[6];
                Array.Copy(
                    this.FileContents,
                    Offset,
                    Data,
                    0,
                    6
                    );

                MidiMessage msg = MidiMessage.CreateFromData(Data, Time);
                Time += this.FileContents[Offset];

                yield return(msg);
            }
        }