/// <summary> /// Initializes a new instance of the <see cref="Measure"/> class. /// </summary> /// <param name="noteList"> /// The note list. /// </param> /// <param name="attributes"> /// The attributes. /// </param> public Measure(List<ValueNote> noteList, Attributes attributes) { if (attributes != null) { Attributes = (Attributes)attributes.Clone(); } NoteList = new List<ValueNote>(); // создаем список нот, по средствам клонирования каждой ноты. foreach (ValueNote note in noteList) { NoteList.Add((ValueNote)note.Clone()); } }
public void FmotivDividerFifthTest() { // создание и заполнения списка(ов) нот для такта(ов) монотрека var notes = new List<ValueNote> { new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 8, 2, 3, false, 240), false, Tie.None, 0), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 8, 2, 3, false, 240), false, Tie.None, 1), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 8, 2, 3, false, 240), false, Tie.None, 1), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 8, false, 360), false, Tie.None, 0), new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 8, false, 360), false, Tie.None, 1) }; // создание атрибутов для такта(ов) var attributes = new Attributes(new Size(2, 4, 1440), new Key(0, "major")); // создание и заполнение такта(ов) списками нот и атрибутами var measures = new List<Measure> { new Measure(notes, (Attributes)attributes.Clone()) }; // создание моно трека var unitrack = new CongenericScoreTrack("track1", measures); // создание объекта для деления монотрека на фмотивы var fmdivider = new FmotivDivider(); // создание результирующей цепочки фмотивов // вычисление, опрделение, разбиение на ф-мотивы данного монотрека var fmchain = fmdivider.GetDivision(unitrack, (int)ParamPauseTreatment.Ignore); fmchain.Id = 0; // создание аналогов ф-мотивов, которые должны получиться, после разбиения // процедура определения одинаковых на данном этапе не производится var fmotiv1 = new Fmotiv("ПМТ", 0); var fmotiv2 = new Fmotiv("ПМТ", 1); fmotiv1.NoteList.Add(new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 8, 2, 3, false, 240), false, Tie.None)); fmotiv1.NoteList.Add(new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 8, 2, 3, false, 240), false, Tie.None)); fmotiv1.NoteList.Add(new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 8, 2, 3, false, 240), false, Tie.None)); fmotiv1.NoteList.Add(new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 8, false, 360), false, Tie.None)); fmotiv2.NoteList.Add(new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 8, false, 360), false, Tie.None)); // записываем ф-мотивы в цепь ф-мотивов, которая будет сравниваться с получившейся var fmchain1 = new FmotivChain { Id = 0, Name = "track1" }; fmchain1.FmotivList.Add(fmotiv1); fmchain1.FmotivList.Add(fmotiv2); Assert.IsTrue(fmchain1.Equals(fmchain)); }
/// <summary> /// The parse attributes. /// </summary> /// <param name="measureNode"> /// The measure node. /// </param> /// <returns> /// The <see cref="Attributes"/>. /// </returns> private Attributes ParseAttributes(XmlNode measureNode) { foreach (XmlNode measureChild in measureNode.ChildNodes) { if (measureChild.Name == "attributes") { Key key = ParseKey(measureChild.Clone()) ?? (Key)currentAttributes.Key.Clone(); Size size = ParseSize(measureChild.Clone()) ?? (Size)currentAttributes.Size.Clone(); currentAttributes = new Attributes(size, key); return currentAttributes; } } return currentAttributes; }
public void MeasureFirstTest() { var notes = new List<ValueNote>(); var notes2 = new List<ValueNote>(); var attributes = new Attributes(new Size(4, 4, 512), new Key(5)); notes.Add(new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 4, false, 128), false, Tie.None)); notes.Add(new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 4, false, 128), false, Tie.None)); notes.Add(new ValueNote(new Pitch(3, 'C', 0), new Duration(1, 16, false, 32), false, Tie.None)); notes2.Add(new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 4, false, 128), false, Tie.None)); notes2.Add(new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 4, false, 128), false, Tie.None)); notes2.Add(new ValueNote(new Pitch(3, 'C', 0), new Duration(1, 16, false, 32), false, Tie.None)); var m1 = new Measure(notes, attributes); var m2 = new Measure(notes2, attributes); Assert.IsTrue(m1.Equals(m2)); }
public void MeasureOrderTest() { // создание и заполнения списка(ов) нот для такта(ов) монотрека var notes = new List<ValueNote> { new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1) }; var notes3 = new List<ValueNote> { new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1) }; var notes2 = new List<ValueNote> { new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1) }; var notes4 = new List<ValueNote> { new ValueNote(new Pitch(3, 'A', -1), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'D', 0), new Duration(1, 4, false, 128), false, Tie.None, 2), new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 4, false, 128), false, Tie.None, 1) }; var notes5 = new List<ValueNote> { new ValueNote((Pitch)null, new Duration(1, 4, false, 128), false, Tie.None, 1), new ValueNote((Pitch)null, new Duration(1, 4, false, 128), false, Tie.None, 1) }; var notes6 = new List<ValueNote> { new ValueNote((Pitch)null, new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote((Pitch)null, new Duration(1, 16, false, 128), false, Tie.None, 1) }; var attr = new Attributes(new Size(4, 4, 128), new Key(5)); var m1 = new Measure(notes, attr); var m2 = new Measure(notes2, attr); var m3 = new Measure(notes3, attr); var m4 = new Measure(notes4, attr); var m5 = new Measure(notes5, attr); var m6 = new Measure(notes6, attr); var measuresList = new List<Measure> { m1, m2, m3, m4, m5, m5, m2, m3, m6 }; var uni = new CongenericScoreTrack("a1", measuresList); Assert.AreEqual(uni.MeasureOrder()[0].Id, 0); Assert.AreEqual(uni.MeasureOrder()[1].Id, 1); Assert.AreEqual(uni.MeasureOrder()[2].Id, 0); Assert.AreEqual(uni.MeasureOrder()[3].Id, 2); Assert.AreEqual(uni.MeasureOrder()[4].Id, 3); Assert.AreEqual(uni.MeasureOrder()[5].Id, 3); Assert.AreEqual(uni.MeasureOrder()[6].Id, 1); Assert.AreEqual(uni.MeasureOrder()[7].Id, 0); Assert.AreEqual(uni.MeasureOrder()[8].Id, 4); Assert.AreEqual(uni.MeasureIdOrder()[0], 0); Assert.AreEqual(uni.MeasureIdOrder()[1], 1); Assert.AreEqual(uni.MeasureIdOrder()[2], 0); Assert.AreEqual(uni.MeasureIdOrder()[3], 2); Assert.AreEqual(uni.MeasureIdOrder()[4], 3); Assert.AreEqual(uni.MeasureIdOrder()[5], 3); Assert.AreEqual(uni.MeasureIdOrder()[6], 1); Assert.AreEqual(uni.MeasureIdOrder()[7], 0); Assert.AreEqual(uni.MeasureIdOrder()[8], 4); }
public void ValueNoteOrderSecondTest() { // создание и заполнения списка(ов) нот для такта(ов) монотрека var notes = new List<ValueNote> { new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote(new Pitch(3, 'A', -1), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'D', 0), new Duration(1, 16, false, 128), false, Tie.None, 2), new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1) }; var notes2 = new List<ValueNote> { new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 4, false, 512), false, Tie.None, 0), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote(new Pitch(3, 'A', -1), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'D', 0), new Duration(1, 4, false, 128), false, Tie.None, 2), new ValueNote(new Pitch(3, 'A', 2), new Duration(1, 16, false, 128), false, Tie.None, 3), new ValueNote(new Pitch(3, 'C', 1), new Duration(1, 4, false, 128), false, Tie.None, 1), new ValueNote((Pitch)null, new Duration(1, 4, false, 128), false, Tie.None, 1), new ValueNote((Pitch)null, new Duration(1, 4, false, 128), false, Tie.None, 1), new ValueNote((Pitch)null, new Duration(1, 16, false, 128), false, Tie.None, 1), new ValueNote((Pitch)null, new Duration(1, 16, false, 128), false, Tie.None, 1) }; var attr = new Attributes(new Size(4, 4), new Key(5)); var m1 = new Measure(notes, attr); var m2 = new Measure(notes2, attr); var mlist = new List<Measure> { m1, m2 }; var uni = new CongenericScoreTrack("a1", mlist); Assert.AreNotEqual(uni.NoteIdOrder()[0], 1); Assert.AreEqual(uni.NoteIdOrder()[0], 0); Assert.AreEqual(uni.NoteIdOrder()[1], 1); Assert.AreEqual(uni.NoteIdOrder()[2], 1); Assert.AreEqual(uni.NoteIdOrder()[3], 2); Assert.AreEqual(uni.NoteIdOrder()[4], 3); Assert.AreEqual(uni.NoteIdOrder()[5], 4); Assert.AreEqual(uni.NoteIdOrder()[6], 0); Assert.AreEqual(uni.NoteIdOrder()[7], 2); Assert.AreEqual(uni.NoteIdOrder()[8], 2); Assert.AreEqual(uni.NoteIdOrder()[9], 0); Assert.AreEqual(uni.NoteIdOrder()[10], 0); Assert.AreEqual(uni.NoteIdOrder()[11], 1); Assert.AreEqual(uni.NoteIdOrder()[12], 1); Assert.AreEqual(uni.NoteIdOrder()[13], 2); Assert.AreEqual(uni.NoteIdOrder()[14], 3); Assert.AreEqual(uni.NoteIdOrder()[15], 5); Assert.AreEqual(uni.NoteIdOrder()[16], 0); Assert.AreEqual(uni.NoteIdOrder()[17], 6); Assert.AreEqual(uni.NoteIdOrder()[18], 7); Assert.AreEqual(uni.NoteIdOrder()[19], 7); Assert.AreEqual(uni.NoteIdOrder()[20], 8); Assert.AreEqual(uni.NoteIdOrder()[21], 8); }
public void XmlParserTest() { var xmlReader = new MusicXmlReader("../../LibiadaMusicexample7Liga.xml"); var parser = new MusicXmlParser(); parser.Execute(xmlReader.MusicXmlDocument, xmlReader.FileName); // Создание атрибутов для такта var attributes1 = new Attributes(new Size(7, 8, 1024), new Key(0, "major")); // Создание списков нот для каждого из 4 тактов var notes1 = new List<ValueNote> { new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 2, false, 2048), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(3, 'F', 0), new Duration(1, 8, false, 512), false, Tie.Start) }; var notes2 = new List<ValueNote> { new ValueNote(new Pitch(3, 'F', 0), new Duration(1, 8, false, 512), false, Tie.Stop), new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(3, 'G', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(3, 'G', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 8, false, 512), false, Tie.None), new ValueNote(new Pitch(2, 'A', 0), new Duration(1, 8, false, 512), false, Tie.None) }; var notes3 = new List<ValueNote> { new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'G', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'E', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'B', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'D', 0), new Duration(1, 8, true, 768), false, Tie.None), new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 8, true, 768), false, Tie.None), new ValueNote((Pitch)null, new Duration(1, 8, false, 512), false, Tie.None) }; var notes4 = new List<ValueNote> { new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'E', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(2, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'D', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(2, 'E', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'G', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(3, 'A', 0), new Duration(1, 16, false, 256), false, Tie.None), new ValueNote(new Pitch(4, 'C', 0), new Duration(1, 16, false, 256), false, Tie.None) }; // создание списка тактов для монофонического трека p0 var measures1 = new List<Measure> { new Measure(notes1, (Attributes)attributes1.Clone()), new Measure(notes2, (Attributes)attributes1.Clone()), new Measure(notes3, (Attributes)attributes1.Clone()), new Measure(notes4, (Attributes)attributes1.Clone()) }; // создание списка монофонических треков для полного музыкального трека var utracks = new List<CongenericScoreTrack> { new CongenericScoreTrack("p0", measures1) }; // создание полной модели музыкального трека/текста, с присвоением имени файла var scoreModel = new ScoreTrack("LibiadaMusicexample7Liga", utracks); Assert.AreEqual(xmlReader.FileName, parser.ScoreModel.Name); Assert.AreEqual(scoreModel.CongenericScoreTracks[0].MeasureList[0].Attributes, parser.ScoreModel.CongenericScoreTracks[0].MeasureList[0].Attributes); Assert.AreEqual(scoreModel.CongenericScoreTracks[0].MeasureList[0].NoteList[0], parser.ScoreModel.CongenericScoreTracks[0].MeasureList[0].NoteList[0]); Assert.AreEqual(scoreModel.CongenericScoreTracks[0].MeasureList[0], parser.ScoreModel.CongenericScoreTracks[0].MeasureList[0]); Assert.AreEqual(scoreModel.CongenericScoreTracks[0].MeasureList[1], parser.ScoreModel.CongenericScoreTracks[0].MeasureList[1]); Assert.AreEqual(scoreModel.CongenericScoreTracks[0].MeasureList[2], parser.ScoreModel.CongenericScoreTracks[0].MeasureList[2]); Assert.AreEqual(scoreModel.CongenericScoreTracks[0].MeasureList[3], parser.ScoreModel.CongenericScoreTracks[0].MeasureList[3]); Assert.AreEqual(scoreModel.CongenericScoreTracks[0], parser.ScoreModel.CongenericScoreTracks[0]); Assert.AreEqual(scoreModel, parser.ScoreModel); }