我正在尝试使用 jFugue + gervill 用 Java 7 创建音乐。我有以下代码
Soundbank soundbank = MidiSystem.getSoundbank(new File("/home/morelli/tmp/SoundBanks/JR_elepiano.sf2"));
Synthesizer synt = MidiSystem.getSynthesizer();
synt.loadAllInstruments(soundbank);
synt.open();
Player player = new Player(synt);
Pattern pattern = new Pattern("$PP=0 T120 V0 I42 C4ww V1 I[PP] C5w+E5qq_G5qq C5w+E5qq_G5qq C5w+A5qq_g5qq C5w+A5qq_g5qq V2 I43 G3q G3q G3q G3q G3q G3q G3q G3q V9 81q");
Rhythm rhythm = new Rhythm();
rhythm.setLayer(1, "O..oO...O..oOO..");
rhythm.setLayer(2, "..*...*...*...*.");
rhythm.setLayer(3, "^^^^^^^^^^^^^^^^");
rhythm.setLayer(4, "...............!");
rhythm.addSubstitution('O', "[BASS_DRUM]i");
rhythm.addSubstitution('o', "Rs [BASS_DRUM]s");
rhythm.addSubstitution('*', "[ACOUSTIC_SNARE]i");
rhythm.addSubstitution('^', "[PEDAL_HI_HAT]s Rs");
rhythm.addSubstitution('!', "[CRASH_CYMBAL_1]s Rs");
rhythm.addSubstitution('.', "Ri");
Pattern rpattern = rhythm.getPattern();
rpattern.repeat(2);
pattern.add(rpattern);
player.play(pattern);
player.saveMidi(pattern, new File("/tmp/music-file.mid"));
//System.out.println(Arrays.toString(synt.getLoadedInstruments()));
for (javax.sound.midi.Instrument l: synt.getLoadedInstruments()) {
System.out.println(l.toString());
}
问题是,如果我更改音库,乐器的声音不会改变,而且打印的乐器总是一样的。我错了什么?