/// <summary> Changes the MusicalLoop's state to Syncing </summary> /// <param name="prevLoop"> (MusicalLoop) Musical Loops that is currently active in the fg </param> /// <param name="currMeasure"> (unsigned int) The match's current measure </param> /// <param name="currBeat"> (unsigned int) The match's current beat </param> public void StartSyncing(MusicalLoop prevLoop, uint currMeasure, uint currBeat) { CheckActionQuality(currBeat); SetLoopState(LoopState.Syncing, currMeasure); this.prevLoop = prevLoop; if (prevLoop != null) { prevLoop.phasingOut = true; } }
/// <summary> /// Initializes a match's loop, and adds it to the loopPerFGHashMap /// </summary> private void InitializeMusicalLoops() { Material mat = new Material(Color.FromName("Black")); string soundfile = "bass.png"; LoopFunctionalGroup fg = LoopFunctionalGroup.Percussion; //Fill the loops array with musical loops for (int i = 0; i < loops.Length; i++) { MusicalLoop loop = new MusicalLoop(fg, soundfile, mat, measure, pSystem, lFGHashMap); loops[i] = loop; lFGHashMap.Add(loop); newMeasureHandler.NewMeasure += loop.OnNewMeasureEvent; } }
/// <summary> remove a MusicalLoop from the LoopFGHashMap </summary> /// <param name="loop"> (MusicalLoop) loop to be removed from the fg HashMap. </param> public void Remove(MusicalLoop loop) { if (loop == null) { throw new ArgumentNullException(String.Format("Tried to remove {0}, but it is null", loop), "loop"); } int key = loop.GetLoopState().GetHashCode(); List <MusicalLoop> value; if (loopsByFGGroup.TryGetValue(key, out value)) { value.Remove(loop); } }
/// <summary> /// Method called to handle NewMeasureEvent: /// - Makes prevLoop Inactive, /// - Updates to nextState if necessary /// </summary> /// <param name="source"> (Object) object which triggered the event </param> /// <param name="e"> (NewMeasureEventArgs) arguments associated with event </param> public void OnNewMeasureEvent(object source, NewMeasureEventArgs e) { if (!phasingOut) { Console.WriteLine("Musical Loop recieved NewMeasureEvent!"); LoopState lState = GetLoopState(); if (lState.Name.Equals("Syncing")) { if (prevLoop != null) { prevLoop.SetInactive(e.TotalMeasures); prevLoop = null; } particleSystem.PlayQueuedEffects(); } LoopState newState = lState.NewMeasureHandler(e.TotalMeasures, measureOfLastStateChange); if (newState != null) { SetLoopState(newState, e.TotalMeasures); } } }