/// <summary> /// The calculate. /// </summary> /// <param name="chain"> /// The chain. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> /// <exception cref="Exception"> /// Thrown if chain doesn't contain fmotives. /// </exception> private static bool Calculate(FmotivChain chain) { if (chain.FmotivList.Count < 1) { throw new Exception("Unable to count note remoteness with no elements in chain!"); } var noteList = new List<ValueNote>(); // список нот, класса Note, всей цепи фмотивов foreach (Fmotiv fmotiv in chain.FmotivList) { foreach (ValueNote note in fmotiv.TieGathered().PauseTreatment((int)ParamPauseTreatment.Ignore).NoteList) { noteList.Add((ValueNote)note.Clone()); } } var noteChain = new Chain(noteList.Count); for (int i = 0; i < noteList.Count; i++) { string temp = string.Empty; // строка для временного хранения набора высот foreach (Pitch pitch in noteList[i].Pitch) { temp += Convert.ToString(pitch.MidiNumber); } // TODO: переделать нормально чтоб цепочка складывалась из ValueNote, а не как попало noteChain[i] = new ValueString(temp + " " + Convert.ToString(noteList[i].Duration.Value * 10000000)); } valR = new AverageRemoteness().Calculate(noteChain, Link.End); valG = new Depth().Calculate(noteChain, Link.End); return true; }
/// <summary> /// The calculate depth. /// </summary> public void CalculateDepth() { var calculator = new Depth(); AvgDepth = calculator.Calculate(MakeNewChain(), Link.End); for (int i = 0; i < PLex.Capacity; i++) { PLex.Data[i].Depth = calculator.Calculate(MakeNewChain().CongenericChain(i), Link.End); } }