private static MvcHtmlString NoteViewerHelper(HtmlHelper htmlHelper, string musicXml, HtmlScoreRendererSettings settings) { MusicXmlParser parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Parse(musicXml)); return(NoteViewerHelper(htmlHelper, score, settings)); }
//protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint) //{ // return new SizeRequest(new Size(widthConstraint, heightConstraint)); //} private static void XmlSourceChanged(BindableObject obj, string oldValue, string newValue) { NoteViewer viewer = obj as NoteViewer; if (string.IsNullOrWhiteSpace(newValue)) { if (!string.IsNullOrWhiteSpace(oldValue)) { viewer.Children.Clear(); } return; } XDocument xmlDocument = XDocument.Parse(newValue); //Apply transformations: if (viewer.XmlTransformations != null) { foreach (var transformation in viewer.XmlTransformations) { xmlDocument = transformation.Parse(xmlDocument); } } MusicXmlParser parser = new MusicXmlParser(); var score = parser.Parse(xmlDocument); score.MeasureInvalidated -= viewer.Score_MeasureInvalidated; viewer.RenderOnCanvas(score); score.MeasureInvalidated += viewer.Score_MeasureInvalidated; }
public void TestRendering() { var currentResults = new ScoreRenderingTestResultsRepository(GetDirectoryPath(inProgressPath)); var previousResults = GetPreviousResults(outputPath); var renderer = new UnitTestScoreRenderer(currentResults); foreach (var file in Directory.EnumerateFiles(inputPath, "*.xml", SearchOption.AllDirectories)) { var xDocument = XDocument.Load(file); var parser = new MusicXmlParser(); var score = parser.Parse(xDocument); foreach (var staff in score.Staves) { Assert.IsTrue(staff.Measures.Where(m => m.Number.HasValue).GroupBy(m => m.Number.Value).All(g => g.Count() == 1), "Duplicate measure numbers detected."); } renderer.Render(score); Assert.IsTrue(!renderer.Exceptions.Any(), "Exceptions occured while rendering."); currentResults.Persist(Path.GetFileName(file)); if (previousResults != null) { previousResults.Load(Path.GetFileName(file)); PerformAssertions(currentResults, previousResults, Path.GetFileName(file)); } } var successPath = Path.Combine(outputPath, Path.GetFileName(currentResults.DataPath)); Directory.Move(currentResults.DataPath, successPath); }
public void CreateMusicPiece(string filename) { _score = MusicXmlParser.GetScore(filename); Guide = new GuidesController(MidiController) { Score = _score, Piano = Piano, Sheet = SheetController }; Sheet = SheetController.SheetModel; //stop program from crashing when reloading musicpiece. Sheet.Reset(); AddGreatStaffsToSheet(); AddMeasuresToGreatStaffs(); AddNotesToMeasures(); Guide.staffEndReached += staffEndReached; Guide.GoToFirstStaff += GoToFirstStaff; Guide.HoldPosition += this.HoldPosition; MidiController.Guide = Guide; KeyboardController.Guide = Guide; }
/// <summary> /// Loads the viewer with a Score object generated from the specified MusicXml file. /// </summary> public void loadFile(string fileName) { this.fileName = fileName; if (File.Exists(fileName)) { // Parser instance converts between Score object and MusicXML var parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Load(fileName)); // Load the content of the specified file into Data Data = score; keySig = (Key)score.FirstStaff.Elements.First(k => k.GetType() == typeof(Key)); if (KeySig == null) { KeySig = new Key(0); } timeSig = (TimeSignature)score.FirstStaff.Elements.First(k => k.GetType() == typeof(TimeSignature)); if (timeSig == null) { timeSig = TimeSignature.CommonTime; } } else { throw new FileNotFoundException(fileName + " not found."); //This and any parser exceptions will be caught by the calling function } }
private void Button_Click_9(object sender, RoutedEventArgs e) { var vm = (TestViewModel)DataContext; var supported = MusicXmlWritingStrategyBase.SupportedElements; var unsupported = MusicXmlWritingStrategyBase.UnsupportedElements; var createdDocument = new MusicXmlParser().ParseBack(vm.Data); }
/// <summary> /// Reads a score from MusicXml document with specific XTransformerParser. /// </summary> /// <param name="document"></param> /// <param name="transformer"></param> /// <returns></returns> public static Score ToScore(this XDocument document, XTransformerParser transformer) { MusicXmlParser parser = new MusicXmlParser(); if (transformer != null) { document = transformer.Parse(document); } return(parser.Parse(document)); }
public void Measure_without_width_attribute_returns_negative_one() { var scoreWithoutMeasureWidthAttribute = MusicXmlParser.GetScore(@"TestData\MusicXmlWithoutMeasureWidthAttribute.xml"); var part = scoreWithoutMeasureWidthAttribute.Parts[0]; var measure = part.Measures[0]; Assert.That(measure.Width, Is.EqualTo(-1)); }
public void Measure_with_decimal_width_attribute() { var scoreWithoutMeasureWidthAttribute = MusicXmlParser.GetScore(@"TestData\MusicXmlWithChords.xml"); var part = scoreWithoutMeasureWidthAttribute.Parts[0]; var measure = part.Measures[0]; Assert.That(measure.Width, Is.EqualTo(199.25)); }
public void Is_chord_tone_false_for_note_without_chord_tag() { var score = MusicXmlParser.GetScore("TestData/MusicXmlWithChords.xml"); var part = score.Parts[0]; var measure = part.Measures[0]; var note = measure.MeasureElements[0].Element as Note; Assert.That(note.IsChordTone, Is.False); }
void LoadTracks() { mxml = MusicXmlParser.GetScore(file_txt.Text); track_cbx.Items.Clear(); foreach (var part in mxml.Parts) { track_cbx.Items.Add(part.Name); } track_cbx.SelectedIndex = 0; track_cbx.IsEnabled = true; }
/// <summary> /// 读取XML文件 /// </summary> /// <param name="file"></param> private void LoadXMLFile(string file) { score = MusicXmlParser.GetScore(Resources.Load <TextAsset>(file)); PartDevideIndex.Clear(); PartDevideIndex.Add(0); foreach (var measure in score.Parts[0].Measures) { if (measure.Attributes?.BarLine == "light-light") { PartDevideIndex.Add(measure.Number); } } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "MusicXml (*.xml)|*.xml"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { MusicXmlParser parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Parse(File.ReadAllText(dialog.FileName))); noteViewer1.DataSource = score; noteViewer1.Refresh(); } }
public void Is_chord_tone_true_for_note_with_chord_tag() { const int knownChordToneIndex = 1; const int knownPartWithChord = 1; var score = MusicXmlParser.GetScore("TestData/MusicXmlWithChords.xml"); var part = score.Parts[knownPartWithChord]; var measure = part.Measures[0]; var note = measure.MeasureElements[knownChordToneIndex].Element as Note; Assert.That(note.IsChordTone, Is.True); }
/// <summary> /// Loads the viewer with a Score object generated from the specified MusicXml file. /// </summary> public void loadFile(string fileName) { this.fileName = fileName; if (File.Exists(fileName)) { // Parser instance converts between Score object and MusicXML var parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Load(fileName)); // Load the content of the specified file into Data Data = score; } else { throw new FileNotFoundException(fileName + " not found."); //This and any parser exceptions will be caught by the calling function } }
/// <summary> /// Loads the viewer with a Score object generated from the specified MusicXml file. /// </summary> public void loadFile(string fileName) { this.fileName = fileName; if (File.Exists(fileName)) { // Parser instance converts between Score object and MusicXML var parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Load(fileName)); // Load the content of the specified file into Data data = null; Data = score; // Get the key signature keySig = (Key)score.FirstStaff.Elements.First(k => k.GetType() == typeof(Key)); if (KeySig == null) { KeySig = new Key(0); } // Get the time signature timeSig = (TimeSignature)score.FirstStaff.Elements.First(k => k.GetType() == typeof(TimeSignature)); if (timeSig == null) { timeSig = TimeSignature.CommonTime; } // Set up the back end data model staves = null; staves = new List <LStaff>(); foreach (var staff in score.Staves) { LStaff ls = null; List <LMeasure> measures = new List <LMeasure>(); foreach (var measure in staff.Measures) { LMeasure m = new LMeasure(measure.Elements, ls, timeSig.WholeNoteCapacity); measures.Add(m); } ls = new LStaff(staff, measures); this.staves.Add(ls); } player = new MidiTaskScorePlayer(data); updateView(); } else { throw new FileNotFoundException(fileName + " not found."); //This and any parser exceptions will be caught by the calling function } }
/// <summary> /// The create. /// </summary> /// <param name="sequence"> /// The sequence. /// </param> /// <param name="sequenceStream"> /// The sequence stream. /// </param> /// <exception cref="Exception"> /// Thrown if congeneric tracks count not equals 1 (track is not monophonic). /// </exception> public void Create(CommonSequence sequence, Stream sequenceStream) { string stringSequence = FileHelper.ReadSequenceFromStream(sequenceStream); var doc = new XmlDocument(); doc.LoadXml(stringSequence); var parser = new MusicXmlParser(); parser.Execute(doc); ScoreTrack tempTrack = parser.ScoreModel; if (tempTrack.CongenericScoreTracks.Count != 1) { throw new Exception("Track contains more then one or zero congeneric score tracks (parts)."); } MatterRepository.CreateOrExtractExistingMatterForSequence(sequence); BaseChain notesSequence = ConvertCongenericScoreTrackToNotesBaseChain(tempTrack.CongenericScoreTracks[0]); long[] notesAlphabet = ElementRepository.GetOrCreateNotesInDb(notesSequence.Alphabet); sequence.Notation = Notation.Notes; Create(sequence, notesAlphabet, notesSequence.Building); BaseChain measuresSequence = ConvertCongenericScoreTrackToMeasuresBaseChain(tempTrack.CongenericScoreTracks[0]); long[] measuresAlphabet = MeasureRepository.GetOrCreateMeasuresInDb(measuresSequence.Alphabet); sequence.Notation = Notation.Measures; sequence.Id = default; Create(sequence, measuresAlphabet, measuresSequence.Building); sequence.Notation = Notation.FormalMotifs; var pauseTreatments = EnumExtensions.ToArray <PauseTreatment>().Where(pt => pt != PauseTreatment.NotApplicable); foreach (PauseTreatment pauseTreatment in pauseTreatments) { BaseChain fmotifsSequence = ConvertCongenericScoreTrackToFormalMotifsBaseChain(tempTrack.CongenericScoreTracks[0], pauseTreatment, false); long[] fmotifsAlphabet = FmotifRepository.GetOrCreateFmotifsInDb(fmotifsSequence.Alphabet); sequence.Id = default; Create(sequence, fmotifsAlphabet, fmotifsSequence.Building, pauseTreatment, false); fmotifsSequence = ConvertCongenericScoreTrackToFormalMotifsBaseChain(tempTrack.CongenericScoreTracks[0], pauseTreatment, true); fmotifsAlphabet = FmotifRepository.GetOrCreateFmotifsInDb(fmotifsSequence.Alphabet); sequence.Id = default; Create(sequence, fmotifsAlphabet, fmotifsSequence.Building, pauseTreatment, true); } }
private void Button_Click_9(object sender, RoutedEventArgs e) { var vm = (TestViewModel)DataContext; var supported = MusicXmlWritingStrategyBase.SupportedElements; var unsupported = MusicXmlWritingStrategyBase.UnsupportedElements; var createdDocument = new MusicXmlParser().ParseBack(noteViewer1.InnerScore); SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "MusicXml (*.xml)|*.xml"; if (dialog.ShowDialog().Value) { createdDocument.Save(dialog.FileName, SaveOptions.None); } }
private static void XmlSourceChanged(NoteViewer contol, string oldValue, string newValue) { XDocument xmlDocument = XDocument.Parse(newValue); //Apply transformations: if (contol.XmlTransformations != null) { foreach (var transformation in contol.XmlTransformations) { xmlDocument = transformation.Parse(xmlDocument); } } MusicXmlParser parser = new MusicXmlParser(); var score = parser.Parse(xmlDocument); contol.RenderOnCanvas(score); }
private static void XmlSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { NoteViewer contol = (NoteViewer)obj; string oldValue = args.OldValue as string; string newValue = args.NewValue as string; var xmlDocument = XDocument.Parse(newValue); //Apply transformations: if (contol.XmlTransformations != null) { //foreach (var transformation in contol.XmlTransformations) xmlDocument = transformation.Parse(xmlDocument); } MusicXmlParser parser = new MusicXmlParser(); var score = parser.Parse(xmlDocument); contol.RenderOnCanvas(score); }
public static void XmlSourceChanged(IXamlNoteViewer viewer, string oldValue, string newValue) { XDocument xmlDocument = XDocument.Parse(newValue); //Apply transformations: if (viewer.XmlTransformations != null) { foreach (var transformation in viewer.XmlTransformations) { xmlDocument = transformation.Parse(xmlDocument); } } MusicXmlParser parser = new MusicXmlParser(); var score = parser.Parse(xmlDocument); score.MeasureInvalidated -= viewer.Score_MeasureInvalidated; viewer.RenderOnCanvas(score); score.MeasureInvalidated += viewer.Score_MeasureInvalidated; }
/// <summary> /// Saves the current Score as a MusicXML file. /// </summary> public void save() { // Create a save dialog to get the output file path Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); if (fileName == "" || !File.Exists(fileName)) { dialog.DefaultExt = "mml"; dialog.CheckPathExists = true; dialog.ValidateNames = true; dialog.Filter = "Music XML|*.mml"; Nullable <bool> result = dialog.ShowDialog(); if (result == false) { throw new FileNotFoundException(); } fileName = dialog.FileName; } try { // Put the staff in a part to meet MusicXML schema requirements Part p1 = new Part(data.FirstStaff); p1.Name = "FirstPart"; p1.PartId = "01"; PartGroup pg1 = new PartGroup(); p1.Group = pg1; data.PartGroups.Add(pg1); data.Parts.Add(p1); // Convert to MusicXML and save var parser = new MusicXmlParser(); var outputXml = parser.ParseBack(data); outputXml.Save(fileName); } catch (Exception ex) { MessageBox.Show("Could not save to " + fileName + ".\n" + ex.Message); fileName = ""; save(); } }
private static void XmlSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { NoteViewer viewer = obj as NoteViewer; string xmlSource = args.NewValue as string; XDocument xmlDocument = XDocument.Parse(xmlSource); //Apply transformations: if (viewer.XmlTransformations != null) { foreach (var transformation in viewer.XmlTransformations) { xmlDocument = transformation.Parse(xmlDocument); } } MusicXmlParser parser = new MusicXmlParser(); var score = parser.Parse(xmlDocument); viewer.RenderOnCanvas(score); }
private void Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "MusicXml (*.xml)|*.xml"; if (dialog.ShowDialog().Value) { string xml = File.ReadAllText(dialog.FileName); noteViewer1.XmlSource = xml; var testViewModel = DataContext as TestViewModel; if (testViewModel.Player != null) { ((IDisposable)testViewModel.Player).Dispose(); } testViewModel.Player = new MidiTaskScorePlayer(noteViewer1.InnerScore); ((MidiTaskScorePlayer)testViewModel.Player).SetInstrument(GeneralMidiInstrument.AcousticGrandPiano); var devices = MidiTaskScorePlayer.AvailableDevices; MusicXmlParser parser = new MusicXmlParser(); noteViewer2.ScoreSource = parser.Parse(XDocument.Parse(xml)); } }
/// <summary> /// Saves the current Score as a MusicXML file. /// PENDING PARSER IMPLEMENTATION FROM MANUFACTURA /// </summary> /// <returns></returns> public bool save() { var setting = data.FirstStaff.MeasureAddingRule; Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); if (fileName == "" || !File.Exists(fileName)) { dialog.DefaultExt = "mml"; dialog.CheckPathExists = true; dialog.ValidateNames = true; dialog.Filter = "Music Maker Score|*.mms|Music XML|*.mml"; Nullable <bool> result = dialog.ShowDialog(); if (result == false) { return(false); } fileName = dialog.FileName; } if (dialog.FilterIndex == 1) // Native binary format { //Score try { BinaryFormatter bf = new BinaryFormatter(); byte[] outBytes; using (var ms = new MemoryStream()) { foreach (Staff s in data.Staves) { foreach (MusicalSymbol item in s.Elements) { if (item.GetType().IsSubclassOf(typeof(NoteOrRest)) || item.GetType() == typeof(Barline)) { bf.Serialize(ms, item); } } } bf.Serialize(ms, data); outBytes = ms.ToArray(); } using (FileStream stream = new FileStream(fileName, FileMode.Create)) { using (BinaryWriter writer = new BinaryWriter(stream)) { writer.Write(outBytes); writer.Close(); } } } catch (Exception ex) { MessageBox.Show("Could not save to " + fileName + ".\n" + ex.Message); fileName = ""; save(); } } else { try // MusicXML format (not yet implemented in Manufactura) { var parser = new MusicXmlParser(); var outputXml = parser.ParseBack(data); outputXml.Save(fileName); } catch (Exception ex) { MessageBox.Show("Could not save to " + fileName + ".\n" + ex.Message); fileName = ""; save(); } } return(true); }
private void Button_Click(object sender, RoutedEventArgs e) { string scoreXml = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?> <!DOCTYPE score-partwise PUBLIC ""-//Recordare//DTD MusicXML 3.0 Partwise//EN"" ""http://www.musicxml.org/dtds/partwise.dtd""> <score-partwise version=""3.0""> <identification> <rights>©</rights> <encoding> <software>Finale NotePad 2012 for Windows</software> <software>Dolet Light for Finale NotePad 2012</software> <encoding-date>2014-06-10</encoding-date> <supports attribute=""new-system"" element=""print"" type=""yes"" value=""yes""/> <supports attribute=""new-page"" element=""print"" type=""yes"" value=""yes""/> </encoding> </identification> <defaults> <scaling> <millimeters>7.2319</millimeters> <tenths>40</tenths> </scaling> <page-layout> <page-height>1545</page-height> <page-width>1194</page-width> <page-margins type=""both""> <left-margin>140</left-margin> <right-margin>70</right-margin> <top-margin>88</top-margin> <bottom-margin>88</bottom-margin> </page-margins> </page-layout> <system-layout> <system-margins> <left-margin>0</left-margin> <right-margin>0</right-margin> </system-margins> <system-distance>121</system-distance> <top-system-distance>70</top-system-distance> </system-layout> <appearance> <line-width type=""stem"">0.7487</line-width> <line-width type=""beam"">5</line-width> <line-width type=""staff"">0.7487</line-width> <line-width type=""light barline"">0.7487</line-width> <line-width type=""heavy barline"">5</line-width> <line-width type=""leger"">0.7487</line-width> <line-width type=""ending"">0.7487</line-width> <line-width type=""wedge"">0.7487</line-width> <line-width type=""enclosure"">0.7487</line-width> <line-width type=""tuplet bracket"">0.7487</line-width> <note-size type=""grace"">60</note-size> <note-size type=""cue"">60</note-size> <distance type=""hyphen"">120</distance> <distance type=""beam"">8</distance> </appearance> <music-font font-family=""Maestro,engraved"" font-size=""20.5""/> <word-font font-family=""Times New Roman"" font-size=""10.25""/> </defaults> <part-list> <score-part id=""P1""> <part-name>Violin</part-name> <part-abbreviation>Vln.</part-abbreviation> <score-instrument id=""P1-I1""> <instrument-name>SmartMusic SoftSynth 1</instrument-name> <instrument-sound>strings.violin</instrument-sound> <solo/> </score-instrument> <midi-instrument id=""P1-I1""> <midi-channel>1</midi-channel> <midi-bank>15489</midi-bank> <midi-program>41</midi-program> <volume>80</volume> <pan>0</pan> </midi-instrument> </score-part> </part-list> <!--=========================================================--> <part id=""P1""> <measure number=""1"" width=""236""> <print> <system-layout> <system-margins> <left-margin>70</left-margin> <right-margin>0</right-margin> </system-margins> <top-system-distance>167</top-system-distance> </system-layout> <measure-numbering>none</measure-numbering> </print> <attributes> <divisions>2</divisions> <key> <fifths>-1</fifths> <mode>major</mode> </key> <time> <beats>2</beats> <beat-type>4</beat-type> </time> <clef> <sign>G</sign> <line>2</line> </clef> </attributes> <sound tempo=""120""/> <note default-x=""111""> <pitch> <step>A</step> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-60"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""111""> <chord/> <pitch> <step>A</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""142""> <pitch> <step>A</step> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-60"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""142""> <chord/> <pitch> <step>A</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""174""> <pitch> <step>B</step> <alter>-1</alter> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-55"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""174""> <chord/> <pitch> <step>B</step> <alter>-1</alter> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""204""> <pitch> <step>C</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-50"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""204""> <chord/> <pitch> <step>C</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> </measure> <!--=======================================================--> <measure number=""2"" width=""135""> <note default-x=""16""> <pitch> <step>C</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-60"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""16""> <chord/> <pitch> <step>C</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""46""> <pitch> <step>G</step> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-65"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""46""> <chord/> <pitch> <step>G</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""75""> <pitch> <step>A</step> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-60"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""75""> <chord/> <pitch> <step>A</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""105""> <pitch> <step>B</step> <alter>-1</alter> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-55"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""105""> <chord/> <pitch> <step>B</step> <alter>-1</alter> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> </measure> <!--=======================================================--> <measure number=""3"" width=""141""> <note default-x=""17""> <pitch> <step>B</step> <alter>-1</alter> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-55"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""17""> <chord/> <pitch> <step>B</step> <alter>-1</alter> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""47""> <pitch> <step>B</step> <alter>-1</alter> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-55"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""47""> <chord/> <pitch> <step>B</step> <alter>-1</alter> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""78""> <pitch> <step>C</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-50"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""78""> <chord/> <pitch> <step>C</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""109""> <pitch> <step>D</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-45"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""109""> <chord/> <pitch> <step>D</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> </measure> <!--=======================================================--> <measure number=""4"" width=""141""> <note default-x=""16""> <pitch> <step>D</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-55"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""16""> <chord/> <pitch> <step>D</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""47""> <pitch> <step>A</step> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-60"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""47""> <chord/> <pitch> <step>A</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""79""> <pitch> <step>B</step> <alter>-1</alter> <octave>4</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-55"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""79""> <chord/> <pitch> <step>B</step> <alter>-1</alter> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""109""> <pitch> <step>C</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-50"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""109""> <chord/> <pitch> <step>C</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> </measure> <!--=======================================================--> <measure number=""5"" width=""141""> <note default-x=""16""> <pitch> <step>F</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-35"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""16""> <chord/> <pitch> <step>F</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""47""> <pitch> <step>F</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-35"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""47""> <chord/> <pitch> <step>F</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""78""> <pitch> <step>E</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-40"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""78""> <chord/> <pitch> <step>E</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""109""> <pitch> <step>D</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-42.5"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""109""> <chord/> <pitch> <step>D</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> </measure> <!--=======================================================--> <measure number=""6"" width=""119""> <note default-x=""14""> <pitch> <step>D</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-45"">down</stem> <beam number=""1"">begin</beam> </note> <note default-x=""14""> <chord/> <pitch> <step>G</step> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""40""> <pitch> <step>B</step> <alter>-1</alter> <octave>5</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem default-y=""-40"">down</stem> <beam number=""1"">end</beam> </note> <note default-x=""40""> <chord/> <pitch> <step>D</step> <octave>6</octave> </pitch> <duration>1</duration> <voice>1</voice> <type>eighth</type> <stem>down</stem> </note> <note default-x=""67""> <rest/> <duration>2</duration> <voice>1</voice> <type>quarter</type> </note> <barline location=""right""> <bar-style>light-heavy</bar-style> </barline> </measure> </part> <!--=========================================================--> </score-partwise> "; MusicXmlParser parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Parse(scoreXml)); noteViewer1.XmlSource = scoreXml; noteViewer2.ScoreSource = score; }
public void insertNewPartitureXml(string path, string login, int originalVersionId) { MusicXmlParser parser = new MusicXmlParser(); Score newScore = parser.GetScore(path); partiture partiture = new partiture { pk_partiture_id = partituresTable.Count() + 1, work_number = newScore.MovementNumber.ToString(), title = newScore.MovementTitle, tempo = newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault <Measure>().Attributes.Divisions.ToString(), meter = newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault <Measure>().Attributes.Time.Beats.ToString() + "/" + newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault <Measure>().Attributes.Time.Mode, note_length = "1/4", part_key = keyFromFifths(newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault().Attributes.Key.Fifths), filepath = path }; if (originalVersionId == 0) { partiture.version_of = partituresTable.Count() + 1; } else { partiture.version_of = originalVersionId; } creators creators = new creators(); creators.pk_creators_id = creatorsTable.Count() + 1; creators.composer = newScore.Identification.Composer; creators.poet = (newScore.Identification.Poet != string.Empty) ? newScore.Identification.Poet : newScore.Identification.Lyricist; System.Diagnostics.Debug.Print(creators.composer + creators.poet); creators.authors_of = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1; if (newScore.Instrument != null) { if (newScore.Instrument.Name != string.Empty) { instruments instrument = new instruments { pk_instrument_id = instrumentsTable.Count() + 1, instrument_name = newScore.Instrument.Name, fk_part_in = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1 }; instrumentsTable.InsertOnSubmit(instrument); } } else { instruments instrument = new instruments { pk_instrument_id = instrumentsTable.Count() + 1, instrument_name = string.Empty, fk_part_in = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1 }; instrumentsTable.InsertOnSubmit(instrument); } software soft = new software { pk_software_id = softwareTable.Count() + 1, software_name = newScore.Identification.Encoding.Software, encoding_date = newScore.Identification.Encoding.EncodingDate, fk_used_for_encoding = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1 }; addedby added = new addedby { id = addedTable.Count() + 1, fk_user_id = GetUserIdByLogin(login), fk_partiture_id = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1, added_on = DateTime.Now }; partituresTable.InsertOnSubmit(partiture); creatorsTable.InsertOnSubmit(creators); softwareTable.InsertOnSubmit(soft); addedTable.InsertOnSubmit(added); db.SubmitChanges(); }
public void SetUp() { _scoreWithStaffValues = MusicXmlParser.GetScore("TestData/MusicXmlWithStaffValues.xml"); }