コード例 #1
0
 public Context(Player player)
 {
     m_Player = player;
     m_States = new Stack<ContextState>();
     var state = new ContextState();
     m_States.Push(state);
 }
コード例 #2
0
 private int GetTotalDuration(ContextState state)
 {
     var oneMinute = new TimeSpan(0, 1, 0);
     int l4TotalLength = (int)oneMinute.TotalMilliseconds/state.Tempo;
     int l1TotalLength = l4TotalLength*4;
     int currentTotalLength = l1TotalLength/(int) state.Length;
     return currentTotalLength;
 }
コード例 #3
0
        public void Play(ContextState state)
        {
            var currentTotalLength = GetTotalDuration(state);
            int soundDuration;
            int pauseDuration;
            GetDurations(currentTotalLength, state.Duration, out soundDuration, out pauseDuration);

            int stepsToA4 = StepsToA4(state.Octave, state.Note, state.Accidental);

            PlaySound(soundDuration, stepsToA4);
            PlayPause(pauseDuration);
        }