public void ConvertAbsolutePitchTest() { Sequence aPitchSeq = SequenceHandler.CreateNewSequence("Test", "Absolute Pitch", "noPage", "AbsolutePitch", 1); Panel aPitchPanel = MeiImport.ImportDocument("..\\..\\files\\tests\\AbsolutePitch.xml").Root.Descendants <Panel>().FirstOrDefault(); SequenceHandler.FlattenMeiToSequence(aPitchPanel, aPitchSeq); Controller.BuildSequence(aPitchSeq); SequenceConversion.ConvertAbsolutePitch(aPitchSeq); foreach (Model.Note note in aPitchSeq.ObjectsInSequence.Where(item => item is Model.Note)) { Assert.IsNotNull(note.WrittenPitch); mei.Note corresp = (mei.Note)aPitchPanel.Descendants().FirstOrDefault(element => element.GetId() == note.ID); if (corresp.HasPnum()) { if (Int32.TryParse(corresp.GetPnumValue(), out int pnum)) { Assert.AreEqual(pnum, note.PitchWithAccid); } else { throw new ArgumentNullException("Pnum could not be parsed!"); } } } }
/// <summary> /// Check if note has @fermata attribute /// </summary> /// <param name="_note">MEI note element</param> /// <returns>True if note has fermata</returns> private static bool GetFermata(mei.Note _note) { if (_note.HasFermata()) { return(true); } else { return(false); } }
/// <summary> /// Adds properties to Note /// </summary> /// <param name="_note">MEI note element</param> /// <param name="_noteObject">Empty note object</param> /// <returns>Note object with content</returns> public static Model.Note ConvertNote(Model.Note _noteObject, mei.Note _note) { _noteObject.Coloration = GetColoration(_note); _noteObject.Fermata = GetFermata(_note); _noteObject.WrittenPitch = ConvertWrittenpitch(_note); _noteObject.Duration = ConvertDuration(_note); _noteObject.Num = ConverterHelper.ConvertNumNumbase(_note.GetNumAttribute()); _noteObject.Numbase = ConverterHelper.ConvertNumNumbase(_note.GetNumbaseAttribute()); _noteObject.Stem = ConvertStem(_note); if (_note.HasAccidGes()) { _noteObject.AccidGes = ConverterHelper.ConvertAccid(_note.GetAccidGesAttribute()); } return(_noteObject); }
/// <summary> /// Check if note has @colored="true" /// </summary> /// <param name="_note">MEI note element</param> /// <returns>Return if note element is colored</returns> private static bool GetColoration(mei.Note _note) { if (_note.HasColored()) { if (_note.GetColoredValue() == "true") { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// Converts @stem.pos and @stem.dir into StemDesc /// </summary> /// <param name="_note">mei.Note element</param> /// <returns>Stem description</returns> private static Model.StemDesc ConvertStem(mei.Note _note) { string pos = null; string dir = null; if (_note.HasStemDir()) { dir = _note.GetStemDirValue(); } if (_note.HasStemPos()) { pos = _note.GetStemPosValue(); } if (Enum.TryParse(pos + dir, true, out Model.StemDesc Stem)) { return(Stem); } else { return(StemDesc.Null); } }
/// <summary> /// Converts the pitch information of a note element into base-40 without accidentals /// </summary> /// <param name="_note">MEI note element</param> /// <returns>Base-40 value as integer</returns> private static int ConvertWrittenpitch(mei.Note _note) { //Conversion without accidentals return(ConverterHelper.ConvertToBase40(_note.GetPnameValue(), _note.GetOctValue())); }
public void Init() { meinote = new mei.Note(); convertedNote = new Model.Note(); }
public void CleanUp() { meinote = null; convertedNote = null; }