public static MidiEventCollection Complete(long deltaTime, byte channel, byte note, byte velocity, long duration)
 {
     MidiEventCollection events = new MidiEventCollection();
     events.Add(new NoteOn(deltaTime, channel, note, velocity));
     events.Add(new NoteOff(duration, channel, note, velocity));
     return events;
 }
 public MidiEventCollection(MidiEventCollection c)
 {
     if (c == null)
     {
         throw new ArgumentNullException("c");
     }
     this._events = new ArrayList(c);
 }
示例#3
0
文件: MidiTrack.cs 项目: rsenn/s2midi
        /// <summary>Initialize the track.</summary>
        public MidiTrack()
        {
            // Create the buffer to store all event information
            _events = new MidiEventCollection();

            // We don't yet have an end of track marker, but we want one eventually.
            _requireEndOfTrack = true;
        }
 public virtual int Add(MidiEventCollection messages)
 {
     if (messages == null)
     {
         throw new ArgumentNullException("messages");
     }
     if (messages.Count == 0)
     {
         return -1;
     }
     int count = this._events.Count;
     this._events.AddRange(messages);
     return count;
 }
 public static void Play(MidiEventCollection events, int division)
 {
     MidiSequence sequence = new MidiSequence(0, division);
     MidiTrack track = sequence.AddTrack();
     track.Events.Add(events);
     if (!track.HasEndOfTrack)
     {
         track.Events.Add(new EndOfTrack(0L));
     }
     Play(sequence);
 }
示例#6
0
        /// <summary>Adds a collection of MIDI event messages to the collection.</summary>
        /// <param name="messages">The events to be added.</param>
        /// <returns>The position at which the first event was added.</returns>
        public virtual int Add(MidiEventCollection messages)
        {
            // Validate the input
            if (messages == null) throw new ArgumentNullException("messages");
            if (messages.Count == 0) return -1;

            // Store the count of the list (the inserted position of the first new element).
            int insertionPos = _events.Count;

            // Add the events
            _events.AddRange(messages);

            // Return the position of the first
            return insertionPos;
        }
示例#7
0
        /// <summary>Intializes the collection.</summary>
        /// <param name="c">The collection of MIDI events with which to initialize the collection.</param>
        public MidiEventCollection(MidiEventCollection c)
        {
            // Validate the input
            if (c == null) throw new ArgumentNullException("c");

            // Initialize the list with the given collection of events
            _events = new ArrayList(c);
        }
示例#8
0
 /// <summary>Plays a collection of MIDI events.</summary>
 /// <param name="events">The events to be played.</param>
 /// <param name="division">The division to use for playing the events.</param>
 public static void Play(MidiEventCollection events, int division)
 {
     // Add all of the events to a temporary track and sequence, then play it
     MidiSequence tempSequence = new MidiSequence(0, division);
     MidiTrack tempTrack = tempSequence.AddTrack();
     tempTrack.Events.Add(events);
     if (!tempTrack.HasEndOfTrack) tempTrack.Events.Add(new EndOfTrack(0));
     Play(tempSequence);
 }