如何在 jFugue 5.0 中使用 MusicXmlParser?
How to use MusicXmlParser in jFugue 5.0?
我正在尝试将 Staccato Pattern 解析为 MusicXml。但是,它不起作用,因为解析的 MusicXml 几乎不包含任何内容。不知道是我的 Staccato 弦有问题,还是 MusicXmlParser 有问题。
这是我的代码,包括 Staccato 字符串:
public class TestMusicXml {
public static void main(String[] args) {
Pattern p = new Pattern(
"#Score_Beginning I[PIANO] T100 TIME:6/4 KEY:AMIN #Variation_0 #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_1 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_2 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_3 E5/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_4 E4/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_5 E4/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 E5/0.25 |");
StaccatoParser parser = new StaccatoParser();
MusicXmlParserListener listener = new MusicXmlParserListener();
parser.addParserListener(listener);
DevLog.debug("parsing: " + p);
parser.parse(p);
String musicXmlStr = listener.getMusicXMLString();
DevLog.debug("writing music xml: " + musicXmlStr);
}
}
这是输出:
2017-07-16 05:36:16.649 1 D [SysProp] song.devlog.printDateTimeInSystemOut=DefaultVal: true, SetVal : null
2017-07-16 05:36:16.649 1 D [SysProp] song.devlog.printNothingInSystemOut=DefaultVal: false, SetVal: null
2017-07-16 05:36:16.649 1 D [SysProp] issac.logLevel=DefaultVal:-S-T-D-I-W-E-,SetVal:空
2017-07-16 05:36:16.626 1D解析:#Score_Beginning I[PIANO] T100 TIME:6/4 KEY:AMIN #Variation_0 #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_1 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_2 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_3 E5/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_4 E4/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_5 E4/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 E5/0.25 |
2017-07-16 05:36:16.674 1D作曲xml:
JFugue MusicXMLRenderer
所以解析后的musicXml结果为:
<?xml version="1.0"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise><identification><creator type="software">JFugue MusicXMLRenderer</creator></identification><part-list /></score-partwise>
我所有的笔记都不见了。我错过了什么?
提前致谢。
它在 JFugue 的下载页面中隐藏得太深,无法立即看到,但是:"Please note that there is no current implementation for MusicXmlParserListener. JFugue still needs: a MusicXmlParserListener updated for JFugue 5.0, more thorough tests for MusicXMLParser, ..."
(我会努力让下载代码的其他人更清楚这一点)。
JFugue 中的 MusicXML 功能是由志愿者贡献的,在更新最新版本的 MusicXML 和最新版本的 JFugue 的代码方面存在一些差距。
我正在尝试将 Staccato Pattern 解析为 MusicXml。但是,它不起作用,因为解析的 MusicXml 几乎不包含任何内容。不知道是我的 Staccato 弦有问题,还是 MusicXmlParser 有问题。
这是我的代码,包括 Staccato 字符串:
public class TestMusicXml {
public static void main(String[] args) {
Pattern p = new Pattern(
"#Score_Beginning I[PIANO] T100 TIME:6/4 KEY:AMIN #Variation_0 #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_1 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_2 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_3 E5/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_4 E4/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_5 E4/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 E5/0.25 |");
StaccatoParser parser = new StaccatoParser();
MusicXmlParserListener listener = new MusicXmlParserListener();
parser.addParserListener(listener);
DevLog.debug("parsing: " + p);
parser.parse(p);
String musicXmlStr = listener.getMusicXMLString();
DevLog.debug("writing music xml: " + musicXmlStr);
}
}
这是输出:
2017-07-16 05:36:16.649 1 D [SysProp] song.devlog.printDateTimeInSystemOut=DefaultVal: true, SetVal : null 2017-07-16 05:36:16.649 1 D [SysProp] song.devlog.printNothingInSystemOut=DefaultVal: false, SetVal: null 2017-07-16 05:36:16.649 1 D [SysProp] issac.logLevel=DefaultVal:-S-T-D-I-W-E-,SetVal:空 2017-07-16 05:36:16.626 1D解析:#Score_Beginning I[PIANO] T100 TIME:6/4 KEY:AMIN #Variation_0 #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_1 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_2 E5/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 #Variation_3 E5/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_4 E4/0.25 | #Chord_0 A3/0.25 | F#4/0.25 F#4/0.25 A3/0.25 D5/0.25 D5/0.25 A3/0.25 | #Chord_1 G3/0.25 | Eb4/0.25 Eb4/0.25 G3/0.25 C5/0.25 C5/0.25 G3/0.25 | #Chord_2 F#4/0.25 | D5/0.25 D5/0.25 F#4/0.25 B4/0.25 B4/0.25 F#4/0.25 | #Chord_3 E4/0.25 | C#5/0.25 C#5/0.25 E4/0.25 A4/0.25 A4/0.25 #Variation_5 E4/0.25 | #Chord_0 A4/0.25 | F#5/0.25 F#5/0.25 A4/0.25 D5/0.25 D5/0.25 A4/0.25 | #Chord_1 G4/0.25 | Eb5/0.25 Eb5/0.25 G4/0.25 C5/0.25 C5/0.25 G4/0.25 | #Chord_2 F#5/0.25 | D6/0.25 D6/0.25 F#5/0.25 B4/0.25 B4/0.25 F#5/0.25 | #Chord_3 E5/0.25 | C#6/0.25 C#6/0.25 E5/0.25 A4/0.25 A4/0.25 E5/0.25 | 2017-07-16 05:36:16.674 1D作曲xml: JFugue MusicXMLRenderer
所以解析后的musicXml结果为:
<?xml version="1.0"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise><identification><creator type="software">JFugue MusicXMLRenderer</creator></identification><part-list /></score-partwise>
我所有的笔记都不见了。我错过了什么?
提前致谢。
它在 JFugue 的下载页面中隐藏得太深,无法立即看到,但是:"Please note that there is no current implementation for MusicXmlParserListener. JFugue still needs: a MusicXmlParserListener updated for JFugue 5.0, more thorough tests for MusicXMLParser, ..."
(我会努力让下载代码的其他人更清楚这一点)。
JFugue 中的 MusicXML 功能是由志愿者贡献的,在更新最新版本的 MusicXML 和最新版本的 JFugue 的代码方面存在一些差距。