I'm trying to use jFugue + gervill to create music with Java 7. I've the following code
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());
}
The problem is that if I change the soundbank, the instruments sound doesn't change and the instruments printed are always the same. What I wrong?
I find the solution (I think :-)). I've to invert the open and loadAllInstruments calls:
synt.open(); synt.loadAllInstruments(soundbank);