Пример #1
0
        /// <summary>
        /// Gets the events from the given style part
        /// </summary>
        /// <param name="IsBasic">True if Basic, False if Advanced</param>
        /// <param name="Part">Part of the style</param>
        /// <param name="Instr">Track of the part</param>
        /// <param name="CType">Chord type</param>
        /// <returns>A list of the events</returns>
        public IEnumerable <MidiMessage> this[bool IsBasic, StylePart Part, Instrument Instr, ChordType CType] {
            get {
                Dictionary <Instrument, Dictionary <StylePart, InstrumentAddress> > Source =
                    IsBasic ? this.BasicAddresses : this.AdvancedAddresses;

                InstrumentAddress addr = Source[Instr][Part];

                return(this.GetMidiMessages(addr, CType));
            }
        }
Пример #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;
            }

            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);
            }
        }
Пример #3
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);
            }
        }