/// <summary>
        /// Initializes a new instance of the SequencePlayer class with the 
        /// specified MIDI sender, tick generator and sequence.
        /// </summary>
        /// <param name="midiSender">
        /// The MIDI sender to use to send MIDI messages.
        /// </param>
        /// <param name="tickGen">
        /// The tick generator used for timing the playback of MIDI messages.
        /// </param>
        /// <param name="seq">
        /// The sequence to playback.
        /// </param>
        public SequencePlayer(IMidiSender midiSender, TickGenerator tickGen, 
            Sequence seq)
        {
            this.xmidiSender = midiSender;
            // For each track in the sequence.
            foreach(Track t in seq)
            {
                // Create track player for the track.
                TrackPlayer player = new TrackPlayer(this.xmidiSender, tickGen, t);
                trackPlayers.Add(player);

                // Register to be notified when the track player has reached
                // the end of the track.
                player.EndOfTrackReached +=
                    new EventHandler(EndOfTrackReachedHandler);
            }

            activeTrackCount = trackPlayers.Count;
        }
        /// <summary>
        /// Reads the division value.
        /// </summary>
        private void ReadDivision()
        {
            byte[] d = binReader.ReadBytes(DivisionByteCount);

            // Convert array to the same byte order as this platform.
            ConvertByteArray(d);

            // Create sequence to hold tracks from the Midi file.
            seq = new Sequence(BitConverter.ToInt16(d, 0));
        }
        /// <summary>
        /// Initializes a new instance of the MidiFileWriter class with the
        /// specified file path name, the MIDI file format, and the sequence
        /// to write to a MIDI file.
        /// </summary>
        /// <param name="path">
        /// The file path name to use to write the MIDI file.
        /// </param>
        /// <param name="format">
        /// The MIDI file format.
        /// </param>
        /// <param name="seq">
        /// The sequence to write as a MIDI file.
        /// </param>
        public MidiFileWriter(string path, short format, Sequence seq)
        {
            this.seq = seq;
            Format = format;

            Write(path);
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the SequenceEnumerator class with 
 /// the specified sequence to iterate over.
 /// </summary>
 /// <param name="owner">
 /// The sequence to iterate over.
 /// </param>
 public SequenceEnumerator(Sequence owner)
 {
     this.owner = owner;
     this.version = owner.version;
 }
        /// <summary>
        /// Initializes the sequencer.
        /// </summary>
        protected virtual void InitializeSequencer()
        {
            seq = new Sequence();
            sequenceVersion = seq.Version;
            player = new SequencePlayer(this.xoutDevice, tickGen, seq);
            player.EndOfSequenceReached +=
                new EventHandler(EndOfSequenceReachedHandler);
            clock = new SlaveClock(null, this.xoutDevice, tickGen);

            clock.Starting += new EventHandler(StartingHandler);
            clock.Continuing += new EventHandler(ContinuingHandler);
            clock.Stopping += new EventHandler(StoppingHandler);
            clock.PositionChanged += new PositionChangedEventHandler(PositionChangedHandler);

            tickGen.TempoChanged += new EventHandler(OnTempoChanged);
        }