예제 #1
0
 /// <summary>
 /// Default constructor for the audio player object, sets up inital values
 /// </summary>
 /// <param name="FirstTrack">The first track to play.</param>
 public AudioPlayer(Beat FirstTrack)
 {
     m_HighPoints = 0;
     m_MidPoints = 0;
     m_LowPoints = 0;
     //Within a changeover period of 1min 31sec (91 seconds) there will be 91 readings aprox, readings are taken once a second
     //Therefore a value of 31 as a reading limit makes sense as, there can be a maximum number of (30+30+31) = 91
     m_PointsLimit = 31;
     m_TimePassed = new TimeSpan(0, 0, 0);
     m_ChangeOverPeriod = new TimeSpan(0, 1, 31);
     m_ShortChangeOverPeriod = new TimeSpan(0, 0, 45);
     m_SoundEngine = new ISoundEngine();
     m_NextTrack = FirstTrack;
     m_CurrentTrack = FirstTrack;
     PlayNextBeat();
 }
예제 #2
0
        /// <summary>
        /// Resets a few utility variables, then trys to tell the Sound engine to play the next track (m_NextTrack) 
        /// </summary>
        private void PlayNextBeat()
        {
            m_NextTrackLocked = false;
            m_TimePassed = new TimeSpan(0, 0, 0);
            m_SoundEngine.StopAllSounds();

            try
            {
                m_SoundEngine.Play2D(m_NextTrack.GetLocation(), false);
            }
            catch
            {
                Debugger.AddStringToDebugger("Failed to play a the track the the location: " + m_NextTrack.GetLocation());
            }

            m_CurrentTrack = m_NextTrack;
        }
예제 #3
0
 /// <summary>
 /// Tries to lock a beat in. Checks if each of the points (i.e. m_HighPoints) variables have passed
 /// the threshold (m_PointsLimit). If the passed beat is of that type then we can lock it in. 
 /// </summary>
 /// <param name="BeatToLockIn">The beat object candidate</param>
 private void TryToLockInBeat(Beat BeatToLockIn)
 {
     if (BeatToLockIn.GetMood() == Moods.High && m_HighPoints >= m_PointsLimit)
     {
         m_NextTrack = BeatToLockIn;
         m_NextTrackLocked = true;
         ResetPoints();
     }
     else if (BeatToLockIn.GetMood() == Moods.Mid && m_MidPoints >= m_PointsLimit)
     {
         m_NextTrack = BeatToLockIn;
         m_NextTrackLocked = true;
         ResetPoints();
     }
     else if (BeatToLockIn.GetMood() == Moods.Low && m_LowPoints >= m_PointsLimit)
     {
         m_NextTrack = BeatToLockIn;
         m_NextTrackLocked = true;
         ResetPoints();
     }
     else
     {
         //Default case, use whatever has been passed but allow other tracks to become locked in in the meantime
         m_NextTrack = BeatToLockIn;
     }
 }
예제 #4
0
 /// <summary>
 /// Attempts to add a track to be played.
 /// If a track has already been locked in then the passed parameter is ignored
 /// Otherwise it records the number of 
 /// </summary>
 /// <param name="BeatToPlay"></param>
 public void TryPlayBeat(Beat BeatToPlay)
 {
     //If a track is locked, it is garunteed to play. All other readings are ignored
     if (!m_NextTrackLocked)
     {
         SetPoints(BeatToPlay.GetMood());
         TryToLockInBeat(BeatToPlay);
     }
 }