Exemple #1
0
        /// <summary>
        /// Sends song position pointer to its slaves.
        /// </summary>
        /// <param name="spp">
        /// The sont position pointer.
        /// </param>
        /// <remarks>
        /// If the master mode is not enabled, this method has no effect.
        /// </remarks>
        public void SendSongPositionPointer(SongPositionPointer spp)
        {
            // Guard.
            if (!MasterEnabled)
            {
                return;
            }

            // Keep track of whether or not the clock is running.
            bool wasRunning = IsRunning();

            // If the clock is running, stop it momentarily. It is better not
            // to change the position while a sequencer is running.
            if (wasRunning)
            {
                Stop();
            }

            // Send song position pointer.
            midiSender.Send(spp.ToMessage());

            // If the clock was running, resume running.
            if (wasRunning)
            {
                Continue();
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles system common received events.
        /// </summary>
        /// <param name="sender">
        /// The MIDI receiver responsible for the event.
        /// </param>
        /// <param name="e">
        /// Information about the event.
        /// </param>
        private void SysCommonReceivedHandler(object sender, SysCommonEventArgs e)
        {
            // Guard.
            if (!SlaveEnabled)
            {
                return;
            }

            // If the position has changed.
            if (e.Message.Type == SysCommonType.SongPositionPointer &&
                PositionChanged != null)
            {
                SongPositionPointer spp =
                    new SongPositionPointer(tickGenerator.Ppqn, e.Message);

                bool wasRunning = IsRunning();

                // If the tick Generator is running, stop it momentarily to
                // give listeners a chance to update their position when the
                // PositionChanged event is raised.
                //
                // Ideally, any master device sending a song position pointer
                // messages would send a stop message first so that the slave
                // is not running when the position is changed.
                if (wasRunning)
                {
                    tickGenerator.Stop();
                }

                PositionChanged(this,
                                new PositionChangedEventArgs(spp.PositionInTicks));

                if (MasterEnabled)
                {
                    midiSender.Send(e.Message);
                }

                // Restart tick generator if it was previously running.
                if (wasRunning)
                {
                    tickGenerator.Start();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Sends song position pointer to its slaves.
        /// </summary>
        /// <param name="spp">
        /// The sont position pointer.
        /// </param>
        /// <remarks>
        /// If the master mode is not enabled, this method has no effect.
        /// </remarks>
        public void SendSongPositionPointer(SongPositionPointer spp)
        {
            // Guard.
            if(!MasterEnabled)
                return;

            // Keep track of whether or not the clock is running.
            bool wasRunning = IsRunning();

            // If the clock is running, stop it momentarily. It is better not
            // to change the position while a sequencer is running.
            if(wasRunning)
                Stop();

            // Send song position pointer.
            midiSender.Send(spp.ToMessage());

            // If the clock was running, resume running.
            if(wasRunning)
                Continue();
        }
Exemple #4
0
        /// <summary>
        /// Handles system common received events.
        /// </summary>
        /// <param name="sender">
        /// The MIDI receiver responsible for the event.
        /// </param>
        /// <param name="e">
        /// Information about the event.
        /// </param>
        private void SysCommonReceivedHandler(object sender, SysCommonEventArgs e)
        {
            // Guard.
            if(!SlaveEnabled)
                return;

            // If the position has changed.
            if(e.Message.Type == SysCommonType.SongPositionPointer &&
                PositionChanged != null)
            {
                SongPositionPointer spp =
                    new SongPositionPointer(tickGenerator.Ppqn, e.Message);

                bool wasRunning = IsRunning();

                // If the tick Generator is running, stop it momentarily to
                // give listeners a chance to update their position when the
                // PositionChanged event is raised.
                //
                // Ideally, any master device sending a song position pointer
                // messages would send a stop message first so that the slave
                // is not running when the position is changed.
                if(wasRunning)
                    tickGenerator.Stop();

                PositionChanged(this,
                    new PositionChangedEventArgs(spp.PositionInTicks));

                if(MasterEnabled)
                    midiSender.Send(e.Message);

                // Restart tick generator if it was previously running.
                if(wasRunning)
                    tickGenerator.Start();
            }
        }