public void ExportAsMusicXml(TextWriter w) { w.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); w.WriteLine("<!DOCTYPE score-partwise PUBLIC \"-//Recordare//DTD MusicXML 2.0 Partwise//EN\""); w.WriteLine(" \"http://www.musicxml.org/dtds/partwise.dtd\">"); w.WriteLine("<score-partwise version=\"2.0\">"); w.WriteLine(" <part-list>"); w.WriteLine(" <part-group number=\"1\" type=\"start\">"); w.WriteLine(" <group-symbol>bracket</group-symbol>"); w.WriteLine(" <group-barline>yes</group-barline>"); w.WriteLine(" </part-group>"); w.WriteLine(" <score-part id=\"P1\">"); w.WriteLine(" <part-name>Sop</part-name>"); w.WriteLine(" <part-abbreviation>S</part-abbreviation>"); w.WriteLine(" </score-part>"); w.WriteLine(" <score-part id=\"P2\">"); w.WriteLine(" <part-name>Alt</part-name>"); w.WriteLine(" <part-abbreviation>A</part-abbreviation>"); w.WriteLine(" </score-part>"); w.WriteLine(" <score-part id=\"P3\">"); w.WriteLine(" <part-name>Ten</part-name>"); w.WriteLine(" <part-abbreviation>T</part-abbreviation>"); w.WriteLine(" </score-part>"); w.WriteLine(" <score-part id=\"P4\">"); w.WriteLine(" <part-name>Bas</part-name>"); w.WriteLine(" <part-abbreviation>B</part-abbreviation>"); w.WriteLine(" </score-part>"); w.WriteLine(" <part-group number=\"1\" type=\"stop\"/>"); w.WriteLine(" </part-list>"); w.WriteLine(" <!--=========================================================-->"); // Sop MXOutputPartHeader(w, "P1", ClefType.G2); int duration = 0; int measure = 0; foreach (var chord in chordSaves) { if (duration != 0 && (duration % 16) == 0) { ++measure; w.WriteLine(" </measure>"); w.WriteLine(" <!--=========================================================-->"); w.WriteLine(" <measure number=\"{0}\">", measure); } var sopNote = new LetterName(chord.sop.letterName); w.WriteLine(" <note>"); w.WriteLine(" <pitch>"); w.WriteLine(" <step>{0}</step>", sopNote.NaturalLetterName()); w.WriteLine(" <alter>{0}</alter>", ((int)sopNote.GetKeySigType()) - (int)KeySigType.Natural); w.WriteLine(" <octave>{0}</octave>", chord.sop.octave); w.WriteLine(" </pitch>"); w.WriteLine(" <duration>2</duration>"); w.WriteLine(" <type>half</type>"); w.WriteLine(" </note>"); duration += 8; } MXOutputPartFooter(w); w.WriteLine(" <!--=========================================================-->"); // Alt MXOutputPartHeader(w, "P2", ClefType.G2); duration = 0; measure = 0; foreach (var chord in chordSaves) { if (duration != 0 && (duration % 16) == 0) { ++measure; w.WriteLine(" </measure>"); w.WriteLine(" <!--=========================================================-->"); w.WriteLine(" <measure number=\"{0}\">", measure); } var altNote = new LetterName(chord.alt.letterName); w.WriteLine(" <note>"); w.WriteLine(" <pitch>"); w.WriteLine(" <step>{0}</step>", altNote.NaturalLetterName()); w.WriteLine(" <alter>{0}</alter>", ((int)altNote.GetKeySigType()) - (int)KeySigType.Natural); w.WriteLine(" <octave>{0}</octave>", chord.alt.octave); w.WriteLine(" </pitch>"); w.WriteLine(" <duration>2</duration>"); w.WriteLine(" <type>half</type>"); w.WriteLine(" </note>"); duration += 8; } MXOutputPartFooter(w); w.WriteLine(" <!--=========================================================-->"); // へ音記号の五線 Ten MXOutputPartHeader(w, "P3", ClefType.F4); duration = 0; measure = 0; foreach (var chord in chordSaves) { if (duration != 0 && (duration % 16) == 0) { ++measure; w.WriteLine(" </measure>"); w.WriteLine(" <!--=========================================================-->"); w.WriteLine(" <measure number=\"{0}\">", measure); } // Ten var tenNote = new LetterName(chord.ten.letterName); w.WriteLine(" <note>"); w.WriteLine(" <pitch>"); w.WriteLine(" <step>{0}</step>", tenNote.NaturalLetterName()); w.WriteLine(" <alter>{0}</alter>", ((int)tenNote.GetKeySigType()) - (int)KeySigType.Natural); w.WriteLine(" <octave>{0}</octave>", chord.ten.octave); w.WriteLine(" </pitch>"); w.WriteLine(" <duration>2</duration>"); w.WriteLine(" <type>half</type>"); w.WriteLine(" </note>"); duration += 8; } MXOutputPartFooter(w); w.WriteLine(" <!--=========================================================-->"); // へ音記号の五線 Bas MXOutputPartHeader(w, "P4", ClefType.F4); duration = 0; measure = 0; foreach (var chord in chordSaves) { if (duration != 0 && (duration % 16) == 0) { ++measure; w.WriteLine(" </measure>"); w.WriteLine(" <!--=========================================================-->"); w.WriteLine(" <measure number=\"{0}\">", measure); } // Bas var basNote = new LetterName(chord.bas.letterName); w.WriteLine(" <note>"); w.WriteLine(" <pitch>"); w.WriteLine(" <step>{0}</step>", basNote.NaturalLetterName()); w.WriteLine(" <alter>{0}</alter>", ((int)basNote.GetKeySigType()) - (int)KeySigType.Natural); w.WriteLine(" <octave>{0}</octave>", chord.bas.octave); w.WriteLine(" </pitch>"); w.WriteLine(" <duration>2</duration>"); w.WriteLine(" <type>half</type>"); w.WriteLine(" </note>"); duration += 8; } MXOutputPartFooter(w); w.WriteLine(" <!--=========================================================-->"); w.WriteLine("</score-partwise>"); }
public LN NaturalLetterName() { return(LetterName.NaturalLetterName()); }